at91: switch to CLKDEV_LOOKUP
PATCH 1/1 at91: switch to CLKDEV_LOOKUP
we do not change the clock naming convention so does not need to switch the AVR32 yet
--- arch/arm/Kconfig | 1 + arch/arm/mach-at91/at572d940hf.c | 64 +++++++++++++++++++++++ arch/arm/mach-at91/at572d940hf_devices.c | 22 ++++---- arch/arm/mach-at91/at91cap9.c | 58 ++++++++++++++++++++ arch/arm/mach-at91/at91cap9_devices.c | 28 ++++------ arch/arm/mach-at91/at91rm9200.c | 50 ++++++++++++++++++ arch/arm/mach-at91/at91rm9200_devices.c | 28 ++++------ arch/arm/mach-at91/at91sam9260.c | 54 +++++++++++++++++++ arch/arm/mach-at91/at91sam9260_devices.c | 31 ++++------- arch/arm/mach-at91/at91sam9261.c | 55 +++++++++++++++++++ arch/arm/mach-at91/at91sam9261_devices.c | 26 ++++----- arch/arm/mach-at91/at91sam9263.c | 54 +++++++++++++++++++ arch/arm/mach-at91/at91sam9263_devices.c | 24 ++++---- arch/arm/mach-at91/at91sam9g45.c | 84 +++++++++++++++++++++++------- arch/arm/mach-at91/at91sam9g45_devices.c | 31 ++++------- arch/arm/mach-at91/at91sam9rl.c | 51 ++++++++++++++++++ arch/arm/mach-at91/at91sam9rl_devices.c | 27 ++++----- arch/arm/mach-at91/clock.c | 54 +++++-------------- arch/arm/mach-at91/clock.h | 19 ++++++- arch/arm/mach-at91/generic.h | 12 ++++- arch/arm/mach-at91/include/mach/clkdev.h | 7 +++ 21 files changed, 598 insertions(+), 182 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/clkdev.h
arch/arm/Kconfig +1 -0
@@ -289,6 +289,7 @@ config ARCH_AT91 select ARCH_REQUIRE_GPIOLIB select HAVE_CLK select GENERIC_ALLOCATOR + select CLKDEV_LOOKUP help This enables support for systems based on the Atmel AT91RM9200, AT91SAM9 and AT91CAP9 processors.
arch/arm/mach-at91/at572d940hf.c +64 -0
102 lines not on this page · raw message
arch/arm/mach-at91/at572d940hf_devices.c +12 -10
@@ -532,7 +532,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PA1 ,0 );/* SPI0_MOSI */ at91_set_A_periph (AT91_PIN_PA2 ,0 );/* SPI0_SPCK */ -at91_clock_associate ("spi0_clk" , &at572d940hf_spi0_device.dev,"spi_clk" );platform_device_register (&at572d940hf_spi0_device); }if (enable_spi1) {
@@ -540,7 +539,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PC1 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PC2 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at572d940hf_spi1_device.dev,"spi_clk" );platform_device_register (&at572d940hf_spi1_device); } }
@@ -588,9 +586,6 @@ static struct platform_device at572d940hf_tcb_device = {static void __init at91_add_device_tc (void ) {/* this chip has a separate clock and irq for each TC channel */ -at91_clock_associate ("tc0_clk" , &at572d940hf_tcb_device.dev,"t0_clk" ); -at91_clock_associate ("tc1_clk" , &at572d940hf_tcb_device.dev,"t1_clk" ); -at91_clock_associate ("tc2_clk" , &at572d940hf_tcb_device.dev,"t2_clk" );platform_device_register (&at572d940hf_tcb_device); }#else
@@ -828,22 +823,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at572d940hf_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT572D940HF_ID_US0 : pdev = &at572d940hf_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT572D940HF_ID_US1 : pdev = &at572d940hf_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT572D940HF_ID_US2 : pdev = &at572d940hf_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -855,10 +846,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at572d940hf_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91cap9.c +58 -0
80 lines not on this page · raw message
arch/arm/mach-at91/at91cap9_devices.c +12 -16
@@ -181,10 +181,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data)/* Pullup pin is handled internally by USB device peripheral */ -/* Clocks */ -at91_clock_associate ("utmi_clk" , &at91_usba_udc_device.dev,"hclk" ); -at91_clock_associate ("udphs_clk" , &at91_usba_udc_device.dev,"pclk" ); - platform_device_register(&at91_usba_udc_device); }#else
@@ -355,7 +351,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc0_data = *data; -at91_clock_associate ("mci0_clk" , &at91cap9_mmc0_device.dev,"mci_clk" );platform_device_register (&at91cap9_mmc0_device); }else {/* MCI1 */ /* CLK */
@@ -373,7 +368,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc1_data = *data; -at91_clock_associate ("mci1_clk" , &at91cap9_mmc1_device.dev,"mci_clk" );platform_device_register (&at91cap9_mmc1_device); } }
@@ -614,7 +608,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_B_periph (AT91_PIN_PA1 ,0 );/* SPI0_MOSI */ at91_set_B_periph (AT91_PIN_PA2 ,0 );/* SPI0_SPCK */ -at91_clock_associate ("spi0_clk" , &at91cap9_spi0_device.dev,"spi_clk" );platform_device_register (&at91cap9_spi0_device); }if (enable_spi1) {
@@ -622,7 +615,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB13 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PB14 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at91cap9_spi1_device.dev,"spi_clk" );platform_device_register (&at91cap9_spi1_device); } }
@@ -660,7 +652,6 @@ static struct platform_device at91cap9_tcb_device = {static void __init at91_add_device_tc (void ) {/* this chip has one clock and irq for all three TC channels */ -at91_clock_associate ("tcb_clk" , &at91cap9_tcb_device.dev,"t0_clk" );platform_device_register (&at91cap9_tcb_device); }#else
@@ -1001,12 +992,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91CAP9_ID_SSC0 : pdev = &at91cap9_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"ssc" );break ;case AT91CAP9_ID_SSC1 : pdev = &at91cap9_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"ssc" );break ;default :return ;
@@ -1205,22 +1194,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91cap9_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91CAP9_ID_US0 : pdev = &at91cap9_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91CAP9_ID_US1 : pdev = &at91cap9_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91CAP9_ID_US2 : pdev = &at91cap9_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1232,10 +1217,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91cap9_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91rm9200.c +50 -0
72 lines not on this page · raw message
arch/arm/mach-at91/at91rm9200_devices.c +12 -16
@@ -645,14 +645,7 @@ static struct platform_device at91rm9200_tcb1_device = {static void __init at91_add_device_tc (void ) {/* this chip has a separate clock and irq for each TC channel */ -at91_clock_associate ("tc0_clk" , &at91rm9200_tcb0_device.dev,"t0_clk" ); -at91_clock_associate ("tc1_clk" , &at91rm9200_tcb0_device.dev,"t1_clk" ); -at91_clock_associate ("tc2_clk" , &at91rm9200_tcb0_device.dev,"t2_clk" );platform_device_register (&at91rm9200_tcb0_device); - -at91_clock_associate ("tc3_clk" , &at91rm9200_tcb1_device.dev,"t0_clk" ); -at91_clock_associate ("tc4_clk" , &at91rm9200_tcb1_device.dev,"t1_clk" ); -at91_clock_associate ("tc5_clk" , &at91rm9200_tcb1_device.dev,"t2_clk" );platform_device_register (&at91rm9200_tcb1_device); }#else
@@ -849,17 +842,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91RM9200_ID_SSC0 : pdev = &at91rm9200_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"ssc" );break ;case AT91RM9200_ID_SSC1 : pdev = &at91rm9200_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"ssc" );break ;case AT91RM9200_ID_SSC2 : pdev = &at91rm9200_ssc2_device;configure_ssc2_pins (pins); -at91_clock_associate ("ssc2_clk" , &pdev->dev,"ssc" );break ;default :return ;
@@ -1115,27 +1105,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91rm9200_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91RM9200_ID_US0 : pdev = &at91rm9200_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91RM9200_ID_US1 : pdev = &at91rm9200_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91RM9200_ID_US2 : pdev = &at91rm9200_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;case AT91RM9200_ID_US3 : pdev = &at91rm9200_uart3_device;configure_usart3_pins (pins); -at91_clock_associate ("usart3_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1147,10 +1132,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91rm9200_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91sam9260.c +54 -0
74 lines not on this page · raw message
arch/arm/mach-at91/at91sam9260_devices.c +12 -19
@@ -609,7 +609,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PA1 ,0 );/* SPI0_MOSI */ at91_set_A_periph (AT91_PIN_PA2 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi0_clk" , &at91sam9260_spi0_device.dev,"spi_clk" );platform_device_register (&at91sam9260_spi0_device); }if (enable_spi1) {
@@ -617,7 +616,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB1 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PB2 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at91sam9260_spi1_device.dev,"spi_clk" );platform_device_register (&at91sam9260_spi1_device); } }
@@ -694,15 +692,7 @@ static struct platform_device at91sam9260_tcb1_device = {static void __init at91_add_device_tc (void ) { -/* this chip has a separate clock and irq for each TC channel */ -at91_clock_associate ("tc0_clk" , &at91sam9260_tcb0_device.dev,"t0_clk" ); -at91_clock_associate ("tc1_clk" , &at91sam9260_tcb0_device.dev,"t1_clk" ); -at91_clock_associate ("tc2_clk" , &at91sam9260_tcb0_device.dev,"t2_clk" );platform_device_register (&at91sam9260_tcb0_device); - -at91_clock_associate ("tc3_clk" , &at91sam9260_tcb1_device.dev,"t0_clk" ); -at91_clock_associate ("tc4_clk" , &at91sam9260_tcb1_device.dev,"t1_clk" ); -at91_clock_associate ("tc5_clk" , &at91sam9260_tcb1_device.dev,"t2_clk" );platform_device_register (&at91sam9260_tcb1_device); }#else
@@ -820,7 +810,6 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91SAM9260_ID_SSC : pdev = &at91sam9260_ssc_device;configure_ssc_pins (pins); -at91_clock_associate ("ssc_clk" , &pdev->dev,"pclk" );break ;default :return ;
@@ -1145,37 +1134,30 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91sam9260_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US0 : pdev = &at91sam9260_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US1 : pdev = &at91sam9260_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US2 : pdev = &at91sam9260_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US3 : pdev = &at91sam9260_uart3_device;configure_usart3_pins (pins); -at91_clock_associate ("usart3_clk" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US4 : pdev = &at91sam9260_uart4_device;configure_usart4_pins (); -at91_clock_associate ("usart4_clk" , &pdev->dev,"usart" );break ;case AT91SAM9260_ID_US5 : pdev = &at91sam9260_uart5_device;configure_usart5_pins (); -at91_clock_associate ("usart5_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1187,10 +1169,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91sam9260_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91sam9261.c +55 -0
86 lines not on this page · raw message
arch/arm/mach-at91/at91sam9261_devices.c +12 -14
@@ -426,7 +426,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PA1 ,0 );/* SPI0_MOSI */ at91_set_A_periph (AT91_PIN_PA2 ,0 );/* SPI0_SPCK */ -at91_clock_associate ("spi0_clk" , &at91sam9261_spi0_device.dev,"spi_clk" );platform_device_register (&at91sam9261_spi0_device); }if (enable_spi1) {
@@ -434,7 +433,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB31 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PB29 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at91sam9261_spi1_device.dev,"spi_clk" );platform_device_register (&at91sam9261_spi1_device); } }
@@ -581,10 +579,6 @@ static struct platform_device at91sam9261_tcb_device = {static void __init at91_add_device_tc (void ) { -/* this chip has a separate clock and irq for each TC channel */ -at91_clock_associate ("tc0_clk" , &at91sam9261_tcb_device.dev,"t0_clk" ); -at91_clock_associate ("tc1_clk" , &at91sam9261_tcb_device.dev,"t1_clk" ); -at91_clock_associate ("tc2_clk" , &at91sam9261_tcb_device.dev,"t2_clk" );platform_device_register (&at91sam9261_tcb_device); }#else
@@ -786,17 +780,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91SAM9261_ID_SSC0 : pdev = &at91sam9261_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"pclk" );break ;case AT91SAM9261_ID_SSC1 : pdev = &at91sam9261_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"pclk" );break ;case AT91SAM9261_ID_SSC2 : pdev = &at91sam9261_ssc2_device;configure_ssc2_pins (pins); -at91_clock_associate ("ssc2_clk" , &pdev->dev,"pclk" );break ;default :return ;
@@ -995,22 +986,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91sam9261_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91SAM9261_ID_US0 : pdev = &at91sam9261_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91SAM9261_ID_US1 : pdev = &at91sam9261_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91SAM9261_ID_US2 : pdev = &at91sam9261_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1022,10 +1009,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91sam9261_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91sam9263.c +54 -0
76 lines not on this page · raw message
arch/arm/mach-at91/at91sam9263_devices.c +12 -12
@@ -308,7 +308,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc0_data = *data; -at91_clock_associate ("mci0_clk" , &at91sam9263_mmc0_device.dev,"mci_clk" );platform_device_register (&at91sam9263_mmc0_device); }else {/* MCI1 */ /* CLK */
@@ -339,7 +338,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc1_data = *data; -at91_clock_associate ("mci1_clk" , &at91sam9263_mmc1_device.dev,"mci_clk" );platform_device_register (&at91sam9263_mmc1_device); } }
@@ -686,7 +684,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_B_periph (AT91_PIN_PA1 ,0 );/* SPI0_MOSI */ at91_set_B_periph (AT91_PIN_PA2 ,0 );/* SPI0_SPCK */ -at91_clock_associate ("spi0_clk" , &at91sam9263_spi0_device.dev,"spi_clk" );platform_device_register (&at91sam9263_spi0_device); }if (enable_spi1) {
@@ -694,7 +691,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB13 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PB14 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at91sam9263_spi1_device.dev,"spi_clk" );platform_device_register (&at91sam9263_spi1_device); } }
@@ -942,7 +938,6 @@ static struct platform_device at91sam9263_tcb_device = {static void __init at91_add_device_tc (void ) {/* this chip has one clock and irq for all three TC channels */ -at91_clock_associate ("tcb_clk" , &at91sam9263_tcb_device.dev,"t0_clk" );platform_device_register (&at91sam9263_tcb_device); }#else
@@ -1171,12 +1166,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91SAM9263_ID_SSC0 : pdev = &at91sam9263_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"pclk" );break ;case AT91SAM9263_ID_SSC1 : pdev = &at91sam9263_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"pclk" );break ;default :return ;
@@ -1376,22 +1369,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91sam9263_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91SAM9263_ID_US0 : pdev = &at91sam9263_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91SAM9263_ID_US1 : pdev = &at91sam9263_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91SAM9263_ID_US2 : pdev = &at91sam9263_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1403,10 +1392,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91sam9263_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91sam9g45.c +65 -19
114 lines not on this page · raw message
arch/arm/mach-at91/at91sam9g45_devices.c +12 -19
@@ -180,7 +180,6 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) } usbh_ehci_data = *data; -at91_clock_associate ("uhphs_clk" , &at91_usbh_ehci_device.dev,"ehci_clk" );platform_device_register (&at91_usbh_ehci_device); }#else
@@ -266,10 +265,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data)/* Pullup pin is handled internally by USB device peripheral */ -/* Clocks */ -at91_clock_associate ("utmi_clk" , &at91_usba_udc_device.dev,"hclk" ); -at91_clock_associate ("udphs_clk" , &at91_usba_udc_device.dev,"pclk" ); - platform_device_register(&at91_usba_udc_device); }#else
@@ -478,7 +473,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) } mmc0_data = *data; -at91_clock_associate ("mci0_clk" , &at91sam9g45_mmc0_device.dev,"mci_clk" );platform_device_register (&at91sam9g45_mmc0_device); }else {/* MCI1 */
@@ -504,7 +498,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) } mmc1_data = *data; -at91_clock_associate ("mci1_clk" , &at91sam9g45_mmc1_device.dev,"mci_clk" );platform_device_register (&at91sam9g45_mmc1_device); }
@@ -801,7 +794,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB1 ,0 );/* SPI0_MOSI */ at91_set_A_periph (AT91_PIN_PB2 ,0 );/* SPI0_SPCK */ -at91_clock_associate ("spi0_clk" , &at91sam9g45_spi0_device.dev,"spi_clk" );platform_device_register (&at91sam9g45_spi0_device); }if (enable_spi1) {
@@ -809,7 +801,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)at91_set_A_periph (AT91_PIN_PB15 ,0 );/* SPI1_MOSI */ at91_set_A_periph (AT91_PIN_PB16 ,0 );/* SPI1_SPCK */ -at91_clock_associate ("spi1_clk" , &at91sam9g45_spi1_device.dev,"spi_clk" );platform_device_register (&at91sam9g45_spi1_device); } }
@@ -1000,9 +991,7 @@ static struct platform_device at91sam9g45_tcb1_device = {static void __init at91_add_device_tc (void ) {/* this chip has one clock and irq for all six TC channels */ -at91_clock_associate ("tcb0_clk" , &at91sam9g45_tcb0_device.dev,"t0_clk" );platform_device_register (&at91sam9g45_tcb0_device); -at91_clock_associate ("tcb1_clk" , &at91sam9g45_tcb1_device.dev,"t0_clk" );platform_device_register (&at91sam9g45_tcb1_device); }#else
@@ -1286,12 +1275,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91SAM9G45_ID_SSC0 : pdev = &at91sam9g45_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"pclk" );break ;case AT91SAM9G45_ID_SSC1 : pdev = &at91sam9g45_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"pclk" );break ;default :return ;
@@ -1533,27 +1520,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91sam9g45_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91SAM9G45_ID_US0 : pdev = &at91sam9g45_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91SAM9G45_ID_US1 : pdev = &at91sam9g45_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91SAM9G45_ID_US2 : pdev = &at91sam9g45_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;case AT91SAM9G45_ID_US3 : pdev = &at91sam9g45_uart3_device;configure_usart3_pins (pins); -at91_clock_associate ("usart3_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1565,10 +1547,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91sam9g45_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/at91sam9rl.c +51 -0
71 lines not on this page · raw message
arch/arm/mach-at91/at91sam9rl_devices.c +12 -15
@@ -155,10 +155,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data)/* Pullup pin is handled internally by USB device peripheral */ -/* Clocks */ -at91_clock_associate ("utmi_clk" , &at91_usba_udc_device.dev,"hclk" ); -at91_clock_associate ("udphs_clk" , &at91_usba_udc_device.dev,"pclk" ); - platform_device_register(&at91_usba_udc_device); }#else
@@ -606,9 +602,6 @@ static struct platform_device at91sam9rl_tcb_device = {static void __init at91_add_device_tc (void ) {/* this chip has a separate clock and irq for each TC channel */ -at91_clock_associate ("tc0_clk" , &at91sam9rl_tcb_device.dev,"t0_clk" ); -at91_clock_associate ("tc1_clk" , &at91sam9rl_tcb_device.dev,"t1_clk" ); -at91_clock_associate ("tc2_clk" , &at91sam9rl_tcb_device.dev,"t2_clk" );platform_device_register (&at91sam9rl_tcb_device); }#else
@@ -892,12 +885,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)case AT91SAM9RL_ID_SSC0 : pdev = &at91sam9rl_ssc0_device;configure_ssc0_pins (pins); -at91_clock_associate ("ssc0_clk" , &pdev->dev,"pclk" );break ;case AT91SAM9RL_ID_SSC1 : pdev = &at91sam9rl_ssc1_device;configure_ssc1_pins (pins); -at91_clock_associate ("ssc1_clk" , &pdev->dev,"pclk" );break ;default :return ;
@@ -1147,27 +1138,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)case 0 :/* DBGU */ pdev = &at91sam9rl_dbgu_device;configure_dbgu_pins (); -at91_clock_associate ("mck" , &pdev->dev,"usart" );break ;case AT91SAM9RL_ID_US0 : pdev = &at91sam9rl_uart0_device;configure_usart0_pins (pins); -at91_clock_associate ("usart0_clk" , &pdev->dev,"usart" );break ;case AT91SAM9RL_ID_US1 : pdev = &at91sam9rl_uart1_device;configure_usart1_pins (pins); -at91_clock_associate ("usart1_clk" , &pdev->dev,"usart" );break ;case AT91SAM9RL_ID_US2 : pdev = &at91sam9rl_uart2_device;configure_usart2_pins (pins); -at91_clock_associate ("usart2_clk" , &pdev->dev,"usart" );break ;case AT91SAM9RL_ID_US3 : pdev = &at91sam9rl_uart3_device;configure_usart3_pins (pins); -at91_clock_associate ("usart3_clk" , &pdev->dev,"usart" );break ;default :return ;
@@ -1179,10 +1165,21 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) at91_uarts[portnr] = pdev; } +static struct clk_lookup console_lookups = { + .con_id ="usart" , +}; +void __init at91_set_serial_console (unsigned portnr) { -if (portnr <ATMEL_MAX_UART ) +struct atmel_uart_data *pdata; + +if (portnr <ATMEL_MAX_UART ) { atmel_default_console_device = at91_uarts[portnr]; + + pdata = atmel_default_console_device->dev.platform_data; + console_lookups.clk =at91sam9rl_get_uart_clock (pdata->num); +clkdev_add (&console_lookups); + } }void __init at91_add_device_serial (void )
arch/arm/mach-at91/clock.c +15 -39
84 lines not on this page · raw message
arch/arm/mach-at91/clock.h +17 -2
@@ -6,6 +6,8 @@* published by the Free Software Foundation. */ +#include <linux/clkdev.h> +#define CLK_TYPE_PRIMARY 0x1#define CLK_TYPE_PLL 0x2#define CLK_TYPE_PROGRAMMABLE 0x4
@@ -16,8 +18,6 @@struct clk {struct list_head node;const char *name;/* unique clock name */ -const char *function;/* function of the clock */ -struct device *dev;/* device associated with function */ unsigned long rate_hz;struct clk *parent;u32 pmc_mask;
@@ -29,3 +29,18 @@ struct clk {extern int __init clk_register (struct clk *clk); +extern struct clk mck; +extern struct clk utmi_clk; + +#define CLKDEV_CON_ID (_id, _clk) \ + { \ + .con_id = _id, \ + .clk = _clk, \ + } + +#define CLKDEV_CON_DEV_ID (_con_id, _dev_id, _clk) \ + { \ + .con_id = _con_id, \ + .dev_id = _dev_id, \ + .clk = _clk, \ + }
arch/arm/mach-at91/generic.h +11 -1
@@ -8,6 +8,8 @@* published by the Free Software Foundation. */ +#include <linux/clkdev.h> +/* Processors */ extern void __init at91rm9200_initialize (unsigned long main_clock,unsigned short banks);extern void __init at91sam9260_initialize (unsigned long main_clock);
@@ -39,8 +41,16 @@ extern struct sys_timer at91x40_timer;/* Clocks */ extern int __init at91_clock_init (unsigned long main_clock); +extern struct clk *__init at91rm9200_get_uart_clock (int id); +extern struct clk *__init at91sam9260_get_uart_clock (int id); +extern struct clk *__init at91sam9261_get_uart_clock (int id); +extern struct clk *__init at91sam9263_get_uart_clock (int id); +extern struct clk *__init at91sam9rl_get_uart_clock (int id); +extern struct clk *__init at91sam9g45_get_uart_clock (int id); +extern struct clk *__init at91x40_get_uart_clock (int id); +extern struct clk *__init at91cap9_get_uart_clock (int id); +extern struct clk *__init at572d940hf_get_uart_clock (int id);struct device ; -extern void __init at91_clock_associate (const char *id,struct device *dev,const char *func);/* Power Management */ extern void at91_irq_suspend (void );
arch/arm/mach-at91/include/mach/clkdev.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __ASM_MACH_CLKDEV_H +#define __ASM_MACH_CLKDEV_H + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif
Signature · 1 line
1.7.4.1
PATCH 1/1 at91: switch to CLKDEV_LOOKUP
Hello Jean-Christophe,
Quoted 40 lines · Jean-Christophe PLAGNIOL-VILLARD
/*
* The five programmable clocks.
* You must configure pin multiplexing to bring these signals out.arch/arm/mach-at91/at572d940hf.c +15
-0@@ -234,6 +265,13 @@ static struct clk pck3 = { .id = 3, }; +static struct clk_lookup program_clocks_lookups[] = { +CLKDEV_CON_ID ("pck0" , &pck0), +CLKDEV_CON_ID ("pck1" , &pck1), +CLKDEV_CON_ID ("pck2" , &pck2), +CLKDEV_CON_ID ("pck3" , &pck3), +}; +static struct clk mAgicV_mem_clk = { .name ="mAgicV_mem_clk" , .pmc_mask =AT91_PMC_PCK4 ,@@ -241,6 +279,9 @@ static struct clk mAgicV_mem_clk = { .id = 4, }; +static struct clk_lookup mAgicV_mem_clk_lookup = +CLKDEV_CON_ID ("mAgicV_mem_clk" , &mAgicV_mem_clk); +/* HClocks */ static struct clk hck0 = { .name ="hck0" ,@@ -255,6 +296,11 @@ static struct clk hck1 = { .id = 1, }; +static struct clk_lookup hc_clocks_lookups[] = { +CLKDEV_CON_ID ("hck0" , &hck0), +CLKDEV_CON_ID ("hck1" , &hck1), +}; +static void __init at572d940hf_register_clocks (void ) {int i;
arch/arm/mach-at91/at572d940hf.c static void __init at572d940hf_register_clocks(void) · line 313
Quoted 6 lines
arch/arm/mach-at91/at572d940hf.c +3
-0@@ -262,14 +308,32 @@ static void __init at572d940hf_register_clocks(void)for (i =0 ; i <ARRAY_SIZE (periph_clocks); i++)clk_register (periph_clocks[i]); +clkdev_add_table (periph_clocks_lookups, +ARRAY_SIZE (periph_clocks_lookups)); +
Does it make sense to add a (maybe global) helper function ? la:
void __init clkdev_register_and_add_table(struct clk_lookup *cl, size_t num)
{
while (num--) {
clk_register(&cl->clk);
clkdev_add(cl);
++cl;
}
}? (The locking isn't optimal here, but I think you get the point.)
arch/arm/mach-at91/at91rm9200.c static struct clk *periph_clocks[] __initdata = {
Quoted 13 lines
arch/arm/mach-at91/at91rm9200.c +12
-0+static struct clk_lookup usart_clocks_lookups[] = { +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.0" , &mck), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.1" , &usart0_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.2" , &usart1_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.3" , &usart2_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.4" , &usart3_clk), +}; +struct clk *__init at91sam9rl_get_uart_clock (int id) +{ +if (id >=ARRAY_SIZE (usart_clocks_lookups)) +return NULL ; +return usart_clocks_lookups[id].clk;
Who is using this function? If the caller has access to the atmel_usart.<id> device, just using clk_get looks better.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 at91: switch to CLKDEV_LOOKUP
Quoted 5 lines
arch/arm/mach-at91/at572d940hf.c static void __init at572d940hf_register_clocks(void) · line 313
Quoted 3 lines
arch/arm/mach-at91/at572d940hf.c +3
-0+clkdev_add_table (periph_clocks_lookups, +ARRAY_SIZE (periph_clocks_lookups)); +Does it make sense to add a (maybe global) helper function ? la:
Quoted 8 lines
void __init clkdev_register_and_add_table(struct clk_lookup *cl, size_t num)
{
while (num--) {
clk_register(&cl->clk);
clkdev_add(cl);
++cl;
}
}agreed
Quoted 4 lines
? (The locking isn't optimal here, but I think you get the point.)
Quoted 15 lines
arch/arm/mach-at91/at91rm9200.c static struct clk *periph_clocks[] __initdata = {
Quoted 13 lines
arch/arm/mach-at91/at91rm9200.c +12
-0+static struct clk_lookup usart_clocks_lookups[] = { +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.0" , &mck), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.1" , &usart0_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.2" , &usart1_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.3" , &usart2_clk), +CLKDEV_CON_DEV_ID ("usart" ,"atmel_usart.4" , &usart3_clk), +}; +struct clk *__init at91sam9rl_get_uart_clock (int id) +{ +if (id >=ARRAY_SIZE (usart_clocks_lookups)) +return NULL ; +return usart_clocks_lookups[id].clk;Who is using this function? If the caller has access to the atmel_usart.<id> device, just using
clk_getlooks better.
no unfortunatly
the current device is not well done in the atmel_usart I'm preparing the switch to the early_plaform_device
to drop this
so this is a workarround (The chicken or the egg causality dilemma)
I need to switch to the clkdev before switch early platform device and I need the early platform device to drop this :)
And I need to update the clkdev lookup for early device too Patch will come soon
Best Regards,
J.
PATCH 1/1 at91: switch to CLKDEV_LOOKUP
In reply to Uwe Kleine-KönigQuoted 60 lines · Uwe Kleine-K?nig
Hello Jean-Christophe,
Quoted 40 lines · Jean-Christophe PLAGNIOL-VILLARD
/*
* The five programmable clocks.
* You must configure pin multiplexing to bring these signals out.arch/arm/mach-at91/at572d940hf.c +15
-0@@ -234,6 +265,13 @@ static struct clk pck3 = { .id = 3, }; +static struct clk_lookup program_clocks_lookups[] = { +CLKDEV_CON_ID ("pck0" , &pck0), +CLKDEV_CON_ID ("pck1" , &pck1), +CLKDEV_CON_ID ("pck2" , &pck2), +CLKDEV_CON_ID ("pck3" , &pck3), +}; +static struct clk mAgicV_mem_clk = { .name ="mAgicV_mem_clk" , .pmc_mask =AT91_PMC_PCK4 ,@@ -241,6 +279,9 @@ static struct clk mAgicV_mem_clk = { .id = 4, }; +static struct clk_lookup mAgicV_mem_clk_lookup = +CLKDEV_CON_ID ("mAgicV_mem_clk" , &mAgicV_mem_clk); +/* HClocks */ static struct clk hck0 = { .name ="hck0" ,@@ -255,6 +296,11 @@ static struct clk hck1 = { .id = 1, }; +static struct clk_lookup hc_clocks_lookups[] = { +CLKDEV_CON_ID ("hck0" , &hck0), +CLKDEV_CON_ID ("hck1" , &hck1), +}; +static void __init at572d940hf_register_clocks (void ) {int i;arch/arm/mach-at91/at572d940hf.c static void __init at572d940hf_register_clocks(void) · line 313
Quoted 6 lines
arch/arm/mach-at91/at572d940hf.c +3
-0@@ -262,14 +308,32 @@ static void __init at572d940hf_register_clocks(void)for (i =0 ; i <ARRAY_SIZE (periph_clocks); i++)clk_register (periph_clocks[i]); +clkdev_add_table (periph_clocks_lookups, +ARRAY_SIZE (periph_clocks_lookups)); +Does it make sense to add a (maybe global) helper function ? la:
void __init clkdev_register_and_add_table(struct clk_lookup *cl, size_t num) { while (num--) { clk_register(&cl->clk); clkdev_add(cl); ++cl; } }
Quoted 1 line
? (The locking isn't optimal here, but I think you get the point.)
Err no. clk_register() has nothing to do with clkdev, and actually clkdev has no business knowing about clk_register() at all. Note that clk_register() is not part of the clk API but a private function to the implementation.