paul@160 | 1 | /* |
paul@160 | 2 | * CPM (clock and power management) support for the X1600. |
paul@160 | 3 | * |
paul@160 | 4 | * Copyright (C) 2017, 2018, 2020, 2021, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@160 | 5 | * |
paul@160 | 6 | * This program is free software; you can redistribute it and/or |
paul@160 | 7 | * modify it under the terms of the GNU General Public License as |
paul@160 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@160 | 9 | * the License, or (at your option) any later version. |
paul@160 | 10 | * |
paul@160 | 11 | * This program is distributed in the hope that it will be useful, |
paul@160 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@160 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@160 | 14 | * GNU General Public License for more details. |
paul@160 | 15 | * |
paul@160 | 16 | * You should have received a copy of the GNU General Public License |
paul@160 | 17 | * along with this program; if not, write to the Free Software |
paul@160 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@160 | 19 | * Boston, MA 02110-1301, USA |
paul@160 | 20 | */ |
paul@160 | 21 | |
paul@160 | 22 | #pragma once |
paul@160 | 23 | |
paul@211 | 24 | #include <l4/devices/clocks.h> |
paul@160 | 25 | #include <l4/sys/types.h> |
paul@160 | 26 | #include <stdint.h> |
paul@160 | 27 | |
paul@160 | 28 | |
paul@160 | 29 | |
paul@243 | 30 | /* X1600-specific clocks. */ |
paul@243 | 31 | |
paul@243 | 32 | enum Clock_x1600_identifiers |
paul@243 | 33 | { |
paul@243 | 34 | Clock_x1600_identifier_base = Clock_specific_start, |
paul@243 | 35 | Clock_usb_phy_12MHz = Clock_specific_start, |
paul@243 | 36 | Clock_x1600_identifier_count, /* not a clock: limit for array definition */ |
paul@243 | 37 | }; |
paul@243 | 38 | |
paul@243 | 39 | |
paul@243 | 40 | |
paul@160 | 41 | #ifdef __cplusplus |
paul@160 | 42 | |
paul@211 | 43 | #include <l4/devices/cpm.h> |
paul@160 | 44 | |
paul@160 | 45 | class Cpm_x1600_chip : public Cpm_chip |
paul@160 | 46 | { |
paul@160 | 47 | public: |
paul@211 | 48 | explicit Cpm_x1600_chip(l4_addr_t addr); |
paul@160 | 49 | }; |
paul@160 | 50 | |
paul@160 | 51 | #endif /* __cplusplus */ |
paul@160 | 52 | |
paul@160 | 53 | |
paul@160 | 54 | |
paul@160 | 55 | /* C language interface. */ |
paul@160 | 56 | |
paul@160 | 57 | EXTERN_C_BEGIN |
paul@160 | 58 | |
paul@160 | 59 | void *x1600_cpm_init(l4_addr_t cpm_base); |
paul@160 | 60 | |
paul@176 | 61 | const char *x1600_cpm_clock_type(void *cpm, enum Clock_identifiers clock); |
paul@176 | 62 | |
paul@160 | 63 | int x1600_cpm_have_clock(void *cpm, enum Clock_identifiers clock); |
paul@160 | 64 | void x1600_cpm_start_clock(void *cpm, enum Clock_identifiers clock); |
paul@160 | 65 | void x1600_cpm_stop_clock(void *cpm, enum Clock_identifiers clock); |
paul@160 | 66 | |
paul@185 | 67 | int x1600_cpm_get_parameters(void *cpm, enum Clock_identifiers clock, |
paul@185 | 68 | uint32_t parameters[]); |
paul@185 | 69 | int x1600_cpm_set_parameters(void *cpm, enum Clock_identifiers clock, |
paul@185 | 70 | int num_parameters, uint32_t parameters[]); |
paul@160 | 71 | |
paul@161 | 72 | uint8_t x1600_cpm_get_source(void *cpm, enum Clock_identifiers clock); |
paul@161 | 73 | void x1600_cpm_set_source(void *cpm, enum Clock_identifiers clock, uint8_t source); |
paul@185 | 74 | enum Clock_identifiers x1600_cpm_get_source_clock(void *cpm, enum Clock_identifiers clock); |
paul@185 | 75 | void x1600_cpm_set_source_clock(void *cpm, enum Clock_identifiers clock, enum Clock_identifiers source); |
paul@160 | 76 | |
paul@213 | 77 | uint64_t x1600_cpm_get_source_frequency(void *cpm, enum Clock_identifiers clock); |
paul@160 | 78 | |
paul@213 | 79 | uint64_t x1600_cpm_get_frequency(void *cpm, enum Clock_identifiers clock); |
paul@213 | 80 | int x1600_cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint64_t frequency); |
paul@160 | 81 | |
paul@160 | 82 | EXTERN_C_END |