1 /* 2 * CPM (clock and power management) support for the JZ4730. 3 * 4 * Copyright (C) 2017, 2018, 2020, 2021, 2023, 5 * 2024 Paul Boddie <paul@boddie.org.uk> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA 21 */ 22 23 #pragma once 24 25 #include <l4/devices/clocks.h> 26 #include <l4/sys/types.h> 27 #include <stdint.h> 28 29 30 31 /* JZ4730-specific clocks. */ 32 33 enum Clock_jz4730_identifiers 34 { 35 Clock_jz4730_identifier_base = Clock_specific_start, 36 37 /* Actual clocks. */ 38 39 Clock_lcd_pixel_in = Clock_specific_start, 40 Clock_msc_16MHz, 41 Clock_msc_24MHz, 42 Clock_pll_div_2, 43 Clock_pll_usb, 44 Clock_usb_phy_48MHz, 45 46 /* Not a clock: limit for array definition. */ 47 48 Clock_jz4730_identifier_count, 49 }; 50 51 52 53 #ifdef __cplusplus 54 55 #include <l4/devices/cpm-generic.h> 56 57 class Cpm_jz4730_chip : public Cpm_chip 58 { 59 public: 60 Cpm_jz4730_chip(l4_addr_t addr); 61 }; 62 63 Cpm_chip *jz4730_cpm_chip(l4_addr_t cpm_base); 64 65 #endif /* __cplusplus */ 66 67 68 69 /* C language interface. */ 70 71 EXTERN_C_BEGIN 72 73 void *jz4730_cpm_init(l4_addr_t cpm_base); 74 75 const char *jz4730_cpm_clock_type(void *cpm, enum Clock_identifiers clock); 76 77 int jz4730_cpm_have_clock(void *cpm, enum Clock_identifiers clock); 78 void jz4730_cpm_start_clock(void *cpm, enum Clock_identifiers clock); 79 void jz4730_cpm_stop_clock(void *cpm, enum Clock_identifiers clock); 80 81 int jz4730_cpm_get_parameters(void *cpm, enum Clock_identifiers clock, 82 uint32_t parameters[]); 83 int jz4730_cpm_set_parameters(void *cpm, enum Clock_identifiers clock, 84 int num_parameters, uint32_t parameters[]); 85 86 uint8_t jz4730_cpm_get_source(void *cpm, enum Clock_identifiers clock); 87 void jz4730_cpm_set_source(void *cpm, enum Clock_identifiers clock, uint8_t source); 88 enum Clock_identifiers jz4730_cpm_get_source_clock(void *cpm, enum Clock_identifiers clock); 89 void jz4730_cpm_set_source_clock(void *cpm, enum Clock_identifiers clock, enum Clock_identifiers source); 90 91 uint64_t jz4730_cpm_get_source_frequency(void *cpm, enum Clock_identifiers clock); 92 93 uint64_t jz4730_cpm_get_frequency(void *cpm, enum Clock_identifiers clock); 94 int jz4730_cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint64_t frequency); 95 96 EXTERN_C_END