1 /* 2 * CPM (clock and power management) support for the X1600. 3 * 4 * Copyright (C) 2017, 2018, 2020, 2021, 2023 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 #pragma once 23 24 #include <l4/devices/clocks.h> 25 #include <l4/sys/types.h> 26 #include <stdint.h> 27 28 29 30 /* X1600-specific clocks. */ 31 32 enum Clock_x1600_identifiers 33 { 34 Clock_x1600_identifier_base = Clock_specific_start, 35 Clock_usb_phy_12MHz = Clock_specific_start, 36 Clock_x1600_identifier_count, /* not a clock: limit for array definition */ 37 }; 38 39 40 41 #ifdef __cplusplus 42 43 #include <l4/devices/cpm.h> 44 45 class Cpm_x1600_chip : public Cpm_chip 46 { 47 public: 48 explicit Cpm_x1600_chip(l4_addr_t addr); 49 }; 50 51 #endif /* __cplusplus */ 52 53 54 55 /* C language interface. */ 56 57 EXTERN_C_BEGIN 58 59 void *x1600_cpm_init(l4_addr_t cpm_base); 60 61 const char *x1600_cpm_clock_type(void *cpm, enum Clock_identifiers clock); 62 63 int x1600_cpm_have_clock(void *cpm, enum Clock_identifiers clock); 64 void x1600_cpm_start_clock(void *cpm, enum Clock_identifiers clock); 65 void x1600_cpm_stop_clock(void *cpm, enum Clock_identifiers clock); 66 67 int x1600_cpm_get_parameters(void *cpm, enum Clock_identifiers clock, 68 uint32_t parameters[]); 69 int x1600_cpm_set_parameters(void *cpm, enum Clock_identifiers clock, 70 int num_parameters, uint32_t parameters[]); 71 72 uint8_t x1600_cpm_get_source(void *cpm, enum Clock_identifiers clock); 73 void x1600_cpm_set_source(void *cpm, enum Clock_identifiers clock, uint8_t source); 74 enum Clock_identifiers x1600_cpm_get_source_clock(void *cpm, enum Clock_identifiers clock); 75 void x1600_cpm_set_source_clock(void *cpm, enum Clock_identifiers clock, enum Clock_identifiers source); 76 77 uint64_t x1600_cpm_get_source_frequency(void *cpm, enum Clock_identifiers clock); 78 79 uint64_t x1600_cpm_get_frequency(void *cpm, enum Clock_identifiers clock); 80 int x1600_cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint64_t frequency); 81 82 EXTERN_C_END