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