at91: Support PMC clock bindings
Subsystems (6)
v2 cover at91: Support PMC clock bindings
The following patchset add supports for the PMC clk bindings for at91.
The patchset was tested on:
- at91sam9264ek - DT enabled
- sama5d4-xplained - non DT
The patchset includes sama5d2.c which is not used today. I have a sama5d27-som1-ek board that I hope to find time to work with and then this will be needed.
Patch 4-8 add drivers but do not wire then into the build. This was done to somehow ease review of the final patch. Patches are rather big but trying to split them up more than already done seems not worth it.
Patch was made on top of:12cd92023788fdc67ad72c6e7d96251a6234ca3e ("Merge branch 'for-next/rpi' into next")
On stray patch sneaked in - to kill a warning.
The patchset triggers some checkpatch warnings:
- SPDX, the barebox variant of checkpatch is missing support for these (anyone?)
- Too long lines. As code is copied from the kernel I left them as-is
Comments/testing very welcome!
v2:
- Split up in smaller patches
- Fix builds in various configs
- Reworked Kconfig changes
- Fix checkpatch warnings (mostly whitespace)
v1:
- Posted to mailing list as a WIP patch
Sam
Sam Ravnborg (9):
clocksource: Do not mix depends and select for ATMEL_PIT
arm: at91: fix at91_configure_usart6 warning
arm: at91: add SOC_SAMA5{D3,D4}
clk: at91: add at91sam9260
clk: at91: add at91sam9rl
clk: at91: add at91sam9x5
clk: at91: add sama5d2
clk: at91: add sama5d4
clk: at91: update to new bindingsarch/arm/mach-at91/Kconfig | 31 +- arch/arm/mach-at91/include/mach/board.h | 1 + drivers/clk/at91/Makefile | 5 + drivers/clk/at91/at91sam9260.c | 497 ++++++++++++++++++++++++++++++++ drivers/clk/at91/at91sam9rl.c | 177 ++++++++++++ drivers/clk/at91/at91sam9x5.c | 315 ++++++++++++++++++++ drivers/clk/at91/clk-generated.c | 185 ++---------- drivers/clk/at91/clk-h32mx.c | 21 +- drivers/clk/at91/clk-main.c | 112 +------ drivers/clk/at91/clk-master.c | 94 +----- drivers/clk/at91/clk-peripheral.c | 82 +----- drivers/clk/at91/clk-pll.c | 174 +---------- drivers/clk/at91/clk-plldiv.c | 27 +- drivers/clk/at91/clk-programmable.c | 83 +----- drivers/clk/at91/clk-slow.c | 33 +-- drivers/clk/at91/clk-smd.c | 33 +-- drivers/clk/at91/clk-system.c | 42 +-- drivers/clk/at91/clk-usb.c | 94 +----- drivers/clk/at91/clk-utmi.c | 100 ++++--- drivers/clk/at91/pmc.c | 248 ++++++++++++++++ drivers/clk/at91/pmc.h | 169 +++++++++++ drivers/clk/at91/sama5d2.c | 342 ++++++++++++++++++++++ drivers/clk/at91/sama5d4.c | 270 +++++++++++++++++ drivers/clocksource/Kconfig | 1 - include/linux/clk.h | 7 + include/soc/at91/atmel-sfr.h | 34 +++ 26 files changed, 2216 insertions(+), 961 deletions(-)
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/9 clocksource: Do not mix depends and select for ATMEL_PIT
CLOCKSOURCE_ATMEL_PIT was both set to yes using depends on and using select.
Use only select to set this non-visible symbol to 'y'
--- drivers/clocksource/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/clocksource/Kconfig +0 -1
@@ -69,7 +69,6 @@ config CLOCKSOURCE_ROCKCHIP config CLOCKSOURCE_ATMEL_PIT bool - depends on SOC_AT91SAM9 || SOC_SAMA5 config CLOCKSOURCE_ARMV8_TIMER bool
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/9 arm: at91: fix at91_configure_usart6 warning
In reply to Sam RavnborgAdd declaration to silence following warning:
arch/arm/mach-at91/sama5d4_devices.c:487:24:
warning: no previous prototype for ‘at91_configure_usart6’
--- arch/arm/mach-at91/include/mach/board.h | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-at91/include/mach/board.h +1 -0
@@ -102,6 +102,7 @@ resource_size_t __init at91_configure_usart2(unsigned pins);resource_size_t __init at91_configure_usart3 (unsigned pins);resource_size_t __init at91_configure_usart4 (unsigned pins);resource_size_t __init at91_configure_usart5 (unsigned pins); +resource_size_t __init at91_configure_usart6 (unsigned pins);#if defined(CONFIG_DRIVER_SERIAL_ATMEL )static inline struct device_d *at91_register_uart (unsigned id,unsigned pins)
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/9 arm: at91: add SOC_SAMA5{D3,D4}
In reply to Sam RavnborgThis split allows us to distingush between the two SOC types.
The SOC_SAMA5D3 and SOC_SAMA5D4 symbols will be used in following patches.
--- arch/arm/mach-at91/Kconfig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arm/mach-at91/Kconfig +12 -2
@@ -57,6 +57,16 @@ config SOC_AT91SAM9 config SOC_SAMA5 bool select CPU_V7 + +config SOC_SAMA5D3 + bool + select SOC_SAMA5 + select AT91SAM9_SMC + select CLOCKSOURCE_ATMEL_PIT + +config SOC_SAMA5D4 + bool + select SOC_SAMA5 select AT91SAM9_SMC select CLOCKSOURCE_ATMEL_PIT
@@ -188,14 +198,14 @@ config ARCH_AT91SAM9N12 config ARCH_SAMA5D3 bool "SAMA5D3x" - select SOC_SAMA5 + select SOC_SAMA5D3 select HAVE_AT91_DBGU1 select HAS_MACB select HAVE_MACH_ARM_HEAD config ARCH_SAMA5D4 bool "SAMA5D4" - select SOC_SAMA5 + select SOC_SAMA5D4 select HAVE_AT91_DBGU2 select HAS_MACB select HAVE_MACH_ARM_HEAD
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/9 clk: at91: add at91sam9260
In reply to Sam RavnborgAdd at91sam9260 as part of supporting the PMC bindings for ARM at91. The file will be wired into the build in a follow-up patch.
The file is a copy from kernel 5.0-rc6 modified to build with barebox.
--- drivers/clk/at91/at91sam9260.c | 497 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 497 insertions(+) create mode 100644 drivers/clk/at91/at91sam9260.c
drivers/clk/at91/at91sam9260.c new file +497 -0
@@ -0,0 +1,497 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <driver.h> +#include <regmap.h> +#include <stdio.h> +#include <mfd/syscon.h> + +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/types.h> + +#include <dt-bindings/clock/at91.h> + +#include "pmc.h" + +struct sck { +char *n; +char *p; +u8 id; +}; + +struct pck { +char *n; +u8 id; +}; + +struct at91sam926x_data { +const struct clk_pll_layout *plla_layout; +const struct clk_pll_characteristics *plla_characteristics; +const struct clk_pll_layout *pllb_layout; +const struct clk_pll_characteristics *pllb_characteristics; +const struct clk_master_characteristics *mck_characteristics; +const struct sck *sck; +const struct pck *pck; +u8 num_sck; +u8 num_pck; +u8 num_progck; +bool has_slck; +}; + +static const struct clk_master_characteristics sam9260_mck_characteristics = { + .output = { .min =0 , .max =105000000 }, + .divisors = {1 ,2 ,4 ,0 }, +}; + +static u8 sam9260_plla_out[] = {0 ,2 }; + +static u16 sam9260_plla_icpll[] = {1 ,1 }; + +static struct clk_range sam9260_plla_outputs[] = { + { .min =80000000 , .max =160000000 }, + { .min =150000000 , .max =240000000 }, +}; + +static const struct clk_pll_characteristics sam9260_plla_characteristics = { + .input = { .min =1000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9260_plla_outputs), + .output = sam9260_plla_outputs, + .icpll = sam9260_plla_icpll, + .out = sam9260_plla_out, +}; + +static u8 sam9260_pllb_out[] = {1 }; + +static u16 sam9260_pllb_icpll[] = {1 }; + +static struct clk_range sam9260_pllb_outputs[] = { + { .min =70000000 , .max =130000000 }, +}; + +static const struct clk_pll_characteristics sam9260_pllb_characteristics = { + .input = { .min =1000000 , .max =5000000 }, + .num_output =ARRAY_SIZE (sam9260_pllb_outputs), + .output = sam9260_pllb_outputs, + .icpll = sam9260_pllb_icpll, + .out = sam9260_pllb_out, +}; + +static const struct sck at91sam9260_systemck[] = { + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, +}; + +static const struct pck at91sam9260_periphck[] = { + { .n ="pioA_clk" , .id =2 }, + { .n ="pioB_clk" , .id =3 }, + { .n ="pioC_clk" , .id =4 }, + { .n ="adc_clk" , .id =5 }, + { .n ="usart0_clk" , .id =6 }, + { .n ="usart1_clk" , .id =7 }, + { .n ="usart2_clk" , .id =8 }, + { .n ="mci0_clk" , .id =9 }, + { .n ="udc_clk" , .id =10 }, + { .n ="twi0_clk" , .id =11 }, + { .n ="spi0_clk" , .id =12 }, + { .n ="spi1_clk" , .id =13 }, + { .n ="ssc0_clk" , .id =14 }, + { .n ="tc0_clk" , .id =17 }, + { .n ="tc1_clk" , .id =18 }, + { .n ="tc2_clk" , .id =19 }, + { .n ="ohci_clk" , .id =20 }, + { .n ="macb0_clk" , .id =21 }, + { .n ="isi_clk" , .id =22 }, + { .n ="usart3_clk" , .id =23 }, + { .n ="uart0_clk" , .id =24 }, + { .n ="uart1_clk" , .id =25 }, + { .n ="tc3_clk" , .id =26 }, + { .n ="tc4_clk" , .id =27 }, + { .n ="tc5_clk" , .id =28 }, +}; + +static struct at91sam926x_data at91sam9260_data = { + .plla_layout = &at91rm9200_pll_layout, + .plla_characteristics = &sam9260_plla_characteristics, + .pllb_layout = &at91rm9200_pll_layout, + .pllb_characteristics = &sam9260_pllb_characteristics, + .mck_characteristics = &sam9260_mck_characteristics, + .sck = at91sam9260_systemck, + .num_sck =ARRAY_SIZE (at91sam9260_systemck), + .pck = at91sam9260_periphck, + .num_pck =ARRAY_SIZE (at91sam9260_periphck), + .num_progck =2 , + .has_slck = true, +}; + +static const struct clk_master_characteristics sam9g20_mck_characteristics = { + .output = { .min =0 , .max =133000000 }, + .divisors = {1 ,2 ,4 ,6 }, +}; + +static u8 sam9g20_plla_out[] = {0 ,1 ,2 ,3 ,0 ,1 ,2 ,3 }; + +static u16 sam9g20_plla_icpll[] = {0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 }; + +static struct clk_range sam9g20_plla_outputs[] = { + { .min =745000000 , .max =800000000 }, + { .min =695000000 , .max =750000000 }, + { .min =645000000 , .max =700000000 }, + { .min =595000000 , .max =650000000 }, + { .min =545000000 , .max =600000000 }, + { .min =495000000 , .max =550000000 }, + { .min =445000000 , .max =500000000 }, + { .min =400000000 , .max =450000000 }, +}; + +static const struct clk_pll_characteristics sam9g20_plla_characteristics = { + .input = { .min =2000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9g20_plla_outputs), + .output = sam9g20_plla_outputs, + .icpll = sam9g20_plla_icpll, + .out = sam9g20_plla_out, +}; + +static u8 sam9g20_pllb_out[] = {0 }; + +static u16 sam9g20_pllb_icpll[] = {0 }; + +static struct clk_range sam9g20_pllb_outputs[] = { + { .min =30000000 , .max =100000000 }, +}; + +static const struct clk_pll_characteristics sam9g20_pllb_characteristics = { + .input = { .min =2000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9g20_pllb_outputs), + .output = sam9g20_pllb_outputs, + .icpll = sam9g20_pllb_icpll, + .out = sam9g20_pllb_out, +}; + +static struct at91sam926x_data at91sam9g20_data = { + .plla_layout = &at91sam9g45_pll_layout, + .plla_characteristics = &sam9g20_plla_characteristics, + .pllb_layout = &at91sam9g20_pllb_layout, + .pllb_characteristics = &sam9g20_pllb_characteristics, + .mck_characteristics = &sam9g20_mck_characteristics, + .sck = at91sam9260_systemck, + .num_sck =ARRAY_SIZE (at91sam9260_systemck), + .pck = at91sam9260_periphck, + .num_pck =ARRAY_SIZE (at91sam9260_periphck), + .num_progck =2 , + .has_slck = true, +}; + +static const struct clk_master_characteristics sam9261_mck_characteristics = { + .output = { .min =0 , .max =94000000 }, + .divisors = {1 ,2 ,4 ,0 }, +}; + +static struct clk_range sam9261_plla_outputs[] = { + { .min =80000000 , .max =200000000 }, + { .min =190000000 , .max =240000000 }, +}; + +static const struct clk_pll_characteristics sam9261_plla_characteristics = { + .input = { .min =1000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9261_plla_outputs), + .output = sam9261_plla_outputs, + .icpll = sam9260_plla_icpll, + .out = sam9260_plla_out, +}; + +static u8 sam9261_pllb_out[] = {1 }; + +static u16 sam9261_pllb_icpll[] = {1 }; + +static struct clk_range sam9261_pllb_outputs[] = { + { .min =70000000 , .max =130000000 }, +}; + +static const struct clk_pll_characteristics sam9261_pllb_characteristics = { + .input = { .min =1000000 , .max =5000000 }, + .num_output =ARRAY_SIZE (sam9261_pllb_outputs), + .output = sam9261_pllb_outputs, + .icpll = sam9261_pllb_icpll, + .out = sam9261_pllb_out, +}; + +static const struct sck at91sam9261_systemck[] = { + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, + { .n ="pck2" , .p ="prog2" , .id =10 }, + { .n ="pck3" , .p ="prog3" , .id =11 }, + { .n ="hclk0" , .p ="masterck" , .id =16 }, + { .n ="hclk1" , .p ="masterck" , .id =17 }, +}; + +static const struct pck at91sam9261_periphck[] = { + { .n ="pioA_clk" , .id =2 , }, + { .n ="pioB_clk" , .id =3 , }, + { .n ="pioC_clk" , .id =4 , }, + { .n ="usart0_clk" , .id =6 , }, + { .n ="usart1_clk" , .id =7 , }, + { .n ="usart2_clk" , .id =8 , }, + { .n ="mci0_clk" , .id =9 , }, + { .n ="udc_clk" , .id =10 , }, + { .n ="twi0_clk" , .id =11 , }, + { .n ="spi0_clk" , .id =12 , }, + { .n ="spi1_clk" , .id =13 , }, + { .n ="ssc0_clk" , .id =14 , }, + { .n ="ssc1_clk" , .id =15 , }, + { .n ="ssc2_clk" , .id =16 , }, + { .n ="tc0_clk" , .id =17 , }, + { .n ="tc1_clk" , .id =18 , }, + { .n ="tc2_clk" , .id =19 , }, + { .n ="ohci_clk" , .id =20 , }, + { .n ="lcd_clk" , .id =21 , }, +}; + +static struct at91sam926x_data at91sam9261_data = { + .plla_layout = &at91rm9200_pll_layout, + .plla_characteristics = &sam9261_plla_characteristics, + .pllb_layout = &at91rm9200_pll_layout, + .pllb_characteristics = &sam9261_pllb_characteristics, + .mck_characteristics = &sam9261_mck_characteristics, + .sck = at91sam9261_systemck, + .num_sck =ARRAY_SIZE (at91sam9261_systemck), + .pck = at91sam9261_periphck, + .num_pck =ARRAY_SIZE (at91sam9261_periphck), + .num_progck =4 , +}; + +static const struct clk_master_characteristics sam9263_mck_characteristics = { + .output = { .min =0 , .max =120000000 }, + .divisors = {1 ,2 ,4 ,0 }, +}; + +static struct clk_range sam9263_pll_outputs[] = { + { .min =80000000 , .max =200000000 }, + { .min =190000000 , .max =240000000 }, +}; + +static const struct clk_pll_characteristics sam9263_pll_characteristics = { + .input = { .min =1000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9263_pll_outputs), + .output = sam9263_pll_outputs, + .icpll = sam9260_plla_icpll, + .out = sam9260_plla_out, +}; + +static const struct sck at91sam9263_systemck[] = { + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, + { .n ="pck2" , .p ="prog2" , .id =10 }, + { .n ="pck3" , .p ="prog3" , .id =11 }, +}; + +static const struct pck at91sam9263_periphck[] = { + { .n ="pioA_clk" , .id =2 , }, + { .n ="pioB_clk" , .id =3 , }, + { .n ="pioCDE_clk" , .id =4 , }, + { .n ="usart0_clk" , .id =7 , }, + { .n ="usart1_clk" , .id =8 , }, + { .n ="usart2_clk" , .id =9 , }, + { .n ="mci0_clk" , .id =10 , }, + { .n ="mci1_clk" , .id =11 , }, + { .n ="can_clk" , .id =12 , }, + { .n ="twi0_clk" , .id =13 , }, + { .n ="spi0_clk" , .id =14 , }, + { .n ="spi1_clk" , .id =15 , }, + { .n ="ssc0_clk" , .id =16 , }, + { .n ="ssc1_clk" , .id =17 , }, + { .n ="ac97_clk" , .id =18 , }, + { .n ="tcb_clk" , .id =19 , }, + { .n ="pwm_clk" , .id =20 , }, + { .n ="macb0_clk" , .id =21 , }, + { .n ="g2de_clk" , .id =23 , }, + { .n ="udc_clk" , .id =24 , }, + { .n ="isi_clk" , .id =25 , }, + { .n ="lcd_clk" , .id =26 , }, + { .n ="dma_clk" , .id =27 , }, + { .n ="ohci_clk" , .id =29 , }, +}; + +static struct at91sam926x_data at91sam9263_data = { + .plla_layout = &at91rm9200_pll_layout, + .plla_characteristics = &sam9263_pll_characteristics, + .pllb_layout = &at91rm9200_pll_layout, + .pllb_characteristics = &sam9263_pll_characteristics, + .mck_characteristics = &sam9263_mck_characteristics, + .sck = at91sam9263_systemck, + .num_sck =ARRAY_SIZE (at91sam9263_systemck), + .pck = at91sam9263_periphck, + .num_pck =ARRAY_SIZE (at91sam9263_periphck), + .num_progck =4 , +}; + +static void __init at91sam926x_pmc_setup (struct device_node *np, +struct at91sam926x_data *data) +{ +const char *slowxtal_name, *mainxtal_name; +struct pmc_data *at91sam9260_pmc; +u32 usb_div[] = {1 ,2 ,4 ,0 }; +const char *parent_names[6 ]; +const char *slck_name; +struct regmap *regmap; +struct clk *hw; +int i; +bool bypass; + + i =of_property_match_string (np,"clock-names" ,"slow_xtal" ); +if (i <0 ) +return ; + + slowxtal_name =of_clk_get_parent_name (np, i); + + i =of_property_match_string (np,"clock-names" ,"main_xtal" ); +if (i <0 ) +return ; + mainxtal_name =of_clk_get_parent_name (np, i); + + regmap =syscon_node_to_regmap (np); +if (IS_ERR (regmap)) +return ; + + at91sam9260_pmc =pmc_data_allocate (PMC_MAIN +1 , +ndck (data->sck, data->num_sck), +ndck (data->pck, data->num_pck),0 ); +if (!at91sam9260_pmc) +return ; + + bypass =of_property_read_bool (np,"atmel,osc-bypass" ); + + hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name, + bypass); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_rm9200_main (regmap,"mainck" ,"main_osc" ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9260_pmc->chws[PMC_MAIN ] = hw; + +if (data->has_slck) { + hw =clk_fixed ("slow_rc_osc" ,32768 ); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] ="slow_rc_osc" ; + parent_names[1 ] ="slow_xtal" ; + hw =at91_clk_register_sam9260_slow (regmap,"slck" , + parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9260_pmc->chws[PMC_SLOW ] = hw; + slck_name ="slck" ; + }else { + slck_name = slowxtal_name; + } + + hw =at91_clk_register_pll (regmap,"pllack" ,"mainck" ,0 , + data->plla_layout, + data->plla_characteristics); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_pll (regmap,"pllbck" ,"mainck" ,1 , + data->pllb_layout, + data->pllb_characteristics); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="pllack" ; + parent_names[3 ] ="pllbck" ; + hw =at91_clk_register_master (regmap,"masterck" ,4 , parent_names, + &at91rm9200_master_layout, + data->mck_characteristics); +if (IS_ERR (hw)) + goto err_free; + + at91sam9260_pmc->chws[PMC_MCK ] = hw; + + hw =at91rm9200_clk_register_usb (regmap,"usbck" ,"pllbck" , usb_div); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="pllack" ; + parent_names[3 ] ="pllbck" ; +for (i =0 ; i < data->num_progck; i++) { +char *name; + + name =xasprintf ("prog%d" , i); + + hw =at91_clk_register_programmable (regmap, name, + parent_names,4 , i, + &at91rm9200_programmable_layout); +if (IS_ERR (hw)) + goto err_free; + } + +for (i =0 ; i < data->num_sck; i++) { + hw =at91_clk_register_system (regmap, data->sck[i].n, + data->sck[i].p, + data->sck[i].id); +if (IS_ERR (hw)) + goto err_free; + + at91sam9260_pmc->shws[data->sck[i].id] = hw; + } + +for (i =0 ; i < data->num_pck; i++) { + hw =at91_clk_register_peripheral (regmap, + data->pck[i].n, +"masterck" , + data->pck[i].id); +if (IS_ERR (hw)) + goto err_free; + + at91sam9260_pmc->phws[data->pck[i].id] = hw; + } + +of_clk_add_provider (np, of_clk_hw_pmc_get, at91sam9260_pmc); + +return ; + +err_free: +pmc_data_free (at91sam9260_pmc); +} + +static void __init at91sam9260_pmc_setup (struct device_node *np) +{ +at91sam926x_pmc_setup (np, &at91sam9260_data); +} +CLK_OF_DECLARE_DRIVER (at91sam9260_pmc,"atmel,at91sam9260-pmc" , + at91sam9260_pmc_setup); + +static void __init at91sam9261_pmc_setup (struct device_node *np) +{ +at91sam926x_pmc_setup (np, &at91sam9261_data); +} +CLK_OF_DECLARE_DRIVER (at91sam9261_pmc,"atmel,at91sam9261-pmc" , + at91sam9261_pmc_setup); + +static void __init at91sam9263_pmc_setup (struct device_node *np) +{ +at91sam926x_pmc_setup (np, &at91sam9263_data); +} +CLK_OF_DECLARE_DRIVER (at91sam9263_pmc,"atmel,at91sam9263-pmc" , + at91sam9263_pmc_setup); + +static void __init at91sam9g20_pmc_setup (struct device_node *np) +{ +at91sam926x_pmc_setup (np, &at91sam9g20_data); +} +CLK_OF_DECLARE_DRIVER (at91sam9g20_pmc,"atmel,at91sam9g20-pmc" , + at91sam9g20_pmc_setup);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 5/9 clk: at91: add at91sam9rl
In reply to Sam RavnborgAdd at91sam9rl as part of supporting the PMC bindings for ARM at91. The file will be wired into the build in a follow-up patch.
The file is a copy from kernel 5.0-rc6 modified to build with barebox.
--- drivers/clk/at91/at91sam9rl.c | 177 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 drivers/clk/at91/at91sam9rl.c
drivers/clk/at91/at91sam9rl.c new file +177 -0
@@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <driver.h> +#include <regmap.h> +#include <stdio.h> +#include <mfd/syscon.h> + +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/types.h> + +#include <dt-bindings/clock/at91.h> + +#include "pmc.h" + +static const struct clk_master_characteristics sam9rl_mck_characteristics = { + .output = { .min =0 , .max =94000000 }, + .divisors = {1 ,2 ,4 ,0 }, +}; + +static u8 sam9rl_plla_out[] = {0 ,2 }; + +static struct clk_range sam9rl_plla_outputs[] = { + { .min =80000000 , .max =200000000 }, + { .min =190000000 , .max =240000000 }, +}; + +static const struct clk_pll_characteristics sam9rl_plla_characteristics = { + .input = { .min =1000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (sam9rl_plla_outputs), + .output = sam9rl_plla_outputs, + .out = sam9rl_plla_out, +}; + +static const struct { +char *n; +char *p; +u8 id; +} at91sam9rl_systemck[] = { + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, +}; + +static const struct { +char *n; +u8 id; +} at91sam9rl_periphck[] = { + { .n ="pioA_clk" , .id =2 , }, + { .n ="pioB_clk" , .id =3 , }, + { .n ="pioC_clk" , .id =4 , }, + { .n ="pioD_clk" , .id =5 , }, + { .n ="usart0_clk" , .id =6 , }, + { .n ="usart1_clk" , .id =7 , }, + { .n ="usart2_clk" , .id =8 , }, + { .n ="usart3_clk" , .id =9 , }, + { .n ="mci0_clk" , .id =10 , }, + { .n ="twi0_clk" , .id =11 , }, + { .n ="twi1_clk" , .id =12 , }, + { .n ="spi0_clk" , .id =13 , }, + { .n ="ssc0_clk" , .id =14 , }, + { .n ="ssc1_clk" , .id =15 , }, + { .n ="tc0_clk" , .id =16 , }, + { .n ="tc1_clk" , .id =17 , }, + { .n ="tc2_clk" , .id =18 , }, + { .n ="pwm_clk" , .id =19 , }, + { .n ="adc_clk" , .id =20 , }, + { .n ="dma0_clk" , .id =21 , }, + { .n ="udphs_clk" , .id =22 , }, + { .n ="lcd_clk" , .id =23 , }, +}; + +static void __init at91sam9rl_pmc_setup (struct device_node *np) +{ +const char *slck_name, *mainxtal_name; +struct pmc_data *at91sam9rl_pmc; +const char *parent_names[6 ]; +struct regmap *regmap; +struct clk *hw; +int i; + + i =of_property_match_string (np,"clock-names" ,"slow_clk" ); +if (i <0 ) +return ; + + slck_name =of_clk_get_parent_name (np, i); + + i =of_property_match_string (np,"clock-names" ,"main_xtal" ); +if (i <0 ) +return ; + mainxtal_name =of_clk_get_parent_name (np, i); + + regmap =syscon_node_to_regmap (np); +if (IS_ERR (regmap)) +return ; + + at91sam9rl_pmc =pmc_data_allocate (PMC_MAIN +1 , +nck (at91sam9rl_systemck), +nck (at91sam9rl_periphck),0 ); +if (!at91sam9rl_pmc) +return ; + + hw =at91_clk_register_rm9200_main (regmap,"mainck" , mainxtal_name); +if (IS_ERR (hw)) + goto err_free; + + at91sam9rl_pmc->chws[PMC_MAIN ] = hw; + + hw =at91_clk_register_pll (regmap,"pllack" ,"mainck" ,0 , + &at91rm9200_pll_layout, + &sam9rl_plla_characteristics); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9rl_pmc->chws[PMC_UTMI ] = hw; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="pllack" ; + parent_names[3 ] ="utmick" ; + hw =at91_clk_register_master (regmap,"masterck" ,4 , parent_names, + &at91rm9200_master_layout, + &sam9rl_mck_characteristics); +if (IS_ERR (hw)) + goto err_free; + + at91sam9rl_pmc->chws[PMC_MCK ] = hw; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="pllack" ; + parent_names[3 ] ="utmick" ; + parent_names[4 ] ="masterck" ; +for (i =0 ; i <2 ; i++) { +char *name; + + name =xasprintf ("prog%d" , i); + + hw =at91_clk_register_programmable (regmap, name, + parent_names,5 , i, + &at91rm9200_programmable_layout); +if (IS_ERR (hw)) + goto err_free; + } + +for (i =0 ; i <ARRAY_SIZE (at91sam9rl_systemck); i++) { + hw =at91_clk_register_system (regmap, at91sam9rl_systemck[i].n, + at91sam9rl_systemck[i].p, + at91sam9rl_systemck[i].id); +if (IS_ERR (hw)) + goto err_free; + + at91sam9rl_pmc->shws[at91sam9rl_systemck[i].id] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (at91sam9rl_periphck); i++) { + hw =at91_clk_register_peripheral (regmap, + at91sam9rl_periphck[i].n, +"masterck" , + at91sam9rl_periphck[i].id); +if (IS_ERR (hw)) + goto err_free; + + at91sam9rl_pmc->phws[at91sam9rl_periphck[i].id] = hw; + } + +of_clk_add_provider (np, of_clk_hw_pmc_get, at91sam9rl_pmc); + +return ; + +err_free: +pmc_data_free (at91sam9rl_pmc); +} +CLK_OF_DECLARE_DRIVER (at91sam9rl_pmc,"atmel,at91sam9rl-pmc" , at91sam9rl_pmc_setup);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 6/9 clk: at91: add at91sam9x5
In reply to Sam RavnborgAdd at91sam9x5 as part of supporting the PMC bindings for ARM at91. The file will be wired into the build in a follow-up patch.
The file is a copy from kernel 5.0-rc6 modified to build with barebox.
--- drivers/clk/at91/at91sam9x5.c | 315 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100644 drivers/clk/at91/at91sam9x5.c
drivers/clk/at91/at91sam9x5.c new file +315 -0
@@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <driver.h> +#include <regmap.h> +#include <stdio.h> +#include <mfd/syscon.h> + +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/types.h> + +#include <dt-bindings/clock/at91.h> + +#include "pmc.h" + +static const struct clk_master_characteristics mck_characteristics = { + .output = { .min =0 , .max =133333333 }, + .divisors = {1 ,2 ,4 ,3 }, + .have_div3_pres =1 , +}; + +static u8 plla_out[] = {0 ,1 ,2 ,3 ,0 ,1 ,2 ,3 }; + +static u16 plla_icpll[] = {0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 }; + +static struct clk_range plla_outputs[] = { + { .min =745000000 , .max =800000000 }, + { .min =695000000 , .max =750000000 }, + { .min =645000000 , .max =700000000 }, + { .min =595000000 , .max =650000000 }, + { .min =545000000 , .max =600000000 }, + { .min =495000000 , .max =555000000 }, + { .min =445000000 , .max =500000000 }, + { .min =400000000 , .max =450000000 }, +}; + +static const struct clk_pll_characteristics plla_characteristics = { + .input = { .min =2000000 , .max =32000000 }, + .num_output =ARRAY_SIZE (plla_outputs), + .output = plla_outputs, + .icpll = plla_icpll, + .out = plla_out, +}; + +static const struct { +char *n; +char *p; +u8 id; +} at91sam9x5_systemck[] = { + { .n ="ddrck" , .p ="masterck" , .id =2 }, + { .n ="smdck" , .p ="smdclk" , .id =4 }, + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, +}; + +struct pck { +char *n; +u8 id; +}; + +static const struct pck at91sam9x5_periphck[] = { + { .n ="pioAB_clk" , .id =2 , }, + { .n ="pioCD_clk" , .id =3 , }, + { .n ="smd_clk" , .id =4 , }, + { .n ="usart0_clk" , .id =5 , }, + { .n ="usart1_clk" , .id =6 , }, + { .n ="usart2_clk" , .id =7 , }, + { .n ="twi0_clk" , .id =9 , }, + { .n ="twi1_clk" , .id =10 , }, + { .n ="twi2_clk" , .id =11 , }, + { .n ="mci0_clk" , .id =12 , }, + { .n ="spi0_clk" , .id =13 , }, + { .n ="spi1_clk" , .id =14 , }, + { .n ="uart0_clk" , .id =15 , }, + { .n ="uart1_clk" , .id =16 , }, + { .n ="tcb0_clk" , .id =17 , }, + { .n ="pwm_clk" , .id =18 , }, + { .n ="adc_clk" , .id =19 , }, + { .n ="dma0_clk" , .id =20 , }, + { .n ="dma1_clk" , .id =21 , }, + { .n ="uhphs_clk" , .id =22 , }, + { .n ="udphs_clk" , .id =23 , }, + { .n ="mci1_clk" , .id =26 , }, + { .n ="ssc0_clk" , .id =28 , }, +}; + +static const struct pck at91sam9g15_periphck[] = { + { .n ="lcdc_clk" , .id =25 , }, + {/* sentinel */ } +}; + +static const struct pck at91sam9g25_periphck[] = { + { .n ="usart3_clk" , .id =8 , }, + { .n ="macb0_clk" , .id =24 , }, + { .n ="isi_clk" , .id =25 , }, + {/* sentinel */ } +}; + +static const struct pck at91sam9g35_periphck[] = { + { .n ="macb0_clk" , .id =24 , }, + { .n ="lcdc_clk" , .id =25 , }, + {/* sentinel */ } +}; + +static const struct pck at91sam9x25_periphck[] = { + { .n ="usart3_clk" , .id =8 , }, + { .n ="macb0_clk" , .id =24 , }, + { .n ="macb1_clk" , .id =27 , }, + { .n ="can0_clk" , .id =29 , }, + { .n ="can1_clk" , .id =30 , }, + {/* sentinel */ } +}; + +static const struct pck at91sam9x35_periphck[] = { + { .n ="macb0_clk" , .id =24 , }, + { .n ="lcdc_clk" , .id =25 , }, + { .n ="can0_clk" , .id =29 , }, + { .n ="can1_clk" , .id =30 , }, + {/* sentinel */ } +}; + +static void __init at91sam9x5_pmc_setup (struct device_node *np, +const struct pck *extra_pcks, +bool has_lcdck) +{ +struct clk_range range =CLK_RANGE (0 ,0 ); +const char *slck_name, *mainxtal_name; +struct pmc_data *at91sam9x5_pmc; +const char *parent_names[6 ]; +struct regmap *regmap; +struct clk *hw; +int i; +bool bypass; + + i =of_property_match_string (np,"clock-names" ,"slow_clk" ); +if (i <0 ) +return ; + + slck_name =of_clk_get_parent_name (np, i); + + i =of_property_match_string (np,"clock-names" ,"main_xtal" ); +if (i <0 ) +return ; + mainxtal_name =of_clk_get_parent_name (np, i); + + regmap =syscon_node_to_regmap (np); +if (IS_ERR (regmap)) +return ; + + at91sam9x5_pmc =pmc_data_allocate (PMC_MAIN +1 , +nck (at91sam9x5_systemck), +nck (at91sam9x35_periphck),0 ); +if (!at91sam9x5_pmc) +return ; + + hw =at91_clk_register_main_rc_osc (regmap,"main_rc_osc" ,12000000 , +50000000 ); +if (IS_ERR (hw)) + goto err_free; + + bypass =of_property_read_bool (np,"atmel,osc-bypass" ); + + hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name, + bypass); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] ="main_rc_osc" ; + parent_names[1 ] ="main_osc" ; + hw =at91_clk_register_sam9x5_main (regmap,"mainck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->chws[PMC_MAIN ] = hw; + + hw =at91_clk_register_pll (regmap,"pllack" ,"mainck" ,0 , + &at91rm9200_pll_layout, &plla_characteristics); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_plldiv (regmap,"plladivck" ,"pllack" ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->chws[PMC_UTMI ] = hw; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + hw =at91_clk_register_master (regmap,"masterck" ,4 , parent_names, + &at91sam9x5_master_layout, + &mck_characteristics); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->chws[PMC_MCK ] = hw; + + parent_names[0 ] ="plladivck" ; + parent_names[1 ] ="utmick" ; + hw =at91sam9x5_clk_register_usb (regmap,"usbck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91sam9x5_clk_register_smd (regmap,"smdclk" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + parent_names[4 ] ="mck" ; +for (i =0 ; i <2 ; i++) { +char *name; + + name =xasprintf ("prog%d" , i); + + hw =at91_clk_register_programmable (regmap, name, + parent_names,5 , i, + &at91sam9x5_programmable_layout); +if (IS_ERR (hw)) + goto err_free; + } + +for (i =0 ; i <ARRAY_SIZE (at91sam9x5_systemck); i++) { + hw =at91_clk_register_system (regmap, at91sam9x5_systemck[i].n, + at91sam9x5_systemck[i].p, + at91sam9x5_systemck[i].id); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->shws[at91sam9x5_systemck[i].id] = hw; + } + +if (has_lcdck) { + hw =at91_clk_register_system (regmap,"lcdck" ,"masterck" ,3 ); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->shws[3 ] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (at91sam9x5_periphck); i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, + at91sam9x5_periphck[i].n, +"masterck" , + at91sam9x5_periphck[i].id, + &range); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->phws[at91sam9x5_periphck[i].id] = hw; + } + +for (i =0 ; extra_pcks[i].id; i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, + extra_pcks[i].n, +"masterck" , + extra_pcks[i].id, + &range); +if (IS_ERR (hw)) + goto err_free; + + at91sam9x5_pmc->phws[extra_pcks[i].id] = hw; + } + +of_clk_add_provider (np, of_clk_hw_pmc_get, at91sam9x5_pmc); + +return ; + +err_free: +pmc_data_free (at91sam9x5_pmc); +} + +static void __init at91sam9g15_pmc_setup (struct device_node *np) +{ +at91sam9x5_pmc_setup (np, at91sam9g15_periphck, true); +} +CLK_OF_DECLARE_DRIVER (at91sam9g15_pmc,"atmel,at91sam9g15-pmc" , + at91sam9g15_pmc_setup); + +static void __init at91sam9g25_pmc_setup (struct device_node *np) +{ +at91sam9x5_pmc_setup (np, at91sam9g25_periphck, false); +} +CLK_OF_DECLARE_DRIVER (at91sam9g25_pmc,"atmel,at91sam9g25-pmc" , + at91sam9g25_pmc_setup); + +static void __init at91sam9g35_pmc_setup (struct device_node *np) +{ +at91sam9x5_pmc_setup (np, at91sam9g35_periphck, true); +} +CLK_OF_DECLARE_DRIVER (at91sam9g35_pmc,"atmel,at91sam9g35-pmc" , + at91sam9g35_pmc_setup); + +static void __init at91sam9x25_pmc_setup (struct device_node *np) +{ +at91sam9x5_pmc_setup (np, at91sam9x25_periphck, false); +} +CLK_OF_DECLARE_DRIVER (at91sam9x25_pmc,"atmel,at91sam9x25-pmc" , + at91sam9x25_pmc_setup); + +static void __init at91sam9x35_pmc_setup (struct device_node *np) +{ +at91sam9x5_pmc_setup (np, at91sam9x35_periphck, true); +} +CLK_OF_DECLARE_DRIVER (at91sam9x35_pmc,"atmel,at91sam9x35-pmc" , + at91sam9x35_pmc_setup);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 7/9 clk: at91: add sama5d2
In reply to Sam RavnborgAdd sama5d2 as part of supporting the PMC bindings for ARM at91. The file will be wired into the build in a follow-up patch.
The file is a copy from kernel 5.0-rc6 modified to build with barebox.
--- drivers/clk/at91/sama5d2.c | 342 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 342 insertions(+) create mode 100644 drivers/clk/at91/sama5d2.c
drivers/clk/at91/sama5d2.c new file +342 -0
@@ -0,0 +1,342 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <driver.h> +#include <regmap.h> +#include <stdio.h> +#include <mfd/syscon.h> + +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/types.h> + +#include <dt-bindings/clock/at91.h> + +#include "pmc.h" + +static const struct clk_master_characteristics mck_characteristics = { + .output = { .min =124000000 , .max =166000000 }, + .divisors = {1 ,2 ,4 ,3 }, +}; + +static u8 plla_out[] = {0 }; + +static u16 plla_icpll[] = {0 }; + +static struct clk_range plla_outputs[] = { + { .min =600000000 , .max =1200000000 }, +}; + +static const struct clk_pll_characteristics plla_characteristics = { + .input = { .min =12000000 , .max =12000000 }, + .num_output =ARRAY_SIZE (plla_outputs), + .output = plla_outputs, + .icpll = plla_icpll, + .out = plla_out, +}; + +static const struct { +char *n; +char *p; +u8 id; +} sama5d2_systemck[] = { + { .n ="ddrck" , .p ="masterck" , .id =2 }, + { .n ="lcdck" , .p ="masterck" , .id =3 }, + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, + { .n ="pck2" , .p ="prog2" , .id =10 }, + { .n ="iscck" , .p ="masterck" , .id =18 }, +}; + +static const struct { +char *n; +u8 id; +struct clk_range r; +} sama5d2_periph32ck[] = { + { .n ="macb0_clk" , .id =5 , .r = { .min =0 , .max =83000000 }, }, + { .n ="tdes_clk" , .id =11 , .r = { .min =0 , .max =83000000 }, }, + { .n ="matrix1_clk" , .id =14 , }, + { .n ="hsmc_clk" , .id =17 , }, + { .n ="pioA_clk" , .id =18 , .r = { .min =0 , .max =83000000 }, }, + { .n ="flx0_clk" , .id =19 , .r = { .min =0 , .max =83000000 }, }, + { .n ="flx1_clk" , .id =20 , .r = { .min =0 , .max =83000000 }, }, + { .n ="flx2_clk" , .id =21 , .r = { .min =0 , .max =83000000 }, }, + { .n ="flx3_clk" , .id =22 , .r = { .min =0 , .max =83000000 }, }, + { .n ="flx4_clk" , .id =23 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uart0_clk" , .id =24 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uart1_clk" , .id =25 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uart2_clk" , .id =26 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uart3_clk" , .id =27 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uart4_clk" , .id =28 , .r = { .min =0 , .max =83000000 }, }, + { .n ="twi0_clk" , .id =29 , .r = { .min =0 , .max =83000000 }, }, + { .n ="twi1_clk" , .id =30 , .r = { .min =0 , .max =83000000 }, }, + { .n ="spi0_clk" , .id =33 , .r = { .min =0 , .max =83000000 }, }, + { .n ="spi1_clk" , .id =34 , .r = { .min =0 , .max =83000000 }, }, + { .n ="tcb0_clk" , .id =35 , .r = { .min =0 , .max =83000000 }, }, + { .n ="tcb1_clk" , .id =36 , .r = { .min =0 , .max =83000000 }, }, + { .n ="pwm_clk" , .id =38 , .r = { .min =0 , .max =83000000 }, }, + { .n ="adc_clk" , .id =40 , .r = { .min =0 , .max =83000000 }, }, + { .n ="uhphs_clk" , .id =41 , .r = { .min =0 , .max =83000000 }, }, + { .n ="udphs_clk" , .id =42 , .r = { .min =0 , .max =83000000 }, }, + { .n ="ssc0_clk" , .id =43 , .r = { .min =0 , .max =83000000 }, }, + { .n ="ssc1_clk" , .id =44 , .r = { .min =0 , .max =83000000 }, }, + { .n ="trng_clk" , .id =47 , .r = { .min =0 , .max =83000000 }, }, + { .n ="pdmic_clk" , .id =48 , .r = { .min =0 , .max =83000000 }, }, + { .n ="securam_clk" , .id =51 , }, + { .n ="i2s0_clk" , .id =54 , .r = { .min =0 , .max =83000000 }, }, + { .n ="i2s1_clk" , .id =55 , .r = { .min =0 , .max =83000000 }, }, + { .n ="can0_clk" , .id =56 , .r = { .min =0 , .max =83000000 }, }, + { .n ="can1_clk" , .id =57 , .r = { .min =0 , .max =83000000 }, }, + { .n ="classd_clk" , .id =59 , .r = { .min =0 , .max =83000000 }, }, +}; + +static const struct { +char *n; +u8 id; +} sama5d2_periphck[] = { + { .n ="dma0_clk" , .id =6 , }, + { .n ="dma1_clk" , .id =7 , }, + { .n ="aes_clk" , .id =9 , }, + { .n ="aesb_clk" , .id =10 , }, + { .n ="sha_clk" , .id =12 , }, + { .n ="mpddr_clk" , .id =13 , }, + { .n ="matrix0_clk" , .id =15 , }, + { .n ="sdmmc0_hclk" , .id =31 , }, + { .n ="sdmmc1_hclk" , .id =32 , }, + { .n ="lcdc_clk" , .id =45 , }, + { .n ="isc_clk" , .id =46 , }, + { .n ="qspi0_clk" , .id =52 , }, + { .n ="qspi1_clk" , .id =53 , }, +}; + +static const struct { +char *n; +u8 id; +struct clk_range r; +bool pll; +} sama5d2_gck[] = { + { .n ="sdmmc0_gclk" , .id =31 , }, + { .n ="sdmmc1_gclk" , .id =32 , }, + { .n ="tcb0_gclk" , .id =35 , .r = { .min =0 , .max =83000000 }, }, + { .n ="tcb1_gclk" , .id =36 , .r = { .min =0 , .max =83000000 }, }, + { .n ="pwm_gclk" , .id =38 , .r = { .min =0 , .max =83000000 }, }, + { .n ="isc_gclk" , .id =46 , }, + { .n ="pdmic_gclk" , .id =48 , }, + { .n ="i2s0_gclk" , .id =54 , .pll = true }, + { .n ="i2s1_gclk" , .id =55 , .pll = true }, + { .n ="can0_gclk" , .id =56 , .r = { .min =0 , .max =80000000 }, }, + { .n ="can1_gclk" , .id =57 , .r = { .min =0 , .max =80000000 }, }, + { .n ="classd_gclk" , .id =59 , .r = { .min =0 , .max =100000000 }, + .pll = true }, +}; + +static void __init sama5d2_pmc_setup (struct device_node *np) +{ +struct clk_range range =CLK_RANGE (0 ,0 ); +const char *slck_name, *mainxtal_name; +struct pmc_data *sama5d2_pmc; +const char *parent_names[6 ]; +struct regmap *regmap, *regmap_sfr; +struct clk *hw; +int i; +bool bypass; + + i =of_property_match_string (np,"clock-names" ,"slow_clk" ); +if (i <0 ) +return ; + + slck_name =of_clk_get_parent_name (np, i); + + i =of_property_match_string (np,"clock-names" ,"main_xtal" ); +if (i <0 ) +return ; + mainxtal_name =of_clk_get_parent_name (np, i); + + regmap =syscon_node_to_regmap (np); +if (IS_ERR (regmap)) +return ; + + sama5d2_pmc =pmc_data_allocate (PMC_I2S1_MUX +1 , +nck (sama5d2_systemck), +nck (sama5d2_periph32ck), +nck (sama5d2_gck)); +if (!sama5d2_pmc) +return ; + + hw =at91_clk_register_main_rc_osc (regmap,"main_rc_osc" ,12000000 , +100000000 ); +if (IS_ERR (hw)) + goto err_free; + + bypass =of_property_read_bool (np,"atmel,osc-bypass" ); + + hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name, + bypass); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] ="main_rc_osc" ; + parent_names[1 ] ="main_osc" ; + hw =at91_clk_register_sam9x5_main (regmap,"mainck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_MAIN ] = hw; + + hw =at91_clk_register_pll (regmap,"pllack" ,"mainck" ,0 , + &sama5d3_pll_layout, &plla_characteristics); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_plldiv (regmap,"plladivck" ,"pllack" ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_audio_pll_frac (regmap,"audiopll_fracck" , +"mainck" ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_audio_pll_pad (regmap,"audiopll_padck" , +"audiopll_fracck" ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_audio_pll_pmc (regmap,"audiopll_pmcck" , +"audiopll_fracck" ); +if (IS_ERR (hw)) + goto err_free; + + regmap_sfr =syscon_regmap_lookup_by_compatible ("atmel,sama5d2-sfr" ); +if (IS_ERR (regmap_sfr)) + regmap_sfr =NULL ; + + hw =at91_clk_register_utmi (regmap, regmap_sfr,"utmick" ,"mainck" ); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_UTMI ] = hw; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + hw =at91_clk_register_master (regmap,"masterck" ,4 , parent_names, + &at91sam9x5_master_layout, + &mck_characteristics); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_MCK ] = hw; + + hw =at91_clk_register_h32mx (regmap,"h32mxck" ,"masterck" ); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_MCK2 ] = hw; + + parent_names[0 ] ="plladivck" ; + parent_names[1 ] ="utmick" ; + hw =at91sam9x5_clk_register_usb (regmap,"usbck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + parent_names[4 ] ="mck" ; +for (i =0 ; i <3 ; i++) { +char *name; + + name =xasprintf ("prog%d" , i); + + hw =at91_clk_register_programmable (regmap, name, + parent_names,5 , i, + &at91sam9x5_programmable_layout); +if (IS_ERR (hw)) + goto err_free; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d2_systemck); i++) { + hw =at91_clk_register_system (regmap, sama5d2_systemck[i].n, + sama5d2_systemck[i].p, + sama5d2_systemck[i].id); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->shws[sama5d2_systemck[i].id] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d2_periphck); i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, &pmc_pcr_lock, + sama5d2_periphck[i].n, +"masterck" , + sama5d2_periphck[i].id, + &range); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->phws[sama5d2_periphck[i].id] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d2_periph32ck); i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, &pmc_pcr_lock, + sama5d2_periph32ck[i].n, +"h32mxck" , + sama5d2_periph32ck[i].id, + &sama5d2_periph32ck[i].r); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->phws[sama5d2_periph32ck[i].id] = hw; + } + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + parent_names[4 ] ="mck" ; + parent_names[5 ] ="audiopll_pmcck" ; +for (i =0 ; i <ARRAY_SIZE (sama5d2_gck); i++) { + hw =at91_clk_register_generated (regmap, &pmc_pcr_lock, + sama5d2_gck[i].n, + parent_names,6 , + sama5d2_gck[i].id, + sama5d2_gck[i].pll, + &sama5d2_gck[i].r); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->ghws[sama5d2_gck[i].id] = hw; + } + +if (regmap_sfr) { + parent_names[0 ] ="i2s0_clk" ; + parent_names[1 ] ="i2s0_gclk" ; + hw =at91_clk_i2s_mux_register (regmap_sfr,"i2s0_muxclk" , + parent_names,2 ,0 ); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_I2S0_MUX ] = hw; + + parent_names[0 ] ="i2s1_clk" ; + parent_names[1 ] ="i2s1_gclk" ; + hw =at91_clk_i2s_mux_register (regmap_sfr,"i2s1_muxclk" , + parent_names,2 ,1 ); +if (IS_ERR (hw)) + goto err_free; + + sama5d2_pmc->chws[PMC_I2S1_MUX ] = hw; + } + +of_clk_add_provider (np, of_clk_hw_pmc_get, sama5d2_pmc); + +return ; + +err_free: +pmc_data_free (sama5d2_pmc); +} +CLK_OF_DECLARE_DRIVER (sama5d2_pmc,"atmel,sama5d2-pmc" , sama5d2_pmc_setup);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 8/9 clk: at91: add sama5d4
In reply to Sam RavnborgAdd sama5d4 as part of supporting the PMC bindings for ARM at91. The file will be wired into the build in a follow-up patch.
The file is a copy from kernel 5.0-rc6 modified to build with barebox.
--- drivers/clk/at91/sama5d4.c | 270 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 drivers/clk/at91/sama5d4.c
drivers/clk/at91/sama5d4.c new file +270 -0
@@ -0,0 +1,270 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <driver.h> +#include <regmap.h> +#include <stdio.h> +#include <mfd/syscon.h> + +#include <linux/clk.h> +#include <linux/slab.h> +#include <linux/types.h> + +#include <dt-bindings/clock/at91.h> + +#include "pmc.h" + +static const struct clk_master_characteristics mck_characteristics = { + .output = { .min =125000000 , .max =200000000 }, + .divisors = {1 ,2 ,4 ,3 }, +}; + +static u8 plla_out[] = {0 }; + +static u16 plla_icpll[] = {0 }; + +static struct clk_range plla_outputs[] = { + { .min =600000000 , .max =1200000000 }, +}; + +static const struct clk_pll_characteristics plla_characteristics = { + .input = { .min =12000000 , .max =12000000 }, + .num_output =ARRAY_SIZE (plla_outputs), + .output = plla_outputs, + .icpll = plla_icpll, + .out = plla_out, +}; + +static const struct { +char *n; +char *p; +u8 id; +} sama5d4_systemck[] = { + { .n ="ddrck" , .p ="masterck" , .id =2 }, + { .n ="lcdck" , .p ="masterck" , .id =3 }, + { .n ="smdck" , .p ="smdclk" , .id =4 }, + { .n ="uhpck" , .p ="usbck" , .id =6 }, + { .n ="udpck" , .p ="usbck" , .id =7 }, + { .n ="pck0" , .p ="prog0" , .id =8 }, + { .n ="pck1" , .p ="prog1" , .id =9 }, + { .n ="pck2" , .p ="prog2" , .id =10 }, +}; + +static const struct { +char *n; +u8 id; +} sama5d4_periph32ck[] = { + { .n ="pioD_clk" , .id =5 }, + { .n ="usart0_clk" , .id =6 }, + { .n ="usart1_clk" , .id =7 }, + { .n ="icm_clk" , .id =9 }, + { .n ="aes_clk" , .id =12 }, + { .n ="tdes_clk" , .id =14 }, + { .n ="sha_clk" , .id =15 }, + { .n ="matrix1_clk" , .id =17 }, + { .n ="hsmc_clk" , .id =22 }, + { .n ="pioA_clk" , .id =23 }, + { .n ="pioB_clk" , .id =24 }, + { .n ="pioC_clk" , .id =25 }, + { .n ="pioE_clk" , .id =26 }, + { .n ="uart0_clk" , .id =27 }, + { .n ="uart1_clk" , .id =28 }, + { .n ="usart2_clk" , .id =29 }, + { .n ="usart3_clk" , .id =30 }, + { .n ="usart4_clk" , .id =31 }, + { .n ="twi0_clk" , .id =32 }, + { .n ="twi1_clk" , .id =33 }, + { .n ="twi2_clk" , .id =34 }, + { .n ="mci0_clk" , .id =35 }, + { .n ="mci1_clk" , .id =36 }, + { .n ="spi0_clk" , .id =37 }, + { .n ="spi1_clk" , .id =38 }, + { .n ="spi2_clk" , .id =39 }, + { .n ="tcb0_clk" , .id =40 }, + { .n ="tcb1_clk" , .id =41 }, + { .n ="tcb2_clk" , .id =42 }, + { .n ="pwm_clk" , .id =43 }, + { .n ="adc_clk" , .id =44 }, + { .n ="dbgu_clk" , .id =45 }, + { .n ="uhphs_clk" , .id =46 }, + { .n ="udphs_clk" , .id =47 }, + { .n ="ssc0_clk" , .id =48 }, + { .n ="ssc1_clk" , .id =49 }, + { .n ="trng_clk" , .id =53 }, + { .n ="macb0_clk" , .id =54 }, + { .n ="macb1_clk" , .id =55 }, + { .n ="fuse_clk" , .id =57 }, + { .n ="securam_clk" , .id =59 }, + { .n ="smd_clk" , .id =61 }, + { .n ="twi3_clk" , .id =62 }, + { .n ="catb_clk" , .id =63 }, +}; + +static const struct { +char *n; +u8 id; +} sama5d4_periphck[] = { + { .n ="dma0_clk" , .id =8 }, + { .n ="cpkcc_clk" , .id =10 }, + { .n ="aesb_clk" , .id =13 }, + { .n ="mpddr_clk" , .id =16 }, + { .n ="matrix0_clk" , .id =18 }, + { .n ="vdec_clk" , .id =19 }, + { .n ="dma1_clk" , .id =50 }, + { .n ="lcdc_clk" , .id =51 }, + { .n ="isi_clk" , .id =52 }, +}; + +static void __init sama5d4_pmc_setup (struct device_node *np) +{ +struct clk_range range =CLK_RANGE (0 ,0 ); +const char *slck_name, *mainxtal_name; +struct pmc_data *sama5d4_pmc; +const char *parent_names[5 ]; +struct regmap *regmap; +struct clk *hw; +int i; +bool bypass; + + i =of_property_match_string (np,"clock-names" ,"slow_clk" ); +if (i <0 ) +return ; + + slck_name =of_clk_get_parent_name (np, i); + + i =of_property_match_string (np,"clock-names" ,"main_xtal" ); +if (i <0 ) +return ; + mainxtal_name =of_clk_get_parent_name (np, i); + + regmap =syscon_node_to_regmap (np); +if (IS_ERR (regmap)) +return ; + + sama5d4_pmc =pmc_data_allocate (PMC_MCK2 +1 , +nck (sama5d4_systemck), +nck (sama5d4_periph32ck),0 ); +if (!sama5d4_pmc) +return ; + + hw =at91_clk_register_main_rc_osc (regmap,"main_rc_osc" ,12000000 , +100000000 ); +if (IS_ERR (hw)) + goto err_free; + + bypass =of_property_read_bool (np,"atmel,osc-bypass" ); + + hw =at91_clk_register_main_osc (regmap,"main_osc" , mainxtal_name, + bypass); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] ="main_rc_osc" ; + parent_names[1 ] ="main_osc" ; + hw =at91_clk_register_sam9x5_main (regmap,"mainck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_pll (regmap,"pllack" ,"mainck" ,0 , + &sama5d3_pll_layout, &plla_characteristics); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_plldiv (regmap,"plladivck" ,"pllack" ); +if (IS_ERR (hw)) + goto err_free; + + hw =at91_clk_register_utmi (regmap,NULL ,"utmick" ,"mainck" ); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->chws[PMC_UTMI ] = hw; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + hw =at91_clk_register_master (regmap,"masterck" ,4 , parent_names, + &at91sam9x5_master_layout, + &mck_characteristics); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->chws[PMC_MCK ] = hw; + + hw =at91_clk_register_h32mx (regmap,"h32mxck" ,"masterck" ); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->chws[PMC_MCK2 ] = hw; + + parent_names[0 ] ="plladivck" ; + parent_names[1 ] ="utmick" ; + hw =at91sam9x5_clk_register_usb (regmap,"usbck" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] ="plladivck" ; + parent_names[1 ] ="utmick" ; + hw =at91sam9x5_clk_register_smd (regmap,"smdclk" , parent_names,2 ); +if (IS_ERR (hw)) + goto err_free; + + parent_names[0 ] = slck_name; + parent_names[1 ] ="mainck" ; + parent_names[2 ] ="plladivck" ; + parent_names[3 ] ="utmick" ; + parent_names[4 ] ="mck" ; +for (i =0 ; i <3 ; i++) { +char *name; + + name =xasprintf ("prog%d" , i); + + hw =at91_clk_register_programmable (regmap, name, + parent_names,5 , i, + &at91sam9x5_programmable_layout); +if (IS_ERR (hw)) + goto err_free; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d4_systemck); i++) { + hw =at91_clk_register_system (regmap, sama5d4_systemck[i].n, + sama5d4_systemck[i].p, + sama5d4_systemck[i].id); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->shws[sama5d4_systemck[i].id] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d4_periphck); i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, &pmc_pcr_lock, + sama5d4_periphck[i].n, +"masterck" , + sama5d4_periphck[i].id, + &range); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->phws[sama5d4_periphck[i].id] = hw; + } + +for (i =0 ; i <ARRAY_SIZE (sama5d4_periph32ck); i++) { + hw =at91_clk_register_sam9x5_peripheral (regmap, &pmc_pcr_lock, + sama5d4_periph32ck[i].n, +"h32mxck" , + sama5d4_periph32ck[i].id, + &range); +if (IS_ERR (hw)) + goto err_free; + + sama5d4_pmc->phws[sama5d4_periph32ck[i].id] = hw; + } + +of_clk_add_provider (np, of_clk_hw_pmc_get, sama5d4_pmc); + +return ; + +err_free: +pmc_data_free (sama5d4_pmc); +} +CLK_OF_DECLARE_DRIVER (sama5d4_pmc,"atmel,sama5d4-pmc" , sama5d4_pmc_setup);
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 9/9 clk: at91: update to new bindings
In reply to Sam RavnborgBased on kernel 5.0-rc6 update at91 clk support
to match the new PMC bindings.
Manually added all changes done in the kernel from 4.9-rc3 to 5.0-rc6.
New drivers required was added as seperate commits.
The kernel has a dt-compat file for all the backward compatibility code.
As barebox has only a few DT enabled at91 targets this was not ported over.
clk-programmable saw some extra changes - it had never been bulit. It is used only by at91sama5d2 - and barebox has no baord support for this cpu (yet).
For the SOC config symbols updated these to match the kernel, to enable the same set of clk features in barebox as in the kernel.
In the kernel CLK_OF_DECLARE_DRIVER() can be used for a two step init. In barebox this is a simple one step init.
It was added to have less differences between the kernel and the barebox versions of the drivers.
--- arch/arm/mach-at91/Kconfig | 17 ++- drivers/clk/at91/Makefile | 5 + drivers/clk/at91/clk-generated.c | 185 +++++---------------------- drivers/clk/at91/clk-h32mx.c | 21 +-- drivers/clk/at91/clk-main.c | 112 +--------------- drivers/clk/at91/clk-master.c | 94 +------------- drivers/clk/at91/clk-peripheral.c | 82 +----------- drivers/clk/at91/clk-pll.c | 174 +------------------------ drivers/clk/at91/clk-plldiv.c | 27 +--- drivers/clk/at91/clk-programmable.c | 83 +----------- drivers/clk/at91/clk-slow.c | 33 +---- drivers/clk/at91/clk-smd.c | 33 +---- drivers/clk/at91/clk-system.c | 42 +----- drivers/clk/at91/clk-usb.c | 94 +------------- drivers/clk/at91/clk-utmi.c | 100 +++++++++------ drivers/clk/at91/pmc.c | 248 ++++++++++++++++++++++++++++++++++++ drivers/clk/at91/pmc.h | 169 ++++++++++++++++++++++++ include/linux/clk.h | 7 + include/soc/at91/atmel-sfr.h | 34 +++++ 19 files changed, 602 insertions(+), 958 deletions(-) create mode 100644 include/soc/at91/atmel-sfr.h
arch/arm/mach-at91/Kconfig +12 -5
@@ -53,6 +53,9 @@ config SOC_AT91SAM9 select AT91SAM9_SMC select CLOCKSOURCE_ATMEL_PIT select PINCTRL + select HAVE_AT91_SMD + select HAVE_AT91_USB_CLK + select HAVE_AT91_UTMI config SOC_SAMA5 bool
@@ -63,12 +66,19 @@ config SOC_SAMA5D3 select SOC_SAMA5 select AT91SAM9_SMC select CLOCKSOURCE_ATMEL_PIT + select HAVE_AT91_SMD + select HAVE_AT91_USB_CLK + select HAVE_AT91_UTMI config SOC_SAMA5D4 bool select SOC_SAMA5 select AT91SAM9_SMC select CLOCKSOURCE_ATMEL_PIT + select HAVE_AT91_H32MX + select HAVE_AT91_SMD + select HAVE_AT91_USB_CLK + select HAVE_AT91_UTMI config ARCH_TEXT_BASE hex
@@ -92,8 +102,9 @@ comment "Atmel AT91 System-on-Chip" config SOC_AT91RM9200 bool select CPU_ARM920T - select HAVE_AT91_DBGU0 select HAS_AT91_ETHER + select HAVE_AT91_DBGU0 + select HAVE_AT91_USB_CLK config SOC_AT91SAM9260 bool
@@ -132,9 +143,6 @@ config SOC_AT91SAM9X5 select SOC_AT91SAM9 select HAVE_AT91_DBGU0 select HAS_MACB - select HAVE_AT91_SMD - select HAVE_AT91_USB_CLK - select HAVE_AT91_UTMI select COMMON_CLK_OF_PROVIDER help Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
@@ -532,7 +540,6 @@ config MACH_AT91SAM9263EK depends on ARCH_AT91SAM9263 select OFDEVICE select COMMON_CLK_OF_PROVIDER - select HAVE_AT91_USB_CLK select HAVE_NAND_ATMEL_BUSWIDTH_16 select HAVE_AT91_BOOTSTRAP select AT91SAM926X_BOARD_INIT
drivers/clk/at91/Makefile +5 -0
@@ -11,3 +11,8 @@ obj-$(CONFIG_HAVE_AT91_USB_CLK) += clk-usb.o obj-$(CONFIG_HAVE_AT91_SMD) += clk-smd.o obj-$(CONFIG_HAVE_AT91_H32MX) += clk-h32mx.o obj-$(CONFIG_HAVE_AT91_GENERATED_CLK) += clk-generated.o +obj-$(CONFIG_SOC_AT91SAM9) += at91sam9260.o +obj-$(CONFIG_SOC_AT91SAM9) += at91sam9rl.o +obj-$(CONFIG_SOC_AT91SAM9) += at91sam9x5.o +obj-$(CONFIG_SOC_SAMA5D2) += sama5d2.o +obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o
drivers/clk/at91/clk-generated.c +32 -153
305 lines not on this page · raw message
drivers/clk/at91/clk-h32mx.c +7 -14
@@ -15,7 +15,6 @@#include <linux/clk-provider.h> #include <linux/clkdev.h> #include <linux/clk/at91_pmc.h> -#include <linux/of.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h>
@@ -86,25 +85,21 @@ static const struct clk_ops h32mx_ops = { .set_rate = clk_sama5d4_h32mx_set_rate, }; -static void __init of_sama5d4_clk_h32mx_setup (struct device_node *np) +struct clk * +at91_clk_register_h32mx (struct regmap *regmap,const char *name, +const char *parent_name) {struct clk_sama5d4_h32mx *h32mxclk;struct clk_init_data init; -const char *parent_name; -struct regmap *regmap;int ret; - regmap =syscon_node_to_regmap (of_get_parent (np)); -if (IS_ERR (regmap)) -return ; - h32mxclk =kzalloc (sizeof (*h32mxclk),GFP_KERNEL );if (!h32mxclk) -return ; +return ERR_PTR (-ENOMEM ); parent_name =of_clk_get_parent_name (np,0 ); - init.name = np->name; + init.name = name; init.ops = &h32mx_ops; init.parent_names = parent_name ? &parent_name :NULL ; init.num_parents = parent_name ?1 :0 ;
@@ -116,10 +111,8 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) ret =clk_hw_register (NULL , &h32mxclk->hw);if (ret) {kfree (h32mxclk); -return ; +return ERR_PTR (ret); } -of_clk_add_hw_provider (np, of_clk_hw_simple_get, &h32mxclk->hw); +return &h32mxclk->hw; } -CLK_OF_DECLARE (of_sama5d4_clk_h32mx_setup,"atmel,sama5d4-clk-h32mx" , - of_sama5d4_clk_h32mx_setup);
drivers/clk/at91/clk-main.c +5 -107
165 lines not on this page · raw message
drivers/clk/at91/clk-master.c +3 -91
122 lines not on this page · raw message
drivers/clk/at91/clk-peripheral.c +2 -80
109 lines not on this page · raw message
drivers/clk/at91/clk-pll.c +5 -169
208 lines not on this page · raw message
drivers/clk/at91/clk-plldiv.c +1 -26
@@ -78,7 +78,7 @@ static const struct clk_ops plldiv_ops = { .set_rate = clk_plldiv_set_rate, }; -static struct clk * +struct clk *at91_clk_register_plldiv (struct regmap *regmap,const char *name,const char *parent_name) {
@@ -108,28 +108,3 @@ at91_clk_register_plldiv(struct regmap *regmap, const char *name,return &plldiv->clk; } - -static int -of_at91sam9x5_clk_plldiv_setup (struct device_node *np) -{ -struct clk *clk; -const char *parent_name; -const char *name = np->name; -struct regmap *regmap; - - parent_name =of_clk_get_parent_name (np,0 ); - -of_property_read_string (np,"clock-output-names" , &name); - - regmap =syscon_node_to_regmap (of_get_parent (np)); -if (IS_ERR (regmap)) -return PTR_ERR (regmap); - - clk =at91_clk_register_plldiv (regmap, name, parent_name); -if (IS_ERR (clk)) -return PTR_ERR (clk); - -return of_clk_add_provider (np, of_clk_src_simple_get, clk); -} -CLK_OF_DECLARE (at91sam9x5_clk_plldiv,"atmel,at91sam9x5-clk-plldiv" , - of_at91sam9x5_clk_plldiv_setup);
drivers/clk/at91/clk-programmable.c +4 -79
118 lines not on this page · raw message
drivers/clk/at91/clk-slow.c +1 -32
@@ -12,7 +12,6 @@#include <common.h> #include <clock.h> -#include <of.h> #include <io.h> #include <linux/list.h> #include <linux/clk.h>
@@ -44,7 +43,7 @@ static const struct clk_ops sam9260_slow_ops = { .get_parent = clk_sam9260_slow_get_parent, }; -static struct clk *__init +struct clk *__init at91_clk_register_sam9260_slow(struct regmap *regmap, const char *name, const char **parent_names,
@@ -76,33 +75,3 @@ at91_clk_register_sam9260_slow(struct regmap *regmap,return &slowck->clk; } - -static int of_at91sam9260_clk_slow_setup (struct device_node *np) -{ -struct clk *clk; -const char *parent_names[2 ]; -unsigned int num_parents; -const char *name = np->name; -struct regmap *regmap; - - num_parents =of_clk_get_parent_count (np); -if (num_parents !=2 ) -return -EINVAL ; - -of_clk_parent_fill (np, parent_names, num_parents); - regmap =syscon_node_to_regmap (of_get_parent (np)); -if (IS_ERR (regmap)) -return PTR_ERR (regmap); - -of_property_read_string (np,"clock-output-names" , &name); - - clk =at91_clk_register_sam9260_slow (regmap, name, parent_names, - num_parents); -if (IS_ERR (clk)) -return PTR_ERR (clk); - -return of_clk_add_provider (np, of_clk_src_simple_get, clk); -} - -CLK_OF_DECLARE (at91sam9260_clk_slow,"atmel,at91sam9260-clk-slow" , - of_at91sam9260_clk_slow_setup);
drivers/clk/at91/clk-smd.c +1 -32
@@ -10,7 +10,6 @@#include <common.h> #include <clock.h> -#include <of.h> #include <io.h> #include <linux/list.h> #include <linux/clk.h>
@@ -115,7 +114,7 @@ static const struct clk_ops at91sam9x5_smd_ops = { .set_rate = at91sam9x5_clk_smd_set_rate, }; -static struct clk * +struct clk *at91sam9x5_clk_register_smd (struct regmap *regmap,const char *name,const char **parent_names,u8 num_parents) {
@@ -140,33 +139,3 @@ at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,return &smd->clk; } - -static int of_at91sam9x5_clk_smd_setup (struct device_node *np) -{ -struct clk *clk; -unsigned int num_parents; -const char *parent_names[SMD_SOURCE_MAX ]; -const char *name = np->name; -struct regmap *regmap; - - num_parents =of_clk_get_parent_count (np); -if (num_parents ==0 || num_parents >SMD_SOURCE_MAX ) -return -EINVAL ; - -of_clk_parent_fill (np, parent_names, num_parents); - -of_property_read_string (np,"clock-output-names" , &name); - - regmap =syscon_node_to_regmap (of_get_parent (np)); -if (IS_ERR (regmap)) -return PTR_ERR (regmap); - - clk =at91sam9x5_clk_register_smd (regmap, name, parent_names, - num_parents); -if (IS_ERR (clk)) -return PTR_ERR (clk); - -return of_clk_add_provider (np, of_clk_src_simple_get, clk); -} -CLK_OF_DECLARE (at91sam9x5_clk_smd,"atmel,at91sam9x5-clk-smd" , - of_at91sam9x5_clk_smd_setup);
drivers/clk/at91/clk-system.c +1 -41
57 lines not on this page · raw message
drivers/clk/at91/clk-usb.c +3 -91
121 lines not on this page · raw message
drivers/clk/at91/clk-utmi.c +62 -38
161 lines not on this page · raw message
drivers/clk/at91/pmc.c +248 -0
259 lines not on this page · raw message
drivers/clk/at91/pmc.h +169 -0
182 lines not on this page · raw message
include/linux/clk.h +7 -0
@@ -385,6 +385,11 @@ int of_clk_add_provider(struct device_node *np,struct clk *(*clk_src_get)(struct of_phandle_args *args,void *data), void *data); + +static inline unsigned int clk_get_num_parents (const struct clk *hw) +{ +return hw->num_parents; +}#else
@@ -430,6 +435,8 @@ static inline int of_clk_add_provider(struct device_node *np, }#endif +#define CLK_OF_DECLARE_DRIVER (name, compat, fn) CLK_OF_DECLARE(name, compat, fn) +struct string_list ;int clk_name_complete (struct string_list *sl,char *instr);
include/soc/at91/atmel-sfr.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Atmel SFR (Special Function Registers) register offsets and bit definitions. +* +* Copyright (C) 2016 Atmel +* +* Author: Ludovic Desroches <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _LINUX_MFD_SYSCON_ATMEL_SFR_H +#define _LINUX_MFD_SYSCON_ATMEL_SFR_H + +#define AT91_SFR_DDRCFG 0x04/* DDR Configuration Register */ +/* 0x08 ~ 0x0c: Reserved */ +#define AT91_SFR_OHCIICR 0x10/* OHCI INT Configuration Register */ +#define AT91_SFR_OHCIISR 0x14/* OHCI INT Status Register */ +#define AT91_SFR_UTMICKTRIM 0x30/* UTMI Clock Trimming Register */ +#define AT91_SFR_I2SCLKSEL 0x90/* I2SC Register */ + +/* Field definitions */ +#define AT91_OHCIICR_SUSPEND_A BIT(8) +#define AT91_OHCIICR_SUSPEND_B BIT(9) +#define AT91_OHCIICR_SUSPEND_C BIT(10) + +#define AT91_OHCIICR_USB_SUSPEND (AT91_OHCIICR_SUSPEND_A | \ + AT91_OHCIICR_SUSPEND_B | \ + AT91_OHCIICR_SUSPEND_C) + +#define AT91_UTMICKTRIM_FREQ GENMASK(1, 0) + +#endif /* _LINUX_MFD_SYSCON_ATMEL_SFR_H */
Signature · 7 lines
2.12.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi all.
Quoted 10 lines
Sam Ravnborg (9):
clocksource: Do not mix depends and select for ATMEL_PIT arm: at91: fix at91_configure_usart6 warning arm: at91: add SOC_SAMA5{D3,D4} clk: at91: add at91sam9260 clk: at91: add at91sam9rl clk: at91: add at91sam9x5 clk: at91: add sama5d2 clk: at91: add sama5d4
This patch is bogus, fails to build.
Quoted 1 line
clk: at91: update to new bindings
Likewise, at least part of it.
Both issues discovered while working on adding DT support to sama5d4 xplained board.
Will repost an updated series when I have it fixed.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Ladislav Michl
Tested-byHi Sam,
Quoted 11 lines · Sam Ravnborg
Hi all.
Quoted 8 lines
Sam Ravnborg (9):
clocksource: Do not mix depends and select for ATMEL_PIT arm: at91: fix at91_configure_usart6 warning arm: at91: add SOC_SAMA5{D3,D4} clk: at91: add at91sam9260 clk: at91: add at91sam9rl clk: at91: add at91sam9x5 clk: at91: add sama5d2
Quoted 5 lines
Quoted 1 line
clk: at91: add sama5d4This patch is bogus, fails to build.
Quoted 1 line
clk: at91: update to new bindings
Likewise, at least part of it.
Well, it builds for at91sam9260 (at91sam9g20) and is runtime tested now. So for that configuration here is my
Besides, current master plus your patches is about 1,3kB bigger, so it does not fit Dataflash anymore, but that is separate issue to solve :)
Thanks a lot for your work!
ladis
Quoted 11 lines
Both issues discovered while working on adding DT support to sama5d4 xplained board.
Will repost an updated series when I have it fixed.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hi Ladislav
Quoted 15 lines · Ladislav Michl
Hi Sam,
Quoted 12 lines · Sam Ravnborg
Hi all.
Quoted 10 lines
Sam Ravnborg (9):
clocksource: Do not mix depends and select for ATMEL_PIT arm: at91: fix at91_configure_usart6 warning arm: at91: add SOC_SAMA5{D3,D4} clk: at91: add at91sam9260 clk: at91: add at91sam9rl clk: at91: add at91sam9x5 clk: at91: add sama5d2 clk: at91: add sama5d4
Quoted 8 lines
Quoted 4 lines
This patch is bogus, fails to build.
Quoted 1 line
clk: at91: update to new bindings
Likewise, at least part of it.
Well, it builds for at91sam9260 (at91sam9g20) and is runtime tested now. So for that configuration here is my
Tested-by Ladislav Michl <[email protected]>
Thanks, very good to know it works for others.
The build failure started when I pulled in clk-h32mx and sama5d4. They are not used by SAM9 so you are safe.
Quoted 2 lines
Besides, current master plus your patches is about 1,3kB bigger, so it does not fit Dataflash anymore, but that is separate issue to solve :)
The current patch pulls in at91sam9260 + at91sam9rl + at91sam9x5 for the SAM9 targets. This is like done in the kernel today. We may have to look at splitting this up.
The patchset also enabled some clocks that was not enabled before. Maybe we can avoid them as they may not be required in the bootloader. This is also something inherited from the kernel.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 18 lines · Sam Ravnborg
The following patchset add supports for the PMC clk bindings for at91.
The patchset was tested on:
- at91sam9264ek - DT enabled
- sama5d4-xplained - non DTThe patchset includes
sama5d2.cwhich is not used today. I have a sama5d27-som1-ek board that I hope to find time to work with and then this will be needed.Patch 4-8 add drivers but do not wire then into the build. This was done to somehow ease review of the final patch. Patches are rather big but trying to split them up more than already done seems not worth it.
Patch was made on top of:
12cd92023788fdc67ad72c6e7d96251a6234ca3e("Merge branch 'for-next/rpi' into next")
Quoted 7 lines
On stray patch sneaked in - to kill a warning.
The patchset triggers some checkpatch warnings:
- SPDX, the barebox variant of checkpatch is missing support for these (anyone?)
- Too long lines. As code is copied from the kernel I left them as-isComments/testing very welcome!
Applied, thanks. Since AT91 is broken currently I applied it to master.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Sascha
Quoted 2 lines
Applied, thanks. Since AT91 is broken currently I applied it to master.
I did not see it in master yet so I sent a full v3 with build fixes and Tested-by: annotations.
It this is too late for master I will do a follow-up with only the build fix changes.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 9 lines · Sam Ravnborg
Hi Sascha
Quoted 2 lines
Applied, thanks. Since AT91 is broken currently I applied it to master.
I did not see it in master yet so I sent a full v3 with build fixes and Tested-by: annotations.
It this is too late for master I will do a follow-up with only the build fix changes.
All good, Ladis already reminded me that you wanted to send a v2 so I haven't pushed it yet. I can still take v2.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Sam Ravnborg
Hi Sascha
Quoted 2 lines
Applied, thanks. Since AT91 is broken currently I applied it to master.
Quoted 8 lines
Quoted 5 lines
I did not see it in master yet so I sent a full v3 with build fixes and Tested-by: annotations.
It this is too late for master I will do a follow-up with only the build fix changes.
All good, Ladis already reminded me that you wanted to send a v2 so I haven't pushed it yet. I can still take v2.
Ahmad sent a fixup! to add compat because sam5d3 do not yet support the new clock binding. Let me integrate these and send a V3.
Sam
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 9 lines · Sam Ravnborg
Quoted 8 lines · Sascha Hauer
Quoted 7 lines · Sam Ravnborg
Hi Sascha
Quoted 2 lines
Applied, thanks. Since AT91 is broken currently I applied it to master.
I did not see it in master yet so I sent a full v3 with build fixes and Tested-by: annotations.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
It this is too late for master I will do a follow-up with only the build fix changes.
All good, Ladis already reminded me that you wanted to send a v2 so I haven't pushed it yet. I can still take v2.
Ahmad sent a fixup! to add compat because sam5d3 do not yet support the new clock binding. Let me integrate these and send a V3.
Sure. I'll wait some time until things have settled before I apply anything ;)
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Sam Ravnborg
Hi Sascha
Quoted 2 lines
Applied, thanks. Since AT91 is broken currently I applied it to master.
Quoted 8 lines
Quoted 5 lines
I did not see it in master yet so I sent a full v3 with build fixes and Tested-by: annotations.
It this is too late for master I will do a follow-up with only the build fix changes.
All good, Ladis already reminded me that you wanted to send a v2 so I haven't pushed it yet. I can still take v2.
I guess you mean v3 here, plus Ahmad's fixups :). That would work for me.
ladis
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox