1 /* 2 * Generic access to clock and power management functionality. 3 * 4 * Copyright (C) 2024 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <string.h> 23 #include "cpm-generic.h" 24 25 /* Function declarations reproduced here to avoid clock identifier conflicts in 26 the chip-specific headers. */ 27 28 // NOTE: To be supported... 29 //extern Cpm_chip *jz4730_cpm_chip(l4_addr_t); 30 //extern Cpm_chip *jz4740_cpm_chip(l4_addr_t); 31 extern Cpm_chip *jz4780_cpm_chip(l4_addr_t); 32 extern Cpm_chip *x1600_cpm_chip(l4_addr_t); 33 34 struct cpm_function 35 { 36 const char *name; 37 Cpm_chip *(*function)(l4_addr_t); 38 }; 39 40 static struct cpm_function functions[] = { 41 //{"jz4730", jz4730_cpm_chip}, 42 //{"jz4740", jz4740_cpm_chip}, 43 {"jz4780", jz4780_cpm_chip}, 44 {"x1600", x1600_cpm_chip}, 45 {NULL, NULL} 46 }; 47 48 Cpm_chip *new_cpm_chip(const char *name, l4_addr_t cpm_base) 49 { 50 for (struct cpm_function *f = functions; f->name != NULL; f++) 51 { 52 if (!strcmp(name, f->name)) 53 return f->function(cpm_base); 54 } 55 56 return NULL; 57 }