From d477a4a2fcbf59feb617de9502ae8b862e1578ed Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:19 +0100 Subject: ARM: shmobile: multiplatform: Enable MSIOF in defconfig Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 83b0725..2a27d46 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -78,6 +78,7 @@ CONFIG_I2C_GPIO=y CONFIG_I2C_RCAR=y CONFIG_SPI=y CONFIG_SPI_RSPI=y +CONFIG_SPI_SH_MSIOF=y CONFIG_GPIO_EM=y CONFIG_GPIO_RCAR=y # CONFIG_HWMON is not set -- cgit v0.10.2 From c2e90c4b7c15fbb2215b47a23b446ba53e6dbf59 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 26 Mar 2014 14:16:19 +0900 Subject: ARM: shmobile: Include i2c-shmobile.c in shmobile_defconfig Many SoCs include I2C controller instances compatible with the i2c-shmobile.c driver. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Magnus Damm Acked-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 2a27d46..d96133a 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -75,6 +75,7 @@ CONFIG_SERIAL_SH_SCI=y CONFIG_SERIAL_SH_SCI_NR_UARTS=20 CONFIG_SERIAL_SH_SCI_CONSOLE=y CONFIG_I2C_GPIO=y +CONFIG_I2C_SH_MOBILE=y CONFIG_I2C_RCAR=y CONFIG_SPI=y CONFIG_SPI_RSPI=y -- cgit v0.10.2 From f5e1367f8f94293f098cab3e906934e535df1a94 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 26 Mar 2014 14:19:11 +0900 Subject: ARM: shmobile: Include at24.c in shmobile_defconfig The Koelsch board includes an at24-compatible EEPROM hooked up via I2C. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Magnus Damm Acked-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index d96133a..146ee70 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -43,6 +43,7 @@ CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y CONFIG_MTD=y CONFIG_MTD_M25P80=y +CONFIG_EEPROM_AT24=y CONFIG_BLK_DEV_SD=y CONFIG_ATA=y CONFIG_SATA_RCAR=y -- cgit v0.10.2 From 41551f3d7d9a37b55a6f84d77200bfe29d42c466 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Fri, 28 Mar 2014 17:54:01 +0100 Subject: ARM: shmobile: Enable USBHS gadget support in shmobile_defconfig The renesas_usbhs driver provides USB gadget support for most Renesas platforms. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Ulrich Hecht Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 146ee70..c10e626 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -103,7 +103,11 @@ CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_RCAR=y +CONFIG_USB=y CONFIG_USB_RCAR_GEN2_PHY=y +CONFIG_USB_RENESAS_USBHS=y +CONFIG_USB_GADGET=y +CONFIG_USB_RENESAS_USBHS_UDC=y CONFIG_MMC=y CONFIG_MMC_SDHI=y CONFIG_MMC_SH_MMCIF=y -- cgit v0.10.2 From 667d0f7b0e940bf36e8d12bd7d64aa0f9217b3ac Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 2 Apr 2014 18:06:24 +0900 Subject: ARM: shmobile: Enable HIGHMEM in shmobile_defconfig Many mach-shmobile hardware platforms include support for more than 1GiB of RAM. Enable HIGHMEM by default to allow use of larger amounts of memory. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index c10e626..b73a038 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -25,6 +25,7 @@ CONFIG_SCHED_MC=y CONFIG_HAVE_ARM_ARCH_TIMER=y CONFIG_NR_CPUS=8 CONFIG_AEABI=y +CONFIG_HIGHMEM=y CONFIG_ZBOOT_ROM_TEXT=0x0 CONFIG_ZBOOT_ROM_BSS=0x0 CONFIG_ARM_APPENDED_DTB=y -- cgit v0.10.2 From e4224fe8bfd955d1aea5f89f2f3ac38dc4a590fc Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 8 Apr 2014 21:37:58 +0900 Subject: ARM: shmobile: Enable VSP1 in shmobile_defconfig Both r8a7790 and r8a7791 have multiple on-chip VSP1 devices, so enable the VSP1 driver by default in the shmobile_defconfig. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index b73a038..8fb30b0 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -92,10 +92,14 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_GPIO=y CONFIG_MEDIA_SUPPORT=y CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SOC_CAMERA=y CONFIG_SOC_CAMERA_PLATFORM=y CONFIG_VIDEO_RCAR_VIN=y +CONFIG_V4L_MEM2MEM_DRIVERS=y +CONFIG_VIDEO_RENESAS_VSP1=y # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set CONFIG_VIDEO_ADV7180=y CONFIG_DRM=y -- cgit v0.10.2 From 1d59eb190e3dc575c7bbee4a163c3facd0de2ed9 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 10 Apr 2014 16:12:45 +0900 Subject: ARM: shmobile: Enable USB [EO]HCI HCD support in shmobile_defconfig The USB [EO]HCI HCD drivers provide USB host support for Renesas R-Car Gen2 platforms. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Acked-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 8fb30b0..6d6437c 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -110,6 +110,8 @@ CONFIG_SND_SOC=y CONFIG_SND_SOC_RCAR=y CONFIG_USB=y CONFIG_USB_RCAR_GEN2_PHY=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_OHCI_HCD=y CONFIG_USB_RENESAS_USBHS=y CONFIG_USB_GADGET=y CONFIG_USB_RENESAS_USBHS_UDC=y -- cgit v0.10.2 From e6597e0e19bbabfdd1983dbe79892d8ba210a180 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Mar 2014 08:36:26 +0900 Subject: ARM: shmobile: Use shmobile_clk_workaround() on Lager Convert the Lager DT reference code to use the newly introduced function shmobile_clk_workaround(). Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 440aac3..c76248b 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -18,12 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include #include #include +#include #include #include #include @@ -86,46 +85,32 @@ static void __init lager_add_du_device(void) platform_device_register_full(&info); } +/* + * This is a really crude hack to provide clkdev support to platform + * devices until they get moved to DT. + */ +static const struct clk_name clk_names[] = { + { "cmt0", NULL, "sh_cmt.0" }, + { "scifa0", NULL, "sh-sci.0" }, + { "scifa1", NULL, "sh-sci.1" }, + { "scifb0", NULL, "sh-sci.2" }, + { "scifb1", NULL, "sh-sci.3" }, + { "scifb2", NULL, "sh-sci.4" }, + { "scifa2", NULL, "sh-sci.5" }, + { "scif0", NULL, "sh-sci.6" }, + { "scif1", NULL, "sh-sci.7" }, + { "hscif0", NULL, "sh-sci.8" }, + { "hscif1", NULL, "sh-sci.9" }, + { "du0", "du.0", "rcar-du-r8a7790" }, + { "du1", "du.1", "rcar-du-r8a7790" }, + { "du2", "du.2", "rcar-du-r8a7790" }, + { "lvds0", "lvds.0", "rcar-du-r8a7790" }, + { "lvds1", "lvds.1", "rcar-du-r8a7790" }, +}; + static void __init lager_add_standard_devices(void) { - /* - * This is a really crude hack to provide clkdev support to platform - * devices until they get moved to DT. - */ - static const struct clk_name { - const char *clk; - const char *con_id; - const char *dev_id; - } clk_names[] = { - { "cmt0", NULL, "sh_cmt.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "hscif0", NULL, "sh-sci.8" }, - { "hscif1", NULL, "sh-sci.9" }, - { "du0", "du.0", "rcar-du-r8a7790" }, - { "du1", "du.1", "rcar-du-r8a7790" }, - { "du2", "du.2", "rcar-du-r8a7790" }, - { "lvds0", "lvds.0", "rcar-du-r8a7790" }, - { "lvds1", "lvds.1", "rcar-du-r8a7790" }, - }; - struct clk *clk; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(clk_names); ++i) { - clk = clk_get(NULL, clk_names[i].clk); - if (!IS_ERR(clk)) { - clk_register_clkdev(clk, clk_names[i].con_id, - clk_names[i].dev_id); - clk_put(clk); - } - } - + shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); r8a7790_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v0.10.2 From 89aff406dbc3ea3dfc008e8472181532c0c0f4ea Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Mar 2014 08:36:35 +0900 Subject: ARM: shmobile: Use shmobile_clk_workaround() on Koelsch Convert the Koelsch DT reference code to use the newly introduced function shmobile_clk_workaround(). Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a3fd302..a760f7f 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -19,12 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include #include #include +#include #include #include #include @@ -82,49 +81,35 @@ static void __init koelsch_add_du_device(void) platform_device_register_full(&info); } +/* + * This is a really crude hack to provide clkdev support to platform + * devices until they get moved to DT. + */ +static const struct clk_name clk_names[] = { + { "cmt0", NULL, "sh_cmt.0" }, + { "scifa0", NULL, "sh-sci.0" }, + { "scifa1", NULL, "sh-sci.1" }, + { "scifb0", NULL, "sh-sci.2" }, + { "scifb1", NULL, "sh-sci.3" }, + { "scifb2", NULL, "sh-sci.4" }, + { "scifa2", NULL, "sh-sci.5" }, + { "scif0", NULL, "sh-sci.6" }, + { "scif1", NULL, "sh-sci.7" }, + { "scif2", NULL, "sh-sci.8" }, + { "scif3", NULL, "sh-sci.9" }, + { "scif4", NULL, "sh-sci.10" }, + { "scif5", NULL, "sh-sci.11" }, + { "scifa3", NULL, "sh-sci.12" }, + { "scifa4", NULL, "sh-sci.13" }, + { "scifa5", NULL, "sh-sci.14" }, + { "du0", "du.0", "rcar-du-r8a7791" }, + { "du1", "du.1", "rcar-du-r8a7791" }, + { "lvds0", "lvds.0", "rcar-du-r8a7791" }, +}; + static void __init koelsch_add_standard_devices(void) { - /* - * This is a really crude hack to provide clkdev support to the CMT and - * DU devices until they get moved to DT. - */ - static const struct clk_name { - const char *clk; - const char *con_id; - const char *dev_id; - } clk_names[] = { - { "cmt0", NULL, "sh_cmt.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "scif2", NULL, "sh-sci.8" }, - { "scif3", NULL, "sh-sci.9" }, - { "scif4", NULL, "sh-sci.10" }, - { "scif5", NULL, "sh-sci.11" }, - { "scifa3", NULL, "sh-sci.12" }, - { "scifa4", NULL, "sh-sci.13" }, - { "scifa5", NULL, "sh-sci.14" }, - { "du0", "du.0", "rcar-du-r8a7791" }, - { "du1", "du.1", "rcar-du-r8a7791" }, - { "lvds0", "lvds.0", "rcar-du-r8a7791" }, - }; - struct clk *clk; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(clk_names); ++i) { - clk = clk_get(NULL, clk_names[i].clk); - if (!IS_ERR(clk)) { - clk_register_clkdev(clk, clk_names[i].con_id, - clk_names[i].dev_id); - clk_put(clk); - } - } - + shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); r8a7791_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v0.10.2 From f6f98b3e44ea408e33eb4d695a4225cc11210cdb Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 13 Mar 2014 15:29:57 +0900 Subject: ARM: shmobile: koelsch: Annotate clk_names with __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a760f7f..1e6a436 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -85,7 +85,7 @@ static void __init koelsch_add_du_device(void) * This is a really crude hack to provide clkdev support to platform * devices until they get moved to DT. */ -static const struct clk_name clk_names[] = { +static const struct clk_name clk_names[] __initconst = { { "cmt0", NULL, "sh_cmt.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, -- cgit v0.10.2 From f71c77286b2c1f809a85e8e42df88eb2ec132e5f Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 13 Mar 2014 15:29:58 +0900 Subject: ARM: shmobile: lager: Annotate clk_names with __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index c76248b..7ff395e 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -89,7 +89,7 @@ static void __init lager_add_du_device(void) * This is a really crude hack to provide clkdev support to platform * devices until they get moved to DT. */ -static const struct clk_name clk_names[] = { +static const struct clk_name clk_names[] __initconst = { { "cmt0", NULL, "sh_cmt.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, -- cgit v0.10.2 From 53cf0cf7ba2ef785b339826a0765bb6b1756adeb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 13 Mar 2014 15:29:30 +0100 Subject: ARM: shmobile: koelsch-reference: Work around core clock issues Due to issues with runtime PM clock management, clocks not explicitly managed by their drivers may not be enabled at all, or be inadvertently disabled by the clk_disable_unused() late initcall. Until this is fixed, add a temporary workaround, calling shmobile_clk_workaround() with enable == true. For now this enables the clocks for: ether, i2c2, msiof0, qspi_mod, and thermal. More clocks can be added if needed. Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index 1e6a436..a39114a 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -107,9 +107,21 @@ static const struct clk_name clk_names[] __initconst = { { "lvds0", "lvds.0", "rcar-du-r8a7791" }, }; +/* + * This is a really crude hack to work around core platform clock issues + */ +static const struct clk_name clk_enables[] = { + { "ether", NULL, "ee700000.ethernet" }, + { "i2c2", NULL, "e6530000.i2c" }, + { "msiof0", NULL, "e6e20000.spi" }, + { "qspi_mod", NULL, "e6b10000.spi" }, + { "thermal", NULL, "e61f0000.thermal" }, +}; + static void __init koelsch_add_standard_devices(void) { shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); + shmobile_clk_workaround(clk_enables, ARRAY_SIZE(clk_enables), true); r8a7791_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v0.10.2 From 9e7b83c221cc257f4dc37acc82bbcb80627c0ab9 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 17 Mar 2014 11:19:56 +0900 Subject: ARM: shmobile: koelsch-reference: Annotate clk_enables as __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a39114a..63117d5 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -110,7 +110,7 @@ static const struct clk_name clk_names[] __initconst = { /* * This is a really crude hack to work around core platform clock issues */ -static const struct clk_name clk_enables[] = { +static const struct clk_name clk_enables[] __initconst = { { "ether", NULL, "ee700000.ethernet" }, { "i2c2", NULL, "e6530000.i2c" }, { "msiof0", NULL, "e6e20000.spi" }, -- cgit v0.10.2 From aa5de826afe747c353162bbc116c63ab5335f91c Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 17 Mar 2014 11:18:56 +0900 Subject: ARM: shmobile: lager-reference: Work around core clock issues Due to issues with runtime PM clock management, clocks not explicitly managed by their drivers may not be enabled at all, or be inadvertently disabled by the clk_disable_unused() late initcall. Until this is fixed, add a temporary workaround, calling shmobile_clk_workaround() with enable == true. For now this enables the clocks for: ether, msiof1, qspi_mod, and thermal. More clocks can be added if needed. Based on work for the koelsch board by Geert Uytterhoeven. Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 7ff395e..313118c 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -108,9 +108,20 @@ static const struct clk_name clk_names[] __initconst = { { "lvds1", "lvds.1", "rcar-du-r8a7790" }, }; +/* + * This is a really crude hack to work around core platform clock issues + */ +static const struct clk_name clk_enables[] __initconst = { + { "ether", NULL, "ee700000.ethernet" }, + { "msiof1", NULL, "e6e10000.spi" }, + { "qspi_mod", NULL, "e6b10000.spi" }, + { "thermal", NULL, "e61f0000.thermal" }, +}; + static void __init lager_add_standard_devices(void) { shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); + shmobile_clk_workaround(clk_enables, ARRAY_SIZE(clk_enables), true); r8a7790_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v0.10.2 From f98b55d730492e664fb2649bd7054fec0fe81acd Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 21:52:47 +0900 Subject: ARM: shmobile: Add Lager clock workarounds for SDHI and MMCIF Add MMCIF1, SDHI0 and SDHI2 to the clock workaround list for Lager multiplatform. Without these additional lines wakeup from Suspend-to-RAM never happens. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 313118c..1eb48cf 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -114,7 +114,10 @@ static const struct clk_name clk_names[] __initconst = { static const struct clk_name clk_enables[] __initconst = { { "ether", NULL, "ee700000.ethernet" }, { "msiof1", NULL, "e6e10000.spi" }, + { "mmcif1", NULL, "ee220000.mmc" }, { "qspi_mod", NULL, "e6b10000.spi" }, + { "sdhi0", NULL, "ee100000.sd" }, + { "sdhi2", NULL, "ee140000.sd" }, { "thermal", NULL, "e61f0000.thermal" }, }; -- cgit v0.10.2 From f278ea78beeb17ea07d11fc3372d4f98c94dcf46 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 21:54:34 +0900 Subject: ARM: shmobile: Add Koelsch clock workarounds for SDHI Add SDHI0, SDHI1 and SDHI2 to the clock workaround list for Koelsch multiplatform. Without these additional lines wakeup from Suspend-to-RAM never happens. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index 63117d5..941f8b3 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -115,6 +115,9 @@ static const struct clk_name clk_enables[] __initconst = { { "i2c2", NULL, "e6530000.i2c" }, { "msiof0", NULL, "e6e20000.spi" }, { "qspi_mod", NULL, "e6b10000.spi" }, + { "sdhi0", NULL, "ee100000.sd" }, + { "sdhi1", NULL, "ee140000.sd" }, + { "sdhi2", NULL, "ee160000.sd" }, { "thermal", NULL, "e61f0000.thermal" }, }; -- cgit v0.10.2 From 115897dab004f580fc8b4c6bab057940ccb64989 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:56:57 -0700 Subject: ARM: shmobile: bockw: remove old style audio clock Current audio clock didn't have dependency to device/driver, but, it was not good design for DT support. To avoid branch merge conflict issue, it is using this load map, and this patch is 3) part. 1) add new style clock in platform 2) add new style clock method in driver 3) remove old tyle clock from platform Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index b4122f8..1aca107 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c @@ -591,6 +591,7 @@ static void __init bockw_init(void) { void __iomem *base; struct clk *clk; + struct platform_device *pdev; int i; r8a7778_clock_init(); @@ -673,9 +674,6 @@ static void __init bockw_init(void) } /* for Audio */ - clk = clk_get(NULL, "audio_clk_b"); - clk_set_rate(clk, 24576000); - clk_put(clk); rsnd_codec_power(5, 1); /* enable ak4642 */ platform_device_register_simple( @@ -684,11 +682,15 @@ static void __init bockw_init(void) platform_device_register_simple( "ak4554-adc-dac", 1, NULL, 0); - platform_device_register_resndata( + pdev = platform_device_register_resndata( &platform_bus, "rcar_sound", -1, rsnd_resources, ARRAY_SIZE(rsnd_resources), &rsnd_info, sizeof(rsnd_info)); + clk = clk_get(&pdev->dev, "clk_b"); + clk_set_rate(clk, 24576000); + clk_put(clk); + for (i = 0; i < ARRAY_SIZE(rsnd_card_info); i++) { struct platform_device_info cardinfo = { .parent = &platform_bus, -- cgit v0.10.2 From a3f50d1bdd47dfa07cb42f7d954739389664f166 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:57:05 -0700 Subject: ARM: shmobile: bockw: switch to use dai info for R-Car sound Now, R-Car sound driver supports dai info settings. switch to use it Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index 1aca107..f444be2 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c @@ -345,24 +345,39 @@ static struct rsnd_ssi_platform_info rsnd_ssi[] = { RSND_SSI_UNUSED, /* SSI 0 */ RSND_SSI_UNUSED, /* SSI 1 */ RSND_SSI_UNUSED, /* SSI 2 */ - RSND_SSI_SET(1, HPBDMA_SLAVE_HPBIF3_TX, gic_iid(0x85), RSND_SSI_PLAY), - RSND_SSI_SET(2, HPBDMA_SLAVE_HPBIF4_RX, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE), - RSND_SSI_SET(0, HPBDMA_SLAVE_HPBIF5_TX, gic_iid(0x86), RSND_SSI_PLAY), - RSND_SSI_SET(0, HPBDMA_SLAVE_HPBIF6_RX, gic_iid(0x86), 0), - RSND_SSI_SET(3, HPBDMA_SLAVE_HPBIF7_TX, gic_iid(0x86), RSND_SSI_PLAY), - RSND_SSI_SET(4, HPBDMA_SLAVE_HPBIF8_RX, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(HPBDMA_SLAVE_HPBIF3_TX, gic_iid(0x85), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF4_RX, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(HPBDMA_SLAVE_HPBIF5_TX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF6_RX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF7_TX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF8_RX, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE), }; -static struct rsnd_scu_platform_info rsnd_scu[9] = { - { .flags = 0, }, /* SRU 0 */ - { .flags = 0, }, /* SRU 1 */ - { .flags = 0, }, /* SRU 2 */ - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, +static struct rsnd_src_platform_info rsnd_src[9] = { + RSND_SRC_UNUSED, /* SRU 0 */ + RSND_SRC_UNUSED, /* SRU 1 */ + RSND_SRC_UNUSED, /* SRU 2 */ + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), +}; + +static struct rsnd_dai_platform_info rsnd_dai[] = { + { + .playback = { .ssi = &rsnd_ssi[5], .src = &rsnd_src[5] }, + .capture = { .ssi = &rsnd_ssi[6], .src = &rsnd_src[6] }, + }, { + .playback = { .ssi = &rsnd_ssi[3], .src = &rsnd_src[3] }, + }, { + .capture = { .ssi = &rsnd_ssi[4], .src = &rsnd_src[4] }, + }, { + .playback = { .ssi = &rsnd_ssi[7], .src = &rsnd_src[7] }, + }, { + .capture = { .ssi = &rsnd_ssi[8], .src = &rsnd_src[8] }, + }, }; enum { @@ -437,8 +452,10 @@ static struct rcar_snd_info rsnd_info = { .flags = RSND_GEN1, .ssi_info = rsnd_ssi, .ssi_info_nr = ARRAY_SIZE(rsnd_ssi), - .scu_info = rsnd_scu, - .scu_info_nr = ARRAY_SIZE(rsnd_scu), + .src_info = rsnd_src, + .src_info_nr = ARRAY_SIZE(rsnd_src), + .dai_info = rsnd_dai, + .dai_info_nr = ARRAY_SIZE(rsnd_dai), .start = rsnd_start, .stop = rsnd_stop, }; -- cgit v0.10.2 From 50f359d7389be354b46d781f3b234d3008d20f2f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:57:12 -0700 Subject: ARM: shmobile: lager: switch to use dai info for R-Car sound Now, R-Car sound driver supports dai info settings. switch to use it Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index f0104bf..6af09e1 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -567,20 +567,27 @@ static struct resource rsnd_resources[] __initdata = { }; static struct rsnd_ssi_platform_info rsnd_ssi[] = { - RSND_SSI_SET(0, 0, gic_spi(370), RSND_SSI_PLAY), - RSND_SSI_SET(0, 0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(0, gic_spi(370), 0), + RSND_SSI(0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), }; -static struct rsnd_scu_platform_info rsnd_scu[2] = { +static struct rsnd_src_platform_info rsnd_src[2] = { /* no member at this point */ }; +static struct rsnd_dai_platform_info rsnd_dai = { + .playback = { .ssi = &rsnd_ssi[0], }, + .capture = { .ssi = &rsnd_ssi[1], }, +}; + static struct rcar_snd_info rsnd_info = { .flags = RSND_GEN2, .ssi_info = rsnd_ssi, .ssi_info_nr = ARRAY_SIZE(rsnd_ssi), - .scu_info = rsnd_scu, - .scu_info_nr = ARRAY_SIZE(rsnd_scu), + .src_info = rsnd_src, + .src_info_nr = ARRAY_SIZE(rsnd_src), + .dai_info = &rsnd_dai, + .dai_info_nr = 1, }; static struct asoc_simple_card_info rsnd_card_info = { -- cgit v0.10.2 From 4d4a0ff30c39b82c1dc549f2cc7a62b514431e64 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:35:57 +0200 Subject: ARM: shmobile: koelsch legacy: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c index 5a034ff..a12a9d3 100644 --- a/arch/arm/mach-shmobile/board-koelsch.c +++ b/arch/arm/mach-shmobile/board-koelsch.c @@ -216,7 +216,7 @@ static const struct spi_board_info spi_info[] __initconst = { { .modalias = "m25p80", .platform_data = &spi_flash_data, - .mode = SPI_MODE_0, + .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, .max_speed_hz = 30000000, .bus_num = 0, .chip_select = 0, -- cgit v0.10.2 From a09b2f0ba170dc89a67d6c4c4f027b37a085dad9 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:35:59 +0200 Subject: ARM: shmobile: lager legacy: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 6af09e1..6c4fcfe 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -325,12 +325,12 @@ static const struct rspi_plat_data qspi_pdata __initconst = { static const struct spi_board_info spi_info[] __initconst = { { - .modalias = "m25p80", - .platform_data = &spi_flash_data, - .mode = SPI_MODE_0, - .max_speed_hz = 30000000, - .bus_num = 0, - .chip_select = 0, + .modalias = "m25p80", + .platform_data = &spi_flash_data, + .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, + .max_speed_hz = 30000000, + .bus_num = 0, + .chip_select = 0, }, }; -- cgit v0.10.2 From dc2eadece70089430f12e4ed6bb1a4421cf3d6f4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_cmt: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 0b1836a..a3103b8 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -728,12 +728,6 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) goto err1; } - /* request irq using setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_cmt_interrupt; - p->irqaction.dev_id = p; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "cmt_fck"); if (IS_ERR(p->clk)) { @@ -786,7 +780,9 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) } p->cs_enabled = false; - ret = setup_irq(irq, &p->irqaction); + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); goto err4; -- cgit v0.10.2 From 7269f9333292586f2378c5321b40a8d3779c4653 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 15:29:19 +0100 Subject: clocksource: sh_cmt: Split channel fields from sh_cmt_priv Create a new sh_cmt_channel structure to hold the channel-specific field in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index a3103b8..351b3ca 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -35,15 +35,10 @@ #include #include -struct sh_cmt_priv { - void __iomem *mapbase; - void __iomem *mapbase_str; - struct clk *clk; - unsigned long width; /* 16 or 32 bit version of hardware block */ - unsigned long overflow_bit; - unsigned long clear_bits; - struct irqaction irqaction; - struct platform_device *pdev; +struct sh_cmt_priv; + +struct sh_cmt_channel { + struct sh_cmt_priv *cmt; unsigned long flags; unsigned long match_value; @@ -55,6 +50,20 @@ struct sh_cmt_priv { struct clocksource cs; unsigned long total_cycles; bool cs_enabled; +}; + +struct sh_cmt_priv { + struct platform_device *pdev; + + void __iomem *mapbase; + void __iomem *mapbase_str; + struct clk *clk; + + struct sh_cmt_channel channel; + + unsigned long width; /* 16 or 32 bit version of hardware block */ + unsigned long overflow_bit; + unsigned long clear_bits; /* callbacks for CMSTR and CMCSR access */ unsigned long (*read_control)(void __iomem *base, unsigned long offs); @@ -114,60 +123,60 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, #define CMCNT 1 /* channel register */ #define CMCOR 2 /* channel register */ -static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return p->read_control(p->mapbase_str, 0); + return ch->cmt->read_control(ch->cmt->mapbase_str, 0); } -static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return p->read_control(p->mapbase, CMCSR); + return ch->cmt->read_control(ch->cmt->mapbase, CMCSR); } -static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return p->read_count(p->mapbase, CMCNT); + return ch->cmt->read_count(ch->cmt->mapbase, CMCNT); } -static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - p->write_control(p->mapbase_str, 0, value); + ch->cmt->write_control(ch->cmt->mapbase_str, 0, value); } -static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - p->write_control(p->mapbase, CMCSR, value); + ch->cmt->write_control(ch->cmt->mapbase, CMCSR, value); } -static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - p->write_count(p->mapbase, CMCNT, value); + ch->cmt->write_count(ch->cmt->mapbase, CMCNT, value); } -static inline void sh_cmt_write_cmcor(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - p->write_count(p->mapbase, CMCOR, value); + ch->cmt->write_count(ch->cmt->mapbase, CMCOR, value); } -static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p, +static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, int *has_wrapped) { unsigned long v1, v2, v3; int o1, o2; - o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; /* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { o2 = o1; - v1 = sh_cmt_read_cmcnt(p); - v2 = sh_cmt_read_cmcnt(p); - v3 = sh_cmt_read_cmcnt(p); - o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit; + v1 = sh_cmt_read_cmcnt(ch); + v2 = sh_cmt_read_cmcnt(ch); + v3 = sh_cmt_read_cmcnt(ch); + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); @@ -177,52 +186,52 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p, static DEFINE_RAW_SPINLOCK(sh_cmt_lock); -static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start) +static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->cmt->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_cmt_lock, flags); - value = sh_cmt_read_cmstr(p); + value = sh_cmt_read_cmstr(ch); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_cmt_write_cmstr(p, value); + sh_cmt_write_cmstr(ch, value); raw_spin_unlock_irqrestore(&sh_cmt_lock, flags); } -static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) +static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) { int k, ret; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->cmt->pdev->dev); + dev_pm_syscore_device(&ch->cmt->pdev->dev, true); /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->cmt->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->cmt->pdev->dev, "cannot enable clock\n"); goto err0; } /* make sure channel is disabled */ - sh_cmt_start_stop_ch(p, 0); + sh_cmt_start_stop_ch(ch, 0); /* configure channel, periodic mode and maximum timeout */ - if (p->width == 16) { - *rate = clk_get_rate(p->clk) / 512; - sh_cmt_write_cmcsr(p, 0x43); + if (ch->cmt->width == 16) { + *rate = clk_get_rate(ch->cmt->clk) / 512; + sh_cmt_write_cmcsr(ch, 0x43); } else { - *rate = clk_get_rate(p->clk) / 8; - sh_cmt_write_cmcsr(p, 0x01a4); + *rate = clk_get_rate(ch->cmt->clk) / 8; + sh_cmt_write_cmcsr(ch, 0x01a4); } - sh_cmt_write_cmcor(p, 0xffffffff); - sh_cmt_write_cmcnt(p, 0); + sh_cmt_write_cmcor(ch, 0xffffffff); + sh_cmt_write_cmcnt(ch, 0); /* * According to the sh73a0 user's manual, as CMCNT can be operated @@ -236,41 +245,41 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) * take RCLKx2 at maximum. */ for (k = 0; k < 100; k++) { - if (!sh_cmt_read_cmcnt(p)) + if (!sh_cmt_read_cmcnt(ch)) break; udelay(1); } - if (sh_cmt_read_cmcnt(p)) { - dev_err(&p->pdev->dev, "cannot clear CMCNT\n"); + if (sh_cmt_read_cmcnt(ch)) { + dev_err(&ch->cmt->pdev->dev, "cannot clear CMCNT\n"); ret = -ETIMEDOUT; goto err1; } /* enable channel */ - sh_cmt_start_stop_ch(p, 1); + sh_cmt_start_stop_ch(ch, 1); return 0; err1: /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->cmt->clk); err0: return ret; } -static void sh_cmt_disable(struct sh_cmt_priv *p) +static void sh_cmt_disable(struct sh_cmt_channel *ch) { /* disable channel */ - sh_cmt_start_stop_ch(p, 0); + sh_cmt_start_stop_ch(ch, 0); /* disable interrupts in CMT block */ - sh_cmt_write_cmcsr(p, 0); + sh_cmt_write_cmcsr(ch, 0); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->cmt->clk); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->cmt->pdev->dev, false); + pm_runtime_put(&ch->cmt->pdev->dev); } /* private flags */ @@ -280,24 +289,24 @@ static void sh_cmt_disable(struct sh_cmt_priv *p) #define FLAG_SKIPEVENT (1 << 3) #define FLAG_IRQCONTEXT (1 << 4) -static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, +static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, int absolute) { unsigned long new_match; - unsigned long value = p->next_match_value; + unsigned long value = ch->next_match_value; unsigned long delay = 0; unsigned long now = 0; int has_wrapped; - now = sh_cmt_get_counter(p, &has_wrapped); - p->flags |= FLAG_REPROGRAM; /* force reprogram */ + now = sh_cmt_get_counter(ch, &has_wrapped); + ch->flags |= FLAG_REPROGRAM; /* force reprogram */ if (has_wrapped) { /* we're competing with the interrupt handler. * -> let the interrupt handler reprogram the timer. * -> interrupt number two handles the event. */ - p->flags |= FLAG_SKIPEVENT; + ch->flags |= FLAG_SKIPEVENT; return; } @@ -309,20 +318,20 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * but don't save the new match value yet. */ new_match = now + value + delay; - if (new_match > p->max_match_value) - new_match = p->max_match_value; + if (new_match > ch->max_match_value) + new_match = ch->max_match_value; - sh_cmt_write_cmcor(p, new_match); + sh_cmt_write_cmcor(ch, new_match); - now = sh_cmt_get_counter(p, &has_wrapped); - if (has_wrapped && (new_match > p->match_value)) { + now = sh_cmt_get_counter(ch, &has_wrapped); + if (has_wrapped && (new_match > ch->match_value)) { /* we are changing to a greater match value, * so this wrap must be caused by the counter * matching the old value. * -> first interrupt reprograms the timer. * -> interrupt number two handles the event. */ - p->flags |= FLAG_SKIPEVENT; + ch->flags |= FLAG_SKIPEVENT; break; } @@ -333,7 +342,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * -> save programmed match value. * -> let isr handle the event. */ - p->match_value = new_match; + ch->match_value = new_match; break; } @@ -344,7 +353,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * -> save programmed match value. * -> let isr handle the event. */ - p->match_value = new_match; + ch->match_value = new_match; break; } @@ -360,138 +369,138 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, delay = 1; if (!delay) - dev_warn(&p->pdev->dev, "too long delay\n"); + dev_warn(&ch->cmt->pdev->dev, "too long delay\n"); } while (delay); } -static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) +static void __sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { - if (delta > p->max_match_value) - dev_warn(&p->pdev->dev, "delta out of range\n"); + if (delta > ch->max_match_value) + dev_warn(&ch->cmt->pdev->dev, "delta out of range\n"); - p->next_match_value = delta; - sh_cmt_clock_event_program_verify(p, 0); + ch->next_match_value = delta; + sh_cmt_clock_event_program_verify(ch, 0); } -static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) +static void sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { unsigned long flags; - raw_spin_lock_irqsave(&p->lock, flags); - __sh_cmt_set_next(p, delta); - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); + __sh_cmt_set_next(ch, delta); + raw_spin_unlock_irqrestore(&ch->lock, flags); } static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id) { - struct sh_cmt_priv *p = dev_id; + struct sh_cmt_channel *ch = dev_id; /* clear flags */ - sh_cmt_write_cmcsr(p, sh_cmt_read_cmcsr(p) & p->clear_bits); + sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & ch->cmt->clear_bits); /* update clock source counter to begin with if enabled * the wrap flag should be cleared by the timer specific * isr before we end up here. */ - if (p->flags & FLAG_CLOCKSOURCE) - p->total_cycles += p->match_value + 1; + if (ch->flags & FLAG_CLOCKSOURCE) + ch->total_cycles += ch->match_value + 1; - if (!(p->flags & FLAG_REPROGRAM)) - p->next_match_value = p->max_match_value; + if (!(ch->flags & FLAG_REPROGRAM)) + ch->next_match_value = ch->max_match_value; - p->flags |= FLAG_IRQCONTEXT; + ch->flags |= FLAG_IRQCONTEXT; - if (p->flags & FLAG_CLOCKEVENT) { - if (!(p->flags & FLAG_SKIPEVENT)) { - if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) { - p->next_match_value = p->max_match_value; - p->flags |= FLAG_REPROGRAM; + if (ch->flags & FLAG_CLOCKEVENT) { + if (!(ch->flags & FLAG_SKIPEVENT)) { + if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) { + ch->next_match_value = ch->max_match_value; + ch->flags |= FLAG_REPROGRAM; } - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); } } - p->flags &= ~FLAG_SKIPEVENT; + ch->flags &= ~FLAG_SKIPEVENT; - if (p->flags & FLAG_REPROGRAM) { - p->flags &= ~FLAG_REPROGRAM; - sh_cmt_clock_event_program_verify(p, 1); + if (ch->flags & FLAG_REPROGRAM) { + ch->flags &= ~FLAG_REPROGRAM; + sh_cmt_clock_event_program_verify(ch, 1); - if (p->flags & FLAG_CLOCKEVENT) - if ((p->ced.mode == CLOCK_EVT_MODE_SHUTDOWN) - || (p->match_value == p->next_match_value)) - p->flags &= ~FLAG_REPROGRAM; + if (ch->flags & FLAG_CLOCKEVENT) + if ((ch->ced.mode == CLOCK_EVT_MODE_SHUTDOWN) + || (ch->match_value == ch->next_match_value)) + ch->flags &= ~FLAG_REPROGRAM; } - p->flags &= ~FLAG_IRQCONTEXT; + ch->flags &= ~FLAG_IRQCONTEXT; return IRQ_HANDLED; } -static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag) +static int sh_cmt_start(struct sh_cmt_channel *ch, unsigned long flag) { int ret = 0; unsigned long flags; - raw_spin_lock_irqsave(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); - if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) - ret = sh_cmt_enable(p, &p->rate); + if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) + ret = sh_cmt_enable(ch, &ch->rate); if (ret) goto out; - p->flags |= flag; + ch->flags |= flag; /* setup timeout if no clockevent */ - if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT))) - __sh_cmt_set_next(p, p->max_match_value); + if ((flag == FLAG_CLOCKSOURCE) && (!(ch->flags & FLAG_CLOCKEVENT))) + __sh_cmt_set_next(ch, ch->max_match_value); out: - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_unlock_irqrestore(&ch->lock, flags); return ret; } -static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag) +static void sh_cmt_stop(struct sh_cmt_channel *ch, unsigned long flag) { unsigned long flags; unsigned long f; - raw_spin_lock_irqsave(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); - f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE); - p->flags &= ~flag; + f = ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE); + ch->flags &= ~flag; - if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) - sh_cmt_disable(p); + if (f && !(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) + sh_cmt_disable(ch); /* adjust the timeout to maximum if only clocksource left */ - if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE)) - __sh_cmt_set_next(p, p->max_match_value); + if ((flag == FLAG_CLOCKEVENT) && (ch->flags & FLAG_CLOCKSOURCE)) + __sh_cmt_set_next(ch, ch->max_match_value); - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_unlock_irqrestore(&ch->lock, flags); } -static struct sh_cmt_priv *cs_to_sh_cmt(struct clocksource *cs) +static struct sh_cmt_channel *cs_to_sh_cmt(struct clocksource *cs) { - return container_of(cs, struct sh_cmt_priv, cs); + return container_of(cs, struct sh_cmt_channel, cs); } static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); unsigned long flags, raw; unsigned long value; int has_wrapped; - raw_spin_lock_irqsave(&p->lock, flags); - value = p->total_cycles; - raw = sh_cmt_get_counter(p, &has_wrapped); + raw_spin_lock_irqsave(&ch->lock, flags); + value = ch->total_cycles; + raw = sh_cmt_get_counter(ch, &has_wrapped); if (unlikely(has_wrapped)) - raw += p->match_value + 1; - raw_spin_unlock_irqrestore(&p->lock, flags); + raw += ch->match_value + 1; + raw_spin_unlock_irqrestore(&ch->lock, flags); return value + raw; } @@ -499,50 +508,50 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) static int sh_cmt_clocksource_enable(struct clocksource *cs) { int ret; - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - WARN_ON(p->cs_enabled); + WARN_ON(ch->cs_enabled); - p->total_cycles = 0; + ch->total_cycles = 0; - ret = sh_cmt_start(p, FLAG_CLOCKSOURCE); + ret = sh_cmt_start(ch, FLAG_CLOCKSOURCE); if (!ret) { - __clocksource_updatefreq_hz(cs, p->rate); - p->cs_enabled = true; + __clocksource_updatefreq_hz(cs, ch->rate); + ch->cs_enabled = true; } return ret; } static void sh_cmt_clocksource_disable(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - WARN_ON(!p->cs_enabled); + WARN_ON(!ch->cs_enabled); - sh_cmt_stop(p, FLAG_CLOCKSOURCE); - p->cs_enabled = false; + sh_cmt_stop(ch, FLAG_CLOCKSOURCE); + ch->cs_enabled = false; } static void sh_cmt_clocksource_suspend(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - sh_cmt_stop(p, FLAG_CLOCKSOURCE); - pm_genpd_syscore_poweroff(&p->pdev->dev); + sh_cmt_stop(ch, FLAG_CLOCKSOURCE); + pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); } static void sh_cmt_clocksource_resume(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - pm_genpd_syscore_poweron(&p->pdev->dev); - sh_cmt_start(p, FLAG_CLOCKSOURCE); + pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); + sh_cmt_start(ch, FLAG_CLOCKSOURCE); } -static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, +static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, char *name, unsigned long rating) { - struct clocksource *cs = &p->cs; + struct clocksource *cs = &ch->cs; cs->name = name; cs->rating = rating; @@ -554,47 +563,47 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&p->pdev->dev, "used as clock source\n"); + dev_info(&ch->cmt->pdev->dev, "used as clock source\n"); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); return 0; } -static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced) +static struct sh_cmt_channel *ced_to_sh_cmt(struct clock_event_device *ced) { - return container_of(ced, struct sh_cmt_priv, ced); + return container_of(ced, struct sh_cmt_channel, ced); } -static void sh_cmt_clock_event_start(struct sh_cmt_priv *p, int periodic) +static void sh_cmt_clock_event_start(struct sh_cmt_channel *ch, int periodic) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; - sh_cmt_start(p, FLAG_CLOCKEVENT); + sh_cmt_start(ch, FLAG_CLOCKEVENT); /* TODO: calculate good shift from rate and counter bit width */ ced->shift = 32; - ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift); - ced->max_delta_ns = clockevent_delta2ns(p->max_match_value, ced); + ced->mult = div_sc(ch->rate, NSEC_PER_SEC, ced->shift); + ced->max_delta_ns = clockevent_delta2ns(ch->max_match_value, ced); ced->min_delta_ns = clockevent_delta2ns(0x1f, ced); if (periodic) - sh_cmt_set_next(p, ((p->rate + HZ/2) / HZ) - 1); + sh_cmt_set_next(ch, ((ch->rate + HZ/2) / HZ) - 1); else - sh_cmt_set_next(p, p->max_match_value); + sh_cmt_set_next(ch, ch->max_match_value); } static void sh_cmt_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: case CLOCK_EVT_MODE_ONESHOT: - sh_cmt_stop(p, FLAG_CLOCKEVENT); + sh_cmt_stop(ch, FLAG_CLOCKEVENT); break; default: break; @@ -602,16 +611,18 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_cmt_clock_event_start(p, 1); + dev_info(&ch->cmt->pdev->dev, + "used for periodic clock events\n"); + sh_cmt_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: - dev_info(&p->pdev->dev, "used for oneshot clock events\n"); - sh_cmt_clock_event_start(p, 0); + dev_info(&ch->cmt->pdev->dev, + "used for oneshot clock events\n"); + sh_cmt_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_SHUTDOWN: case CLOCK_EVT_MODE_UNUSED: - sh_cmt_stop(p, FLAG_CLOCKEVENT); + sh_cmt_stop(ch, FLAG_CLOCKEVENT); break; default: break; @@ -621,37 +632,37 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, static int sh_cmt_clock_event_next(unsigned long delta, struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT); - if (likely(p->flags & FLAG_IRQCONTEXT)) - p->next_match_value = delta - 1; + if (likely(ch->flags & FLAG_IRQCONTEXT)) + ch->next_match_value = delta - 1; else - sh_cmt_set_next(p, delta - 1); + sh_cmt_set_next(ch, delta - 1); return 0; } static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - pm_genpd_syscore_poweroff(&p->pdev->dev); - clk_unprepare(p->clk); + pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); + clk_unprepare(ch->cmt->clk); } static void sh_cmt_clock_event_resume(struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - clk_prepare(p->clk); - pm_genpd_syscore_poweron(&p->pdev->dev); + clk_prepare(ch->cmt->clk); + pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); } -static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, +static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; memset(ced, 0, sizeof(*ced)); @@ -665,19 +676,19 @@ static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, ced->suspend = sh_cmt_clock_event_suspend; ced->resume = sh_cmt_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->cmt->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); } -static int sh_cmt_register(struct sh_cmt_priv *p, char *name, +static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { if (clockevent_rating) - sh_cmt_register_clockevent(p, name, clockevent_rating); + sh_cmt_register_clockevent(ch, name, clockevent_rating); if (clocksource_rating) - sh_cmt_register_clocksource(p, name, clocksource_rating); + sh_cmt_register_clocksource(ch, name, clocksource_rating); return 0; } @@ -685,6 +696,7 @@ static int sh_cmt_register(struct sh_cmt_priv *p, char *name, static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; + struct sh_cmt_channel *ch = &p->channel; struct resource *res, *res2; int irq, ret; ret = -ENXIO; @@ -763,26 +775,27 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) p->clear_bits = ~0xc000; } - if (p->width == (sizeof(p->max_match_value) * 8)) - p->max_match_value = ~0; + if (p->width == (sizeof(ch->max_match_value) * 8)) + ch->max_match_value = ~0; else - p->max_match_value = (1 << p->width) - 1; + ch->max_match_value = (1 << p->width) - 1; - p->match_value = p->max_match_value; - raw_spin_lock_init(&p->lock); + ch->cmt = p; + ch->match_value = ch->max_match_value; + raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(p, (char *)dev_name(&p->pdev->dev), + ret = sh_cmt_register(ch, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { dev_err(&p->pdev->dev, "registration failed\n"); goto err4; } - p->cs_enabled = false; + ch->cs_enabled = false; ret = request_irq(irq, sh_cmt_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&p->pdev->dev), ch); if (ret) { dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); goto err4; -- cgit v0.10.2 From 2653caf4381f9adeec8c18dfec21ec3c855d801c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Rename struct sh_cmt_priv to sh_cmt_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 351b3ca..604199a 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -35,10 +35,10 @@ #include #include -struct sh_cmt_priv; +struct sh_cmt_device; struct sh_cmt_channel { - struct sh_cmt_priv *cmt; + struct sh_cmt_device *cmt; unsigned long flags; unsigned long match_value; @@ -52,7 +52,7 @@ struct sh_cmt_channel { bool cs_enabled; }; -struct sh_cmt_priv { +struct sh_cmt_device { struct platform_device *pdev; void __iomem *mapbase; @@ -693,132 +693,132 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, return 0; } -static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) +static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; - struct sh_cmt_channel *ch = &p->channel; + struct sh_cmt_channel *ch = &cmt->channel; struct resource *res, *res2; int irq, ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(cmt, 0, sizeof(*cmt)); + cmt->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&cmt->pdev->dev, "missing platform data\n"); goto err0; } - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); goto err0; } /* optional resource for the shared timer start/stop register */ - res2 = platform_get_resource(p->pdev, IORESOURCE_MEM, 1); + res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - irq = platform_get_irq(p->pdev, 0); + irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + dev_err(&cmt->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (cmt->mapbase == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* map second resource for CMSTR */ - p->mapbase_str = ioremap_nocache(res2 ? res2->start : - res->start - cfg->channel_offset, - res2 ? resource_size(res2) : 2); - if (p->mapbase_str == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O second memory\n"); + cmt->mapbase_str = ioremap_nocache(res2 ? res2->start : + res->start - cfg->channel_offset, + res2 ? resource_size(res2) : 2); + if (cmt->mapbase_str == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); goto err1; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "cmt_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); + if (IS_ERR(cmt->clk)) { + dev_err(&cmt->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(cmt->clk); goto err2; } - ret = clk_prepare(p->clk); + ret = clk_prepare(cmt->clk); if (ret < 0) goto err3; if (res2 && (resource_size(res2) == 4)) { /* assume both CMSTR and CMCSR to be 32-bit */ - p->read_control = sh_cmt_read32; - p->write_control = sh_cmt_write32; + cmt->read_control = sh_cmt_read32; + cmt->write_control = sh_cmt_write32; } else { - p->read_control = sh_cmt_read16; - p->write_control = sh_cmt_write16; + cmt->read_control = sh_cmt_read16; + cmt->write_control = sh_cmt_write16; } if (resource_size(res) == 6) { - p->width = 16; - p->read_count = sh_cmt_read16; - p->write_count = sh_cmt_write16; - p->overflow_bit = 0x80; - p->clear_bits = ~0x80; + cmt->width = 16; + cmt->read_count = sh_cmt_read16; + cmt->write_count = sh_cmt_write16; + cmt->overflow_bit = 0x80; + cmt->clear_bits = ~0x80; } else { - p->width = 32; - p->read_count = sh_cmt_read32; - p->write_count = sh_cmt_write32; - p->overflow_bit = 0x8000; - p->clear_bits = ~0xc000; + cmt->width = 32; + cmt->read_count = sh_cmt_read32; + cmt->write_count = sh_cmt_write32; + cmt->overflow_bit = 0x8000; + cmt->clear_bits = ~0xc000; } - if (p->width == (sizeof(ch->max_match_value) * 8)) + if (cmt->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else - ch->max_match_value = (1 << p->width) - 1; + ch->max_match_value = (1 << cmt->width) - 1; - ch->cmt = p; + ch->cmt = cmt; ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(ch, (char *)dev_name(&p->pdev->dev), + ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { - dev_err(&p->pdev->dev, "registration failed\n"); + dev_err(&cmt->pdev->dev, "registration failed\n"); goto err4; } ch->cs_enabled = false; ret = request_irq(irq, sh_cmt_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), ch); + dev_name(&cmt->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); + dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); goto err4; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, cmt); return 0; err4: - clk_unprepare(p->clk); + clk_unprepare(cmt->clk); err3: - clk_put(p->clk); + clk_put(cmt->clk); err2: - iounmap(p->mapbase_str); + iounmap(cmt->mapbase_str); err1: - iounmap(p->mapbase); + iounmap(cmt->mapbase); err0: return ret; } static int sh_cmt_probe(struct platform_device *pdev) { - struct sh_cmt_priv *p = platform_get_drvdata(pdev); + struct sh_cmt_device *cmt = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -827,20 +827,20 @@ static int sh_cmt_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (cmt) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + cmt = kmalloc(sizeof(*cmt), GFP_KERNEL); + if (cmt == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_cmt_setup(p, pdev); + ret = sh_cmt_setup(cmt, pdev); if (ret) { - kfree(p); + kfree(cmt); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v0.10.2 From b882e7b13bc12b3d6b00e4ea2fe374413ddcdd2d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Split channel setup to separate function Move the channel setup code from sh_cmt_setup to a new sh_cmt_setup_channel function and call it from sh_cmt_setup. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 604199a..26f73cf 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -693,12 +693,55 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, return 0; } +static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, + struct sh_cmt_device *cmt) +{ + struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; + int irq; + int ret; + + memset(ch, 0, sizeof(*ch)); + ch->cmt = cmt; + + irq = platform_get_irq(cmt->pdev, 0); + if (irq < 0) { + dev_err(&cmt->pdev->dev, "failed to get irq\n"); + return irq; + } + + if (cmt->width == (sizeof(ch->max_match_value) * 8)) + ch->max_match_value = ~0; + else + ch->max_match_value = (1 << cmt->width) - 1; + + ch->match_value = ch->max_match_value; + raw_spin_lock_init(&ch->lock); + + ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), + cfg->clockevent_rating, + cfg->clocksource_rating); + if (ret) { + dev_err(&cmt->pdev->dev, "registration failed\n"); + return ret; + } + ch->cs_enabled = false; + + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&cmt->pdev->dev), ch); + if (ret) { + dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + return ret; + } + + return 0; +} + static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; - struct sh_cmt_channel *ch = &cmt->channel; struct resource *res, *res2; - int irq, ret; + int ret; ret = -ENXIO; memset(cmt, 0, sizeof(*cmt)); @@ -718,12 +761,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) /* optional resource for the shared timer start/stop register */ res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - irq = platform_get_irq(cmt->pdev, 0); - if (irq < 0) { - dev_err(&cmt->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); if (cmt->mapbase == NULL) { @@ -775,31 +812,9 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - if (cmt->width == (sizeof(ch->max_match_value) * 8)) - ch->max_match_value = ~0; - else - ch->max_match_value = (1 << cmt->width) - 1; - - ch->cmt = cmt; - ch->match_value = ch->max_match_value; - raw_spin_lock_init(&ch->lock); - - ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); - if (ret) { - dev_err(&cmt->pdev->dev, "registration failed\n"); - goto err4; - } - ch->cs_enabled = false; - - ret = request_irq(irq, sh_cmt_interrupt, - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&cmt->pdev->dev), ch); - if (ret) { - dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + ret = sh_cmt_setup_channel(&cmt->channel, cmt); + if (ret < 0) goto err4; - } platform_set_drvdata(pdev, cmt); -- cgit v0.10.2 From 1d053e1d8eb28f42b7ec57d1c11ce70b8fba45ff Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 16:04:16 +0100 Subject: clocksource: sh_cmt: Constify name argument to sh_cmt_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 26f73cf..febd6bf 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -549,7 +549,7 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) } static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clocksource *cs = &ch->cs; @@ -660,7 +660,7 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) } static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; @@ -680,7 +680,7 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, clockevents_register_device(ced); } -static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, +static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { @@ -717,7 +717,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), + ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { -- cgit v0.10.2 From 36f1ac982d94cd3cce8ae24abd0676b79dec6126 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Rename mapbase/mapbase_str to mapbase_ch/mapbase The mapbase variable points to the mapped base address of the channel, rename it to mapbase_sh. mapbase_str points to the mapped base address of the CMT device, rename it to mapbase. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index febd6bf..eb93b88 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -55,8 +55,8 @@ struct sh_cmt_channel { struct sh_cmt_device { struct platform_device *pdev; + void __iomem *mapbase_ch; void __iomem *mapbase; - void __iomem *mapbase_str; struct clk *clk; struct sh_cmt_channel channel; @@ -125,41 +125,41 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase_str, 0); + return ch->cmt->read_control(ch->cmt->mapbase, 0); } static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase, CMCSR); + return ch->cmt->read_control(ch->cmt->mapbase_ch, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->cmt->mapbase, CMCNT); + return ch->cmt->read_count(ch->cmt->mapbase_ch, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase_str, 0, value); + ch->cmt->write_control(ch->cmt->mapbase, 0, value); } static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase, CMCSR, value); + ch->cmt->write_control(ch->cmt->mapbase_ch, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase, CMCNT, value); + ch->cmt->write_count(ch->cmt->mapbase_ch, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase, CMCOR, value); + ch->cmt->write_count(ch->cmt->mapbase_ch, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -761,18 +761,18 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) /* optional resource for the shared timer start/stop register */ res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - /* map memory, let mapbase point to our channel */ - cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (cmt->mapbase == NULL) { + /* map memory, let mapbase_ch point to our channel */ + cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res)); + if (cmt->mapbase_ch == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* map second resource for CMSTR */ - cmt->mapbase_str = ioremap_nocache(res2 ? res2->start : - res->start - cfg->channel_offset, - res2 ? resource_size(res2) : 2); - if (cmt->mapbase_str == NULL) { + cmt->mapbase = ioremap_nocache(res2 ? res2->start : + res->start - cfg->channel_offset, + res2 ? resource_size(res2) : 2); + if (cmt->mapbase == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); goto err1; } @@ -824,9 +824,9 @@ err4: err3: clk_put(cmt->clk); err2: - iounmap(cmt->mapbase_str); -err1: iounmap(cmt->mapbase); +err1: + iounmap(cmt->mapbase_ch); err0: return ret; } -- cgit v0.10.2 From c924d2d2a964715b55b6601be338b3bd05a1ced5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Add memory base to sh_cmt_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index eb93b88..4fcb05d 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -40,6 +40,8 @@ struct sh_cmt_device; struct sh_cmt_channel { struct sh_cmt_device *cmt; + void __iomem *base; + unsigned long flags; unsigned long match_value; unsigned long next_match_value; @@ -130,12 +132,12 @@ static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase_ch, CMCSR); + return ch->cmt->read_control(ch->base, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->cmt->mapbase_ch, CMCNT); + return ch->cmt->read_count(ch->base, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, @@ -147,19 +149,19 @@ static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase_ch, CMCSR, value); + ch->cmt->write_control(ch->base, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase_ch, CMCNT, value); + ch->cmt->write_count(ch->base, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase_ch, CMCOR, value); + ch->cmt->write_count(ch->base, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -702,6 +704,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; + ch->base = cmt->mapbase_ch; irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { -- cgit v0.10.2 From 740a95184dd61eb0481f75ced05ea5e01b7ce6ac Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Add index to struct sh_cmt_channel Use the index when printing messages to identify the channel. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 4fcb05d..6b65621 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -39,6 +39,7 @@ struct sh_cmt_device; struct sh_cmt_channel { struct sh_cmt_device *cmt; + unsigned int index; void __iomem *base; @@ -216,7 +217,8 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) /* enable clock */ ret = clk_enable(ch->cmt->clk); if (ret) { - dev_err(&ch->cmt->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->cmt->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); goto err0; } @@ -253,7 +255,8 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) } if (sh_cmt_read_cmcnt(ch)) { - dev_err(&ch->cmt->pdev->dev, "cannot clear CMCNT\n"); + dev_err(&ch->cmt->pdev->dev, "ch%u: cannot clear CMCNT\n", + ch->index); ret = -ETIMEDOUT; goto err1; } @@ -371,7 +374,8 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, delay = 1; if (!delay) - dev_warn(&ch->cmt->pdev->dev, "too long delay\n"); + dev_warn(&ch->cmt->pdev->dev, "ch%u: too long delay\n", + ch->index); } while (delay); } @@ -379,7 +383,8 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, static void __sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { if (delta > ch->max_match_value) - dev_warn(&ch->cmt->pdev->dev, "delta out of range\n"); + dev_warn(&ch->cmt->pdev->dev, "ch%u: delta out of range\n", + ch->index); ch->next_match_value = delta; sh_cmt_clock_event_program_verify(ch, 0); @@ -565,7 +570,8 @@ static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&ch->cmt->pdev->dev, "used as clock source\n"); + dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n", + ch->index); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); @@ -614,12 +620,12 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->cmt->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_cmt_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: dev_info(&ch->cmt->pdev->dev, - "used for oneshot clock events\n"); + "ch%u: used for oneshot clock events\n", ch->index); sh_cmt_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_SHUTDOWN: @@ -678,7 +684,8 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, ced->suspend = sh_cmt_clock_event_suspend; ced->resume = sh_cmt_clock_event_resume; - dev_info(&ch->cmt->pdev->dev, "used for clock events\n"); + dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_register_device(ced); } @@ -695,7 +702,7 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, return 0; } -static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, +static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, struct sh_cmt_device *cmt) { struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; @@ -705,10 +712,12 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; ch->base = cmt->mapbase_ch; + ch->index = index; irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { - dev_err(&cmt->pdev->dev, "failed to get irq\n"); + dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return irq; } @@ -724,7 +733,8 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { - dev_err(&cmt->pdev->dev, "registration failed\n"); + dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", + ch->index); return ret; } ch->cs_enabled = false; @@ -733,7 +743,8 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&cmt->pdev->dev), ch); if (ret) { - dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + dev_err(&cmt->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, irq); return ret; } @@ -815,7 +826,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - ret = sh_cmt_setup_channel(&cmt->channel, cmt); + ret = sh_cmt_setup_channel(&cmt->channel, cfg->timer_bit, cmt); if (ret < 0) goto err4; -- cgit v0.10.2 From b262bc74dcfd77355720342cbcf89cc8ec12e86b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 6b65621..0779bf1 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -672,8 +672,6 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, { struct clock_event_device *ced = &ch->ced; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; @@ -709,7 +707,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, int irq; int ret; - memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; ch->base = cmt->mapbase_ch; ch->index = index; @@ -758,7 +755,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) int ret; ret = -ENXIO; - memset(cmt, 0, sizeof(*cmt)); cmt->pdev = pdev; if (!cfg) { @@ -861,7 +857,7 @@ static int sh_cmt_probe(struct platform_device *pdev) goto out; } - cmt = kmalloc(sizeof(*cmt), GFP_KERNEL); + cmt = kzalloc(sizeof(*cmt), GFP_KERNEL); if (cmt == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v0.10.2 From f5ec9b194a93c05e2ccdb3e90d9061cfedc806d9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 0779bf1..f94db32 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -62,7 +62,8 @@ struct sh_cmt_device { void __iomem *mapbase; struct clk *clk; - struct sh_cmt_channel channel; + struct sh_cmt_channel *channels; + unsigned int num_channels; unsigned long width; /* 16 or 32 bit version of hardware block */ unsigned long overflow_bit; @@ -822,7 +823,15 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - ret = sh_cmt_setup_channel(&cmt->channel, cfg->timer_bit, cmt); + cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); + if (cmt->channels == NULL) { + ret = -ENOMEM; + goto err4; + } + + cmt->num_channels = 1; + + ret = sh_cmt_setup_channel(&cmt->channels[0], cfg->timer_bit, cmt); if (ret < 0) goto err4; @@ -830,6 +839,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) return 0; err4: + kfree(cmt->channels); clk_unprepare(cmt->clk); err3: clk_put(cmt->clk); -- cgit v0.10.2 From 2cda3ac49d5744432e9ebffb8ba47bef6eca053d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 11 Feb 2014 23:46:48 +0100 Subject: clocksource: sh_cmt: Split static information from sh_cmt_device Create a new sh_cmt_info structure to hold static information about the device model and reference that structure from the sh_cmt_device structure. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index f94db32..879b8c2 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -37,6 +37,52 @@ struct sh_cmt_device; +/* + * The CMT comes in 5 different identified flavours, depending not only on the + * SoC but also on the particular instance. The following table lists the main + * characteristics of those flavours. + * + * 16B 32B 32B-F 48B 48B-2 + * ----------------------------------------------------------------------------- + * Channels 2 1/4 1 6 2/8 + * Control Width 16 16 16 16 32 + * Counter Width 16 32 32 32/48 32/48 + * Shared Start/Stop Y Y Y Y N + * + * The 48-bit gen2 version has a per-channel start/stop register located in the + * channel registers block. All other versions have a shared start/stop register + * located in the global space. + * + * Note that CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit + * channels only, is a 48-bit gen2 CMT with the 48-bit channels unavailable. + */ + +enum sh_cmt_model { + SH_CMT_16BIT, + SH_CMT_32BIT, + SH_CMT_32BIT_FAST, + SH_CMT_48BIT, + SH_CMT_48BIT_GEN2, +}; + +struct sh_cmt_info { + enum sh_cmt_model model; + + unsigned long width; /* 16 or 32 bit version of hardware block */ + unsigned long overflow_bit; + unsigned long clear_bits; + + /* callbacks for CMSTR and CMCSR access */ + unsigned long (*read_control)(void __iomem *base, unsigned long offs); + void (*write_control)(void __iomem *base, unsigned long offs, + unsigned long value); + + /* callbacks for CMCNT and CMCOR access */ + unsigned long (*read_count)(void __iomem *base, unsigned long offs); + void (*write_count)(void __iomem *base, unsigned long offs, + unsigned long value); +}; + struct sh_cmt_channel { struct sh_cmt_device *cmt; unsigned int index; @@ -58,49 +104,16 @@ struct sh_cmt_channel { struct sh_cmt_device { struct platform_device *pdev; + const struct sh_cmt_info *info; + void __iomem *mapbase_ch; void __iomem *mapbase; struct clk *clk; struct sh_cmt_channel *channels; unsigned int num_channels; - - unsigned long width; /* 16 or 32 bit version of hardware block */ - unsigned long overflow_bit; - unsigned long clear_bits; - - /* callbacks for CMSTR and CMCSR access */ - unsigned long (*read_control)(void __iomem *base, unsigned long offs); - void (*write_control)(void __iomem *base, unsigned long offs, - unsigned long value); - - /* callbacks for CMCNT and CMCOR access */ - unsigned long (*read_count)(void __iomem *base, unsigned long offs); - void (*write_count)(void __iomem *base, unsigned long offs, - unsigned long value); }; -/* Examples of supported CMT timer register layouts and I/O access widths: - * - * "16-bit counter and 16-bit control" as found on sh7263: - * CMSTR 0xfffec000 16-bit - * CMCSR 0xfffec002 16-bit - * CMCNT 0xfffec004 16-bit - * CMCOR 0xfffec006 16-bit - * - * "32-bit counter and 16-bit control" as found on sh7372, sh73a0, r8a7740: - * CMSTR 0xffca0000 16-bit - * CMCSR 0xffca0060 16-bit - * CMCNT 0xffca0064 32-bit - * CMCOR 0xffca0068 32-bit - * - * "32-bit counter and 32-bit control" as found on r8a73a4 and r8a7790: - * CMSTR 0xffca0500 32-bit - * CMCSR 0xffca0510 32-bit - * CMCNT 0xffca0514 32-bit - * CMCOR 0xffca0518 32-bit - */ - static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs) { return ioread16(base + (offs << 1)); @@ -123,47 +136,100 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, iowrite32(value, base + (offs << 2)); } +static const struct sh_cmt_info sh_cmt_info[] = { + [SH_CMT_16BIT] = { + .model = SH_CMT_16BIT, + .width = 16, + .overflow_bit = 0x80, + .clear_bits = ~0x80, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read16, + .write_count = sh_cmt_write16, + }, + [SH_CMT_32BIT] = { + .model = SH_CMT_32BIT, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_32BIT_FAST] = { + .model = SH_CMT_32BIT_FAST, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_48BIT] = { + .model = SH_CMT_48BIT, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read32, + .write_control = sh_cmt_write32, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_48BIT_GEN2] = { + .model = SH_CMT_48BIT_GEN2, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read32, + .write_control = sh_cmt_write32, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, +}; + #define CMCSR 0 /* channel register */ #define CMCNT 1 /* channel register */ #define CMCOR 2 /* channel register */ static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase, 0); + return ch->cmt->info->read_control(ch->cmt->mapbase, 0); } static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->base, CMCSR); + return ch->cmt->info->read_control(ch->base, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->base, CMCNT); + return ch->cmt->info->read_count(ch->base, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase, 0, value); + ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); } static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->base, CMCSR, value); + ch->cmt->info->write_control(ch->base, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->base, CMCNT, value); + ch->cmt->info->write_count(ch->base, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->base, CMCOR, value); + ch->cmt->info->write_count(ch->base, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -172,7 +238,7 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, unsigned long v1, v2, v3; int o1, o2; - o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit; /* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { @@ -180,7 +246,7 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, v1 = sh_cmt_read_cmcnt(ch); v2 = sh_cmt_read_cmcnt(ch); v3 = sh_cmt_read_cmcnt(ch); - o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit; } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); @@ -227,7 +293,7 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) sh_cmt_start_stop_ch(ch, 0); /* configure channel, periodic mode and maximum timeout */ - if (ch->cmt->width == 16) { + if (ch->cmt->info->width == 16) { *rate = clk_get_rate(ch->cmt->clk) / 512; sh_cmt_write_cmcsr(ch, 0x43); } else { @@ -405,7 +471,8 @@ static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id) struct sh_cmt_channel *ch = dev_id; /* clear flags */ - sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & ch->cmt->clear_bits); + sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & + ch->cmt->info->clear_bits); /* update clock source counter to begin with if enabled * the wrap flag should be cleared by the timer specific @@ -719,10 +786,10 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, return irq; } - if (cmt->width == (sizeof(ch->max_match_value) * 8)) + if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else - ch->max_match_value = (1 << cmt->width) - 1; + ch->max_match_value = (1 << cmt->info->width) - 1; ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); @@ -800,28 +867,13 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) if (ret < 0) goto err3; - if (res2 && (resource_size(res2) == 4)) { - /* assume both CMSTR and CMCSR to be 32-bit */ - cmt->read_control = sh_cmt_read32; - cmt->write_control = sh_cmt_write32; - } else { - cmt->read_control = sh_cmt_read16; - cmt->write_control = sh_cmt_write16; - } - - if (resource_size(res) == 6) { - cmt->width = 16; - cmt->read_count = sh_cmt_read16; - cmt->write_count = sh_cmt_write16; - cmt->overflow_bit = 0x80; - cmt->clear_bits = ~0x80; - } else { - cmt->width = 32; - cmt->read_count = sh_cmt_read32; - cmt->write_count = sh_cmt_write32; - cmt->overflow_bit = 0x8000; - cmt->clear_bits = ~0xc000; - } + /* identify the model based on the resources */ + if (resource_size(res) == 6) + cmt->info = &sh_cmt_info[SH_CMT_16BIT]; + else if (res2 && (resource_size(res2) == 4)) + cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + else + cmt->info = &sh_cmt_info[SH_CMT_32BIT]; cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); if (cmt->channels == NULL) { -- cgit v0.10.2 From d14be99b7e3fe52bc9921caa30953d49f499f121 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Jan 2014 00:33:08 +0100 Subject: clocksource: sh_cmt: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 879b8c2..ce00baa 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -114,6 +114,34 @@ struct sh_cmt_device { unsigned int num_channels; }; +#define SH_CMT16_CMCSR_CMF (1 << 7) +#define SH_CMT16_CMCSR_CMIE (1 << 6) +#define SH_CMT16_CMCSR_CKS8 (0 << 0) +#define SH_CMT16_CMCSR_CKS32 (1 << 0) +#define SH_CMT16_CMCSR_CKS128 (2 << 0) +#define SH_CMT16_CMCSR_CKS512 (3 << 0) +#define SH_CMT16_CMCSR_CKS_MASK (3 << 0) + +#define SH_CMT32_CMCSR_CMF (1 << 15) +#define SH_CMT32_CMCSR_OVF (1 << 14) +#define SH_CMT32_CMCSR_WRFLG (1 << 13) +#define SH_CMT32_CMCSR_STTF (1 << 12) +#define SH_CMT32_CMCSR_STPF (1 << 11) +#define SH_CMT32_CMCSR_SSIE (1 << 10) +#define SH_CMT32_CMCSR_CMS (1 << 9) +#define SH_CMT32_CMCSR_CMM (1 << 8) +#define SH_CMT32_CMCSR_CMTOUT_IE (1 << 7) +#define SH_CMT32_CMCSR_CMR_NONE (0 << 4) +#define SH_CMT32_CMCSR_CMR_DMA (1 << 4) +#define SH_CMT32_CMCSR_CMR_IRQ (2 << 4) +#define SH_CMT32_CMCSR_CMR_MASK (3 << 4) +#define SH_CMT32_CMCSR_DBGIVD (1 << 3) +#define SH_CMT32_CMCSR_CKS_RCLK8 (4 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK32 (5 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK128 (6 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK1 (7 << 0) +#define SH_CMT32_CMCSR_CKS_MASK (7 << 0) + static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs) { return ioread16(base + (offs << 1)); @@ -140,8 +168,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_16BIT] = { .model = SH_CMT_16BIT, .width = 16, - .overflow_bit = 0x80, - .clear_bits = ~0x80, + .overflow_bit = SH_CMT16_CMCSR_CMF, + .clear_bits = ~SH_CMT16_CMCSR_CMF, .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read16, @@ -150,8 +178,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_32BIT] = { .model = SH_CMT_32BIT, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read32, @@ -160,8 +188,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_32BIT_FAST] = { .model = SH_CMT_32BIT_FAST, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read32, @@ -170,8 +198,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_48BIT] = { .model = SH_CMT_48BIT, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read32, .write_control = sh_cmt_write32, .read_count = sh_cmt_read32, @@ -180,8 +208,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_48BIT_GEN2] = { .model = SH_CMT_48BIT_GEN2, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read32, .write_control = sh_cmt_write32, .read_count = sh_cmt_read32, @@ -295,10 +323,14 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) /* configure channel, periodic mode and maximum timeout */ if (ch->cmt->info->width == 16) { *rate = clk_get_rate(ch->cmt->clk) / 512; - sh_cmt_write_cmcsr(ch, 0x43); + sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE | + SH_CMT16_CMCSR_CKS512); } else { *rate = clk_get_rate(ch->cmt->clk) / 8; - sh_cmt_write_cmcsr(ch, 0x01a4); + sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM | + SH_CMT32_CMCSR_CMTOUT_IE | + SH_CMT32_CMCSR_CMR_IRQ | + SH_CMT32_CMCSR_CKS_RCLK8); } sh_cmt_write_cmcor(ch, 0xffffffff); -- cgit v0.10.2 From f1ebe1e47e1979393a8492bfe751176908a830ae Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 16:19:44 +0100 Subject: clocksource: sh_cmt: Set cpumask to cpu_possible_mask The CMT is a global timer not restricted to a single CPU. It has a lower rating than the TMU or ARM architected timer, but is still useful on systems where the other timers are stopped during CPU sleep. When multiple timers are available the timers core selects which timer to use based on timer ratings. On SMP systems where timer broadcasting is required, one dummy timer is instantiated per CPU with a rating of 100. On those systems the CMT timer has a rating of 80, which makes the dummy timer selected by default on all CPUs. The CMT is then available, and will be used as a broadcast timer. On UP systems no dummy timer is instantiated. The CMT timer has a rating of 125 on those systems and is used directly as a clock event device for CPU0 without broadcasting. The CMT rating shouldn't depend on whether we boot a UP or SMP system. We can't raise the CMT rating to 125 on SMP systems. This would select CMT as the clock event device for CPU0 as its rating is higher than the dummy timer rating, and would leave the system without a broadcast timer. We could instead lower the rating to 80 on all systems, but that wouldn't reflect reality as ratings between 1 and 99 are documented as "unfit for real use". We should raise the rating above 99 and still have the CMT selected as a broadcast timer. This can be done by changing the cpumask from cpumask_of(0) to cpu_possible_mask. In that case the timer selection logic will prefer the previously probed and already selected dummy timer for all CPUs based on the fact that already selected per-cpu timers are preferred over new global timers, regardless of their respective ratings. This also better reflects reality, as the CMT is not tied to the boot CPU. Ideally the timer selection logic should realize that the CMT needs to be used as a broadcast timer on SMP systems as no other broadcast timer is available, regardless of the cpumask and rating. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index ce00baa..926abe2 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -776,7 +776,7 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; ced->rating = rating; - ced->cpumask = cpumask_of(0); + ced->cpumask = cpu_possible_mask; ced->set_next_event = sh_cmt_clock_event_next; ced->set_mode = sh_cmt_clock_event_mode; ced->suspend = sh_cmt_clock_event_suspend; -- cgit v0.10.2 From b7fcbb0f830e6cccc9d358c24f8463e5d8018649 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_cmt: Hardcode CMT clock event rating to 125 All boards use or should use a clock event rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 926abe2..75b1f83 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -768,14 +768,14 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) } static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; - ced->rating = rating; + ced->rating = 125; ced->cpumask = cpu_possible_mask; ced->set_next_event = sh_cmt_clock_event_next; ced->set_mode = sh_cmt_clock_event_mode; @@ -788,11 +788,10 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, - unsigned long clockevent_rating, - unsigned long clocksource_rating) + bool clockevent, unsigned long clocksource_rating) { - if (clockevent_rating) - sh_cmt_register_clockevent(ch, name, clockevent_rating); + if (clockevent) + sh_cmt_register_clockevent(ch, name); if (clocksource_rating) sh_cmt_register_clocksource(ch, name, clocksource_rating); @@ -827,7 +826,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, raw_spin_lock_init(&ch->lock); ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), - cfg->clockevent_rating, + cfg->clockevent_rating != 0, cfg->clocksource_rating); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", -- cgit v0.10.2 From fb28a659813084365eced5c2876c6383da52e634 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_cmt: Hardcode CMT clock source rating to 125 All boards use or should use a clock source rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 75b1f83..c753efc 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -656,12 +656,12 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) } static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clocksource *cs = &ch->cs; cs->name = name; - cs->rating = rating; + cs->rating = 125; cs->read = sh_cmt_clocksource_read; cs->enable = sh_cmt_clocksource_enable; cs->disable = sh_cmt_clocksource_disable; @@ -788,13 +788,13 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, - bool clockevent, unsigned long clocksource_rating) + bool clockevent, bool clocksource) { if (clockevent) sh_cmt_register_clockevent(ch, name); - if (clocksource_rating) - sh_cmt_register_clocksource(ch, name, clocksource_rating); + if (clocksource) + sh_cmt_register_clocksource(ch, name); return 0; } @@ -827,7 +827,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), cfg->clockevent_rating != 0, - cfg->clocksource_rating); + cfg->clocksource_rating != 0); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", ch->index); -- cgit v0.10.2 From 81b3b2711072b6047d5f332cd8751a1c5c9a3fb2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 28 Jan 2014 12:36:48 +0100 Subject: clocksource: sh_cmt: Add support for multiple channels per device CMT hardware devices can support multiple channels, with global registers and per-channel registers. The sh_cmt driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index c753efc..1efe7d6 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -53,7 +53,16 @@ struct sh_cmt_device; * channel registers block. All other versions have a shared start/stop register * located in the global space. * - * Note that CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit + * Channels are indexed from 0 to N-1 in the documentation. The channel index + * infers the start/stop bit position in the control register and the channel + * registers block address. Some CMT instances have a subset of channels + * available, in which case the index in the documentation doesn't match the + * "real" index as implemented in hardware. This is for instance the case with + * CMT0 on r8a7740, which is a 32-bit variant with a single channel numbered 0 + * in the documentation but using start/stop bit 5 and having its registers + * block at 0x60. + * + * Similarly CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit * channels only, is a 48-bit gen2 CMT with the 48-bit channels unavailable. */ @@ -85,10 +94,14 @@ struct sh_cmt_info { struct sh_cmt_channel { struct sh_cmt_device *cmt; - unsigned int index; - void __iomem *base; + unsigned int index; /* Index in the documentation */ + unsigned int hwidx; /* Real hardware index */ + + void __iomem *iostart; + void __iomem *ioctrl; + unsigned int timer_bit; unsigned long flags; unsigned long match_value; unsigned long next_match_value; @@ -105,6 +118,7 @@ struct sh_cmt_device { struct platform_device *pdev; const struct sh_cmt_info *info; + bool legacy; void __iomem *mapbase_ch; void __iomem *mapbase; @@ -112,6 +126,9 @@ struct sh_cmt_device { struct sh_cmt_channel *channels; unsigned int num_channels; + + bool has_clockevent; + bool has_clocksource; }; #define SH_CMT16_CMCSR_CMF (1 << 7) @@ -223,41 +240,47 @@ static const struct sh_cmt_info sh_cmt_info[] = { static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->info->read_control(ch->cmt->mapbase, 0); + if (ch->iostart) + return ch->cmt->info->read_control(ch->iostart, 0); + else + return ch->cmt->info->read_control(ch->cmt->mapbase, 0); } -static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) +static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, + unsigned long value) { - return ch->cmt->info->read_control(ch->base, CMCSR); + if (ch->iostart) + ch->cmt->info->write_control(ch->iostart, 0, value); + else + ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); } -static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) +static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->info->read_count(ch->base, CMCNT); + return ch->cmt->info->read_control(ch->ioctrl, CMCSR); } -static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, +static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); + ch->cmt->info->write_control(ch->ioctrl, CMCSR, value); } -static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, - unsigned long value) +static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - ch->cmt->info->write_control(ch->base, CMCSR, value); + return ch->cmt->info->read_count(ch->ioctrl, CMCNT); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_count(ch->base, CMCNT, value); + ch->cmt->info->write_count(ch->ioctrl, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_count(ch->base, CMCOR, value); + ch->cmt->info->write_count(ch->ioctrl, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -286,7 +309,6 @@ static DEFINE_RAW_SPINLOCK(sh_cmt_lock); static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) { - struct sh_timer_config *cfg = ch->cmt->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -294,9 +316,9 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) value = sh_cmt_read_cmstr(ch); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->timer_bit; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->timer_bit); sh_cmt_write_cmstr(ch, value); raw_spin_unlock_irqrestore(&sh_cmt_lock, flags); @@ -790,27 +812,72 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, bool clockevent, bool clocksource) { - if (clockevent) + if (clockevent) { + ch->cmt->has_clockevent = true; sh_cmt_register_clockevent(ch, name); + } - if (clocksource) + if (clocksource) { + ch->cmt->has_clocksource = true; sh_cmt_register_clocksource(ch, name); + } return 0; } static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, - struct sh_cmt_device *cmt) + unsigned int hwidx, bool clockevent, + bool clocksource, struct sh_cmt_device *cmt) { - struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; int irq; int ret; + /* Skip unused channels. */ + if (!clockevent && !clocksource) + return 0; + ch->cmt = cmt; - ch->base = cmt->mapbase_ch; ch->index = index; + ch->hwidx = hwidx; + + /* + * Compute the address of the channel control register block. For the + * timers with a per-channel start/stop register, compute its address + * as well. + * + * For legacy configuration the address has been mapped explicitly. + */ + if (cmt->legacy) { + ch->ioctrl = cmt->mapbase_ch; + } else { + switch (cmt->info->model) { + case SH_CMT_16BIT: + ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6; + break; + case SH_CMT_32BIT: + case SH_CMT_48BIT: + ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10; + break; + case SH_CMT_32BIT_FAST: + /* + * The 32-bit "fast" timer has a single channel at hwidx + * 5 but is located at offset 0x40 instead of 0x60 for + * some reason. + */ + ch->ioctrl = cmt->mapbase + 0x40; + break; + case SH_CMT_48BIT_GEN2: + ch->iostart = cmt->mapbase + ch->hwidx * 0x100; + ch->ioctrl = ch->iostart + 0x10; + break; + } + } + + if (cmt->legacy) + irq = platform_get_irq(cmt->pdev, 0); + else + irq = platform_get_irq(cmt->pdev, ch->index); - irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", ch->index); @@ -825,9 +892,15 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); + if (cmt->legacy) { + ch->timer_bit = ch->hwidx; + } else { + ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 + ? 0 : ch->hwidx; + } + ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), - cfg->clockevent_rating != 0, - cfg->clocksource_rating != 0); + clockevent, clocksource); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", ch->index); @@ -847,97 +920,180 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, return 0; } -static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) +static int sh_cmt_map_memory(struct sh_cmt_device *cmt) { - struct sh_timer_config *cfg = pdev->dev.platform_data; - struct resource *res, *res2; - int ret; - ret = -ENXIO; + struct resource *mem; - cmt->pdev = pdev; + mem = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); + if (!mem) { + dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); + return -ENXIO; + } - if (!cfg) { - dev_err(&cmt->pdev->dev, "missing platform data\n"); - goto err0; + cmt->mapbase = ioremap_nocache(mem->start, resource_size(mem)); + if (cmt->mapbase == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); + return -ENXIO; } + return 0; +} + +static int sh_cmt_map_memory_legacy(struct sh_cmt_device *cmt) +{ + struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; + struct resource *res, *res2; + + /* map memory, let mapbase_ch point to our channel */ res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } - /* optional resource for the shared timer start/stop register */ - res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - - /* map memory, let mapbase_ch point to our channel */ cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res)); if (cmt->mapbase_ch == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + return -ENXIO; } + /* optional resource for the shared timer start/stop register */ + res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); + /* map second resource for CMSTR */ cmt->mapbase = ioremap_nocache(res2 ? res2->start : res->start - cfg->channel_offset, res2 ? resource_size(res2) : 2); if (cmt->mapbase == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); - goto err1; + iounmap(cmt->mapbase_ch); + return -ENXIO; } - /* get hold of clock */ + /* identify the model based on the resources */ + if (resource_size(res) == 6) + cmt->info = &sh_cmt_info[SH_CMT_16BIT]; + else if (res2 && (resource_size(res2) == 4)) + cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + else + cmt->info = &sh_cmt_info[SH_CMT_32BIT]; + + return 0; +} + +static void sh_cmt_unmap_memory(struct sh_cmt_device *cmt) +{ + iounmap(cmt->mapbase); + if (cmt->mapbase_ch) + iounmap(cmt->mapbase_ch); +} + +static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int hw_channels; + int ret; + + memset(cmt, 0, sizeof(*cmt)); + cmt->pdev = pdev; + + if (!cfg) { + dev_err(&cmt->pdev->dev, "missing platform data\n"); + return -ENXIO; + } + + cmt->info = (const struct sh_cmt_info *)id->driver_data; + cmt->legacy = cmt->info ? false : true; + + /* Get hold of clock. */ cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); if (IS_ERR(cmt->clk)) { dev_err(&cmt->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(cmt->clk); - goto err2; + return PTR_ERR(cmt->clk); } ret = clk_prepare(cmt->clk); if (ret < 0) - goto err3; + goto err_clk_put; - /* identify the model based on the resources */ - if (resource_size(res) == 6) - cmt->info = &sh_cmt_info[SH_CMT_16BIT]; - else if (res2 && (resource_size(res2) == 4)) - cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + /* + * Map the memory resource(s). We need to support both the legacy + * platform device configuration (with one device per channel) and the + * new version (with multiple channels per device). + */ + if (cmt->legacy) + ret = sh_cmt_map_memory_legacy(cmt); else - cmt->info = &sh_cmt_info[SH_CMT_32BIT]; + ret = sh_cmt_map_memory(cmt); - cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); + if (ret < 0) + goto err_clk_unprepare; + + /* Allocate and setup the channels. */ + if (cmt->legacy) { + cmt->num_channels = 1; + hw_channels = 0; + } else { + cmt->num_channels = hweight8(cfg->channels_mask); + hw_channels = cfg->channels_mask; + } + + cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels), + GFP_KERNEL); if (cmt->channels == NULL) { ret = -ENOMEM; - goto err4; + goto err_unmap; } - cmt->num_channels = 1; + if (cmt->legacy) { + ret = sh_cmt_setup_channel(&cmt->channels[0], + cfg->timer_bit, cfg->timer_bit, + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0, cmt); + if (ret < 0) + goto err_unmap; + } else { + unsigned int mask = hw_channels; + unsigned int i; - ret = sh_cmt_setup_channel(&cmt->channels[0], cfg->timer_bit, cmt); - if (ret < 0) - goto err4; + /* + * Use the first channel as a clock event device and the second + * channel as a clock source. If only one channel is available + * use it for both. + */ + for (i = 0; i < cmt->num_channels; ++i) { + unsigned int hwidx = ffs(mask) - 1; + bool clocksource = i == 1 || cmt->num_channels == 1; + bool clockevent = i == 0; + + ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx, + clockevent, clocksource, + cmt); + if (ret < 0) + goto err_unmap; + + mask &= ~(1 << hwidx); + } + } platform_set_drvdata(pdev, cmt); return 0; -err4: + +err_unmap: kfree(cmt->channels); + sh_cmt_unmap_memory(cmt); +err_clk_unprepare: clk_unprepare(cmt->clk); -err3: +err_clk_put: clk_put(cmt->clk); -err2: - iounmap(cmt->mapbase); -err1: - iounmap(cmt->mapbase_ch); -err0: return ret; } static int sh_cmt_probe(struct platform_device *pdev) { struct sh_cmt_device *cmt = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -966,7 +1122,7 @@ static int sh_cmt_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating || cfg->clocksource_rating) + if (cmt->has_clockevent || cmt->has_clocksource) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -979,12 +1135,24 @@ static int sh_cmt_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent and clocksource */ } +static const struct platform_device_id sh_cmt_id_table[] = { + { "sh_cmt", 0 }, + { "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] }, + { "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] }, + { "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] }, + { "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] }, + { "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] }, + { } +}; +MODULE_DEVICE_TABLE(platform, sh_cmt_id_table); + static struct platform_driver sh_cmt_device_driver = { .probe = sh_cmt_probe, .remove = sh_cmt_remove, .driver = { .name = "sh_cmt", - } + }, + .id_table = sh_cmt_id_table, }; static int __init sh_cmt_init(void) diff --git a/include/linux/sh_timer.h b/include/linux/sh_timer.h index 4d9dcd1..8e1e036 100644 --- a/include/linux/sh_timer.h +++ b/include/linux/sh_timer.h @@ -7,6 +7,7 @@ struct sh_timer_config { int timer_bit; unsigned long clockevent_rating; unsigned long clocksource_rating; + unsigned int channels_mask; }; #endif /* __SH_TIMER_H__ */ -- cgit v0.10.2 From 24b4e07df54b7bf7739fb3dd193f639a8f274ad6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 00:35:18 +0100 Subject: clocksource: sh_cmt: Rename clock to "fck" in the non-legacy case The sh_cmt driver gets the CMT functional clock using a connection ID of "cmt_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "cmt_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 1efe7d6..a5ea9ae 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -1007,7 +1007,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->legacy = cmt->info ? false : true; /* Get hold of clock. */ - cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); + cmt->clk = clk_get(&cmt->pdev->dev, cmt->legacy ? "cmt_fck" : "fck"); if (IS_ERR(cmt->clk)) { dev_err(&cmt->pdev->dev, "cannot get clock\n"); return PTR_ERR(cmt->clk); -- cgit v0.10.2 From 1cd89c568c057a13ca11acf0eb3a78121513e2b6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 01:25:50 +0100 Subject: clocksource: sh_cmt: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index a5ea9ae..399e952 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v0.10.2 From e7a9bcc2372b0e62443569c63a369cfd528db4f4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 12 Feb 2014 16:56:44 +0100 Subject: clocksource: sh_cmt: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 399e952..9f215e7 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -13,23 +13,23 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include +#include #include -#include -#include #include -#include #include -#include +#include #include -#include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include struct sh_cmt_device; -- cgit v0.10.2 From bfa76bb12f23ecf0c6d07c302f4571a6fe9bc3e3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Feb 2014 01:24:47 +0100 Subject: clocksource: sh_cmt: Request IRQ for clock event device only Clock sources don't need an IRQ, request the IRQ only for channels used as clock event devices. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 9f215e7..bc8d025 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -785,10 +785,28 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); } -static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - const char *name) +static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, + const char *name) { struct clock_event_device *ced = &ch->ced; + int irq; + int ret; + + irq = platform_get_irq(ch->cmt->pdev, ch->cmt->legacy ? 0 : ch->index); + if (irq < 0) { + dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n", + ch->index); + return irq; + } + + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&ch->cmt->pdev->dev), ch); + if (ret) { + dev_err(&ch->cmt->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, irq); + return ret; + } ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; @@ -803,14 +821,20 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", ch->index); clockevents_register_device(ced); + + return 0; } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, bool clockevent, bool clocksource) { + int ret; + if (clockevent) { ch->cmt->has_clockevent = true; - sh_cmt_register_clockevent(ch, name); + ret = sh_cmt_register_clockevent(ch, name); + if (ret < 0) + return ret; } if (clocksource) { @@ -825,7 +849,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, unsigned int hwidx, bool clockevent, bool clocksource, struct sh_cmt_device *cmt) { - int irq; int ret; /* Skip unused channels. */ @@ -869,17 +892,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, } } - if (cmt->legacy) - irq = platform_get_irq(cmt->pdev, 0); - else - irq = platform_get_irq(cmt->pdev, ch->index); - - if (irq < 0) { - dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", - ch->index); - return irq; - } - if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else @@ -904,15 +916,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, } ch->cs_enabled = false; - ret = request_irq(irq, sh_cmt_interrupt, - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&cmt->pdev->dev), ch); - if (ret) { - dev_err(&cmt->pdev->dev, "ch%u: failed to request irq %d\n", - ch->index, irq); - return ret; - } - return 0; } -- cgit v0.10.2 From 1c56cf6b048e1e1bbe08faf38b5592b373905ac5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_tmu: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index ecd7b60..8613cc9 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -38,7 +38,7 @@ struct sh_tmu_priv { void __iomem *mapbase; struct clk *clk; - struct irqaction irqaction; + int irq; struct platform_device *pdev; unsigned long rate; unsigned long periodic; @@ -401,10 +401,11 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); - ret = setup_irq(p->irqaction.irq, &p->irqaction); + ret = request_irq(p->irq, sh_tmu_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", - p->irqaction.irq); + dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); return; } } @@ -425,7 +426,7 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - int irq, ret; + int ret; ret = -ENXIO; memset(p, 0, sizeof(*p)); @@ -444,8 +445,8 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - irq = platform_get_irq(p->pdev, 0); - if (irq < 0) { + p->irq = platform_get_irq(p->pdev, 0); + if (p->irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -457,13 +458,6 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - /* setup data for setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_tmu_interrupt; - p->irqaction.dev_id = p; - p->irqaction.irq = irq; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "tmu_fck"); if (IS_ERR(p->clk)) { -- cgit v0.10.2 From de2d12c7e856f0fa59ea83275410a364d2b182c0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 15:29:19 +0100 Subject: clocksource: sh_tmu: Split channel fields from sh_tmu_priv Create a new sh_tmu_channel structure to hold the channel-specific field in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 8613cc9..26457e1 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,11 +35,13 @@ #include #include -struct sh_tmu_priv { - void __iomem *mapbase; - struct clk *clk; +struct sh_tmu_priv; + +struct sh_tmu_channel { + struct sh_tmu_priv *tmu; + int irq; - struct platform_device *pdev; + unsigned long rate; unsigned long periodic; struct clock_event_device ced; @@ -48,6 +50,15 @@ struct sh_tmu_priv { unsigned int enable_count; }; +struct sh_tmu_priv { + struct platform_device *pdev; + + void __iomem *mapbase; + struct clk *clk; + + struct sh_tmu_channel channel; +}; + static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TSTR -1 /* shared register */ @@ -55,10 +66,10 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TCNT 1 /* channel register */ #define TCR 2 /* channel register */ -static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr) +static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; + void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) @@ -72,11 +83,11 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr) return ioread32(base + offs); } -static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr, +static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; + void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) { @@ -92,152 +103,152 @@ static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr, iowrite32(value, base + offs); } -static void sh_tmu_start_stop_ch(struct sh_tmu_priv *p, int start) +static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_tmu_lock, flags); - value = sh_tmu_read(p, TSTR); + value = sh_tmu_read(ch, TSTR); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_tmu_write(p, TSTR, value); + sh_tmu_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_tmu_lock, flags); } -static int __sh_tmu_enable(struct sh_tmu_priv *p) +static int __sh_tmu_enable(struct sh_tmu_channel *ch) { int ret; /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->tmu->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->tmu->pdev->dev, "cannot enable clock\n"); return ret; } /* make sure channel is disabled */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* maximum timeout */ - sh_tmu_write(p, TCOR, 0xffffffff); - sh_tmu_write(p, TCNT, 0xffffffff); + sh_tmu_write(ch, TCOR, 0xffffffff); + sh_tmu_write(ch, TCNT, 0xffffffff); /* configure channel to parent clock / 4, irq off */ - p->rate = clk_get_rate(p->clk) / 4; - sh_tmu_write(p, TCR, 0x0000); + ch->rate = clk_get_rate(ch->tmu->clk) / 4; + sh_tmu_write(ch, TCR, 0x0000); /* enable channel */ - sh_tmu_start_stop_ch(p, 1); + sh_tmu_start_stop_ch(ch, 1); return 0; } -static int sh_tmu_enable(struct sh_tmu_priv *p) +static int sh_tmu_enable(struct sh_tmu_channel *ch) { - if (p->enable_count++ > 0) + if (ch->enable_count++ > 0) return 0; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->tmu->pdev->dev); + dev_pm_syscore_device(&ch->tmu->pdev->dev, true); - return __sh_tmu_enable(p); + return __sh_tmu_enable(ch); } -static void __sh_tmu_disable(struct sh_tmu_priv *p) +static void __sh_tmu_disable(struct sh_tmu_channel *ch) { /* disable channel */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* disable interrupts in TMU block */ - sh_tmu_write(p, TCR, 0x0000); + sh_tmu_write(ch, TCR, 0x0000); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->tmu->clk); } -static void sh_tmu_disable(struct sh_tmu_priv *p) +static void sh_tmu_disable(struct sh_tmu_channel *ch) { - if (WARN_ON(p->enable_count == 0)) + if (WARN_ON(ch->enable_count == 0)) return; - if (--p->enable_count > 0) + if (--ch->enable_count > 0) return; - __sh_tmu_disable(p); + __sh_tmu_disable(ch); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->tmu->pdev->dev, false); + pm_runtime_put(&ch->tmu->pdev->dev); } -static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, +static void sh_tmu_set_next(struct sh_tmu_channel *ch, unsigned long delta, int periodic) { /* stop timer */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* acknowledge interrupt */ - sh_tmu_read(p, TCR); + sh_tmu_read(ch, TCR); /* enable interrupt */ - sh_tmu_write(p, TCR, 0x0020); + sh_tmu_write(ch, TCR, 0x0020); /* reload delta value in case of periodic timer */ if (periodic) - sh_tmu_write(p, TCOR, delta); + sh_tmu_write(ch, TCOR, delta); else - sh_tmu_write(p, TCOR, 0xffffffff); + sh_tmu_write(ch, TCOR, 0xffffffff); - sh_tmu_write(p, TCNT, delta); + sh_tmu_write(ch, TCNT, delta); /* start timer */ - sh_tmu_start_stop_ch(p, 1); + sh_tmu_start_stop_ch(ch, 1); } static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id) { - struct sh_tmu_priv *p = dev_id; + struct sh_tmu_channel *ch = dev_id; /* disable or acknowledge interrupt */ - if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) - sh_tmu_write(p, TCR, 0x0000); + if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) + sh_tmu_write(ch, TCR, 0x0000); else - sh_tmu_write(p, TCR, 0x0020); + sh_tmu_write(ch, TCR, 0x0020); /* notify clockevent layer */ - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); return IRQ_HANDLED; } -static struct sh_tmu_priv *cs_to_sh_tmu(struct clocksource *cs) +static struct sh_tmu_channel *cs_to_sh_tmu(struct clocksource *cs) { - return container_of(cs, struct sh_tmu_priv, cs); + return container_of(cs, struct sh_tmu_channel, cs); } static cycle_t sh_tmu_clocksource_read(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - return sh_tmu_read(p, TCNT) ^ 0xffffffff; + return sh_tmu_read(ch, TCNT) ^ 0xffffffff; } static int sh_tmu_clocksource_enable(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); int ret; - if (WARN_ON(p->cs_enabled)) + if (WARN_ON(ch->cs_enabled)) return 0; - ret = sh_tmu_enable(p); + ret = sh_tmu_enable(ch); if (!ret) { - __clocksource_updatefreq_hz(cs, p->rate); - p->cs_enabled = true; + __clocksource_updatefreq_hz(cs, ch->rate); + ch->cs_enabled = true; } return ret; @@ -245,45 +256,45 @@ static int sh_tmu_clocksource_enable(struct clocksource *cs) static void sh_tmu_clocksource_disable(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (WARN_ON(!p->cs_enabled)) + if (WARN_ON(!ch->cs_enabled)) return; - sh_tmu_disable(p); - p->cs_enabled = false; + sh_tmu_disable(ch); + ch->cs_enabled = false; } static void sh_tmu_clocksource_suspend(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (!p->cs_enabled) + if (!ch->cs_enabled) return; - if (--p->enable_count == 0) { - __sh_tmu_disable(p); - pm_genpd_syscore_poweroff(&p->pdev->dev); + if (--ch->enable_count == 0) { + __sh_tmu_disable(ch); + pm_genpd_syscore_poweroff(&ch->tmu->pdev->dev); } } static void sh_tmu_clocksource_resume(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (!p->cs_enabled) + if (!ch->cs_enabled) return; - if (p->enable_count++ == 0) { - pm_genpd_syscore_poweron(&p->pdev->dev); - __sh_tmu_enable(p); + if (ch->enable_count++ == 0) { + pm_genpd_syscore_poweron(&ch->tmu->pdev->dev); + __sh_tmu_enable(ch); } } -static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, +static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, char *name, unsigned long rating) { - struct clocksource *cs = &p->cs; + struct clocksource *cs = &ch->cs; cs->name = name; cs->rating = rating; @@ -295,43 +306,43 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, cs->mask = CLOCKSOURCE_MASK(32); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&p->pdev->dev, "used as clock source\n"); + dev_info(&ch->tmu->pdev->dev, "used as clock source\n"); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); return 0; } -static struct sh_tmu_priv *ced_to_sh_tmu(struct clock_event_device *ced) +static struct sh_tmu_channel *ced_to_sh_tmu(struct clock_event_device *ced) { - return container_of(ced, struct sh_tmu_priv, ced); + return container_of(ced, struct sh_tmu_channel, ced); } -static void sh_tmu_clock_event_start(struct sh_tmu_priv *p, int periodic) +static void sh_tmu_clock_event_start(struct sh_tmu_channel *ch, int periodic) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; - sh_tmu_enable(p); + sh_tmu_enable(ch); - clockevents_config(ced, p->rate); + clockevents_config(ced, ch->rate); if (periodic) { - p->periodic = (p->rate + HZ/2) / HZ; - sh_tmu_set_next(p, p->periodic, 1); + ch->periodic = (ch->rate + HZ/2) / HZ; + sh_tmu_set_next(ch, ch->periodic, 1); } } static void sh_tmu_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_tmu_priv *p = ced_to_sh_tmu(ced); + struct sh_tmu_channel *ch = ced_to_sh_tmu(ced); int disabled = 0; /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: case CLOCK_EVT_MODE_ONESHOT: - sh_tmu_disable(p); + sh_tmu_disable(ch); disabled = 1; break; default: @@ -340,16 +351,18 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_tmu_clock_event_start(p, 1); + dev_info(&ch->tmu->pdev->dev, + "used for periodic clock events\n"); + sh_tmu_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: - dev_info(&p->pdev->dev, "used for oneshot clock events\n"); - sh_tmu_clock_event_start(p, 0); + dev_info(&ch->tmu->pdev->dev, + "used for oneshot clock events\n"); + sh_tmu_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_UNUSED: if (!disabled) - sh_tmu_disable(p); + sh_tmu_disable(ch); break; case CLOCK_EVT_MODE_SHUTDOWN: default: @@ -360,29 +373,29 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, static int sh_tmu_clock_event_next(unsigned long delta, struct clock_event_device *ced) { - struct sh_tmu_priv *p = ced_to_sh_tmu(ced); + struct sh_tmu_channel *ch = ced_to_sh_tmu(ced); BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT); /* program new delta value */ - sh_tmu_set_next(p, delta, 0); + sh_tmu_set_next(ch, delta, 0); return 0; } static void sh_tmu_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->pdev->dev); + pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } static void sh_tmu_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->pdev->dev); + pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } -static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, +static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; int ret; memset(ced, 0, sizeof(*ced)); @@ -397,27 +410,28 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, ced->suspend = sh_tmu_clock_event_suspend; ced->resume = sh_tmu_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->tmu->pdev->dev, "used for clock events\n"); clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); - ret = request_irq(p->irq, sh_tmu_interrupt, + ret = request_irq(ch->irq, sh_tmu_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&ch->tmu->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); + dev_err(&ch->tmu->pdev->dev, "failed to request irq %d\n", + ch->irq); return; } } -static int sh_tmu_register(struct sh_tmu_priv *p, char *name, +static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { if (clockevent_rating) - sh_tmu_register_clockevent(p, name, clockevent_rating); + sh_tmu_register_clockevent(ch, name, clockevent_rating); else if (clocksource_rating) - sh_tmu_register_clocksource(p, name, clocksource_rating); + sh_tmu_register_clocksource(ch, name, clocksource_rating); return 0; } @@ -445,8 +459,8 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - p->irq = platform_get_irq(p->pdev, 0); - if (p->irq < 0) { + p->channel.irq = platform_get_irq(p->pdev, 0); + if (p->channel.irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -470,10 +484,11 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) if (ret < 0) goto err2; - p->cs_enabled = false; - p->enable_count = 0; + p->channel.cs_enabled = false; + p->channel.enable_count = 0; + p->channel.tmu = p; - ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev), + ret = sh_tmu_register(&p->channel, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret < 0) -- cgit v0.10.2 From 0a72aa39cc105fbf6971feb8928a63530a4a446b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Rename struct sh_tmu_priv to sh_tmu_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 26457e1..7013790 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,10 +35,10 @@ #include #include -struct sh_tmu_priv; +struct sh_tmu_device; struct sh_tmu_channel { - struct sh_tmu_priv *tmu; + struct sh_tmu_device *tmu; int irq; @@ -50,7 +50,7 @@ struct sh_tmu_channel { unsigned int enable_count; }; -struct sh_tmu_priv { +struct sh_tmu_device { struct platform_device *pdev; void __iomem *mapbase; @@ -436,59 +436,59 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, return 0; } -static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) +static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; int ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(tmu, 0, sizeof(*tmu)); + tmu->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&tmu->pdev->dev, "missing platform data\n"); goto err0; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, tmu); - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&tmu->pdev->dev, "failed to get I/O memory\n"); goto err0; } - p->channel.irq = platform_get_irq(p->pdev, 0); - if (p->channel.irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + tmu->channel.irq = platform_get_irq(tmu->pdev, 0); + if (tmu->channel.irq < 0) { + dev_err(&tmu->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (tmu->mapbase == NULL) { + dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "tmu_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); + if (IS_ERR(tmu->clk)) { + dev_err(&tmu->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(tmu->clk); goto err1; } - ret = clk_prepare(p->clk); + ret = clk_prepare(tmu->clk); if (ret < 0) goto err2; - p->channel.cs_enabled = false; - p->channel.enable_count = 0; - p->channel.tmu = p; + tmu->channel.cs_enabled = false; + tmu->channel.enable_count = 0; + tmu->channel.tmu = tmu; - ret = sh_tmu_register(&p->channel, (char *)dev_name(&p->pdev->dev), + ret = sh_tmu_register(&tmu->channel, (char *)dev_name(&tmu->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret < 0) @@ -497,18 +497,18 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) return 0; err3: - clk_unprepare(p->clk); + clk_unprepare(tmu->clk); err2: - clk_put(p->clk); + clk_put(tmu->clk); err1: - iounmap(p->mapbase); + iounmap(tmu->mapbase); err0: return ret; } static int sh_tmu_probe(struct platform_device *pdev) { - struct sh_tmu_priv *p = platform_get_drvdata(pdev); + struct sh_tmu_device *tmu = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -517,20 +517,20 @@ static int sh_tmu_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (tmu) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + tmu = kmalloc(sizeof(*tmu), GFP_KERNEL); + if (tmu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_tmu_setup(p, pdev); + ret = sh_tmu_setup(tmu, pdev); if (ret) { - kfree(p); + kfree(tmu); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v0.10.2 From a94ddaa6fcd46e168736027535b2d81b6a18883f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Split channel setup to separate function Move the channel setup code from sh_tmu_setup to a new sh_tmu_setup_channel function and call it from sh_tmu_setup. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 7013790..4779c97b 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -436,6 +436,28 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, return 0; } +static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, + struct sh_tmu_device *tmu) +{ + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + + memset(ch, 0, sizeof(*ch)); + ch->tmu = tmu; + + ch->irq = platform_get_irq(tmu->pdev, 0); + if (ch->irq < 0) { + dev_err(&tmu->pdev->dev, "failed to get irq\n"); + return ch->irq; + } + + ch->cs_enabled = false; + ch->enable_count = 0; + + return sh_tmu_register(ch, (char *)dev_name(&tmu->pdev->dev), + cfg->clockevent_rating, + cfg->clocksource_rating); +} + static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; @@ -459,12 +481,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) goto err0; } - tmu->channel.irq = platform_get_irq(tmu->pdev, 0); - if (tmu->channel.irq < 0) { - dev_err(&tmu->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); if (tmu->mapbase == NULL) { @@ -484,13 +500,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) if (ret < 0) goto err2; - tmu->channel.cs_enabled = false; - tmu->channel.enable_count = 0; - tmu->channel.tmu = tmu; - - ret = sh_tmu_register(&tmu->channel, (char *)dev_name(&tmu->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); + ret = sh_tmu_channel_setup(&tmu->channel, tmu); if (ret < 0) goto err3; -- cgit v0.10.2 From 84876d0505b15a2907696566a80a365993feab44 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 16:04:16 +0100 Subject: clocksource: sh_tmu: Constify name argument to sh_tmu_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 4779c97b..2c64e3f 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -292,7 +292,7 @@ static void sh_tmu_clocksource_resume(struct clocksource *cs) } static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clocksource *cs = &ch->cs; @@ -393,7 +393,7 @@ static void sh_tmu_clock_event_resume(struct clock_event_device *ced) } static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; int ret; @@ -424,7 +424,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, } } -static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, +static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { @@ -453,7 +453,7 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->cs_enabled = false; ch->enable_count = 0; - return sh_tmu_register(ch, (char *)dev_name(&tmu->pdev->dev), + return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); } -- cgit v0.10.2 From de693461bf9624ec12808f8c5524510364cc2a43 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Add memory base to sh_tmu_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 2c64e3f..a464ed8 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -40,6 +40,7 @@ struct sh_tmu_device; struct sh_tmu_channel { struct sh_tmu_device *tmu; + void __iomem *base; int irq; unsigned long rate; @@ -68,39 +69,35 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; - void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) - return ioread8(base - cfg->channel_offset); + return ioread8(ch->tmu->mapbase); offs = reg_nr << 2; if (reg_nr == TCR) - return ioread16(base + offs); + return ioread16(ch->base + offs); else - return ioread32(base + offs); + return ioread32(ch->base + offs); } static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; - void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, base - cfg->channel_offset); + iowrite8(value, ch->tmu->mapbase); return; } offs = reg_nr << 2; if (reg_nr == TCR) - iowrite16(value, base + offs); + iowrite16(value, ch->base + offs); else - iowrite32(value, base + offs); + iowrite32(value, ch->base + offs); } static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) @@ -481,13 +478,18 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) goto err0; } - /* map memory, let mapbase point to our channel */ - tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (tmu->mapbase == NULL) { + /* + * Map memory, let channel.base point to our channel and mapbase to the + * start/stop shared register. + */ + tmu->channel.base = ioremap_nocache(res->start, resource_size(res)); + if (tmu->channel.base == NULL) { dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } + tmu->mapbase = tmu->channel.base - cfg->channel_offset; + /* get hold of clock */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); if (IS_ERR(tmu->clk)) { @@ -511,7 +513,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) err2: clk_put(tmu->clk); err1: - iounmap(tmu->mapbase); + iounmap(tmu->channel.base); err0: return ret; } -- cgit v0.10.2 From fe68eb802ef8bf034735f37cb561ab814fb3b0d6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Add index to struct sh_tmu_channel Use the index as the timer start/stop bit and when printing messages to identify the channel. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index a464ed8..e304304 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -39,6 +39,7 @@ struct sh_tmu_device; struct sh_tmu_channel { struct sh_tmu_device *tmu; + unsigned int index; void __iomem *base; int irq; @@ -102,7 +103,6 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -110,9 +110,9 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) value = sh_tmu_read(ch, TSTR); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->index; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->index); sh_tmu_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_tmu_lock, flags); @@ -125,7 +125,8 @@ static int __sh_tmu_enable(struct sh_tmu_channel *ch) /* enable clock */ ret = clk_enable(ch->tmu->clk); if (ret) { - dev_err(&ch->tmu->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->tmu->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); return ret; } @@ -303,7 +304,8 @@ static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, cs->mask = CLOCKSOURCE_MASK(32); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&ch->tmu->pdev->dev, "used as clock source\n"); + dev_info(&ch->tmu->pdev->dev, "ch%u: used as clock source\n", + ch->index); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); @@ -349,12 +351,12 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->tmu->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_tmu_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: dev_info(&ch->tmu->pdev->dev, - "used for oneshot clock events\n"); + "ch%u: used for oneshot clock events\n", ch->index); sh_tmu_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_UNUSED: @@ -407,7 +409,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, ced->suspend = sh_tmu_clock_event_suspend; ced->resume = sh_tmu_clock_event_resume; - dev_info(&ch->tmu->pdev->dev, "used for clock events\n"); + dev_info(&ch->tmu->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); @@ -415,8 +418,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&ch->tmu->pdev->dev), ch); if (ret) { - dev_err(&ch->tmu->pdev->dev, "failed to request irq %d\n", - ch->irq); + dev_err(&ch->tmu->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, ch->irq); return; } } @@ -441,9 +444,19 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, memset(ch, 0, sizeof(*ch)); ch->tmu = tmu; + /* + * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps channel + * registers blocks at base + 2 + 12 * index, while all other variants + * map them at base + 4 + 12 * index. We can compute the index by just + * dividing by 12, the 2 bytes or 4 bytes offset being hidden by the + * integer division. + */ + ch->index = cfg->channel_offset / 12; + ch->irq = platform_get_irq(tmu->pdev, 0); if (ch->irq < 0) { - dev_err(&tmu->pdev->dev, "failed to get irq\n"); + dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return ch->irq; } -- cgit v0.10.2 From 3b77a83eeabb885c5fff02756eba50f446a2d83c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index e304304..26a9f7d 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -397,8 +397,6 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, struct clock_event_device *ced = &ch->ced; int ret; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; @@ -441,7 +439,6 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, { struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; - memset(ch, 0, sizeof(*ch)); ch->tmu = tmu; /* @@ -475,7 +472,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) int ret; ret = -ENXIO; - memset(tmu, 0, sizeof(*tmu)); tmu->pdev = pdev; if (!cfg) { @@ -547,7 +543,7 @@ static int sh_tmu_probe(struct platform_device *pdev) goto out; } - tmu = kmalloc(sizeof(*tmu), GFP_KERNEL); + tmu = kzalloc(sizeof(*tmu), GFP_KERNEL); if (tmu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v0.10.2 From a5de49f436e2bc498c1d13f6f8a9afaf19cb5f95 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 26a9f7d..55b7a37 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -58,7 +58,8 @@ struct sh_tmu_device { void __iomem *mapbase; struct clk *clk; - struct sh_tmu_channel channel; + struct sh_tmu_channel *channels; + unsigned int num_channels; }; static DEFINE_RAW_SPINLOCK(sh_tmu_lock); @@ -469,6 +470,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; + void __iomem *base; int ret; ret = -ENXIO; @@ -488,16 +490,16 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) } /* - * Map memory, let channel.base point to our channel and mapbase to the + * Map memory, let base point to our channel and mapbase to the * start/stop shared register. */ - tmu->channel.base = ioremap_nocache(res->start, resource_size(res)); - if (tmu->channel.base == NULL) { + base = ioremap_nocache(res->start, resource_size(res)); + if (base == NULL) { dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } - tmu->mapbase = tmu->channel.base - cfg->channel_offset; + tmu->mapbase = base - cfg->channel_offset; /* get hold of clock */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); @@ -511,18 +513,29 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) if (ret < 0) goto err2; - ret = sh_tmu_channel_setup(&tmu->channel, tmu); + tmu->channels = kzalloc(sizeof(*tmu->channels), GFP_KERNEL); + if (tmu->channels == NULL) { + ret = -ENOMEM; + goto err3; + } + + tmu->num_channels = 1; + + tmu->channels[0].base = base; + + ret = sh_tmu_channel_setup(&tmu->channels[0], tmu); if (ret < 0) goto err3; return 0; err3: + kfree(tmu->channels); clk_unprepare(tmu->clk); err2: clk_put(tmu->clk); err1: - iounmap(tmu->channel.base); + iounmap(base); err0: return ret; } -- cgit v0.10.2 From 5cfe2d151f8f55052f5463e725d3d3a4aa51335d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Jan 2014 00:33:08 +0100 Subject: clocksource: sh_tmu: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 55b7a37..63ed92d 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -69,6 +69,15 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TCNT 1 /* channel register */ #define TCR 2 /* channel register */ +#define TCR_UNF (1 << 8) +#define TCR_UNIE (1 << 5) +#define TCR_TPSC_CLK4 (0 << 0) +#define TCR_TPSC_CLK16 (1 << 0) +#define TCR_TPSC_CLK64 (2 << 0) +#define TCR_TPSC_CLK256 (3 << 0) +#define TCR_TPSC_CLK1024 (4 << 0) +#define TCR_TPSC_MASK (7 << 0) + static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { unsigned long offs; @@ -140,7 +149,7 @@ static int __sh_tmu_enable(struct sh_tmu_channel *ch) /* configure channel to parent clock / 4, irq off */ ch->rate = clk_get_rate(ch->tmu->clk) / 4; - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); /* enable channel */ sh_tmu_start_stop_ch(ch, 1); @@ -165,7 +174,7 @@ static void __sh_tmu_disable(struct sh_tmu_channel *ch) sh_tmu_start_stop_ch(ch, 0); /* disable interrupts in TMU block */ - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); /* stop clock */ clk_disable(ch->tmu->clk); @@ -195,7 +204,7 @@ static void sh_tmu_set_next(struct sh_tmu_channel *ch, unsigned long delta, sh_tmu_read(ch, TCR); /* enable interrupt */ - sh_tmu_write(ch, TCR, 0x0020); + sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4); /* reload delta value in case of periodic timer */ if (periodic) @@ -215,9 +224,9 @@ static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id) /* disable or acknowledge interrupt */ if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); else - sh_tmu_write(ch, TCR, 0x0020); + sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4); /* notify clockevent layer */ ch->ced.event_handler(&ch->ced); -- cgit v0.10.2 From f1010ed1a13ea38f495ebfa2fdb1f38b7f87301f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_tmu: Hardcode TMU clock event and source ratings to 200 All boards use clock event and clock source ratings of 200 for the TMU, hardcode it in the driver. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 63ed92d..fec9bed 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -300,12 +300,12 @@ static void sh_tmu_clocksource_resume(struct clocksource *cs) } static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clocksource *cs = &ch->cs; cs->name = name; - cs->rating = rating; + cs->rating = 200; cs->read = sh_tmu_clocksource_read; cs->enable = sh_tmu_clocksource_enable; cs->disable = sh_tmu_clocksource_disable; @@ -402,7 +402,7 @@ static void sh_tmu_clock_event_resume(struct clock_event_device *ced) } static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; int ret; @@ -410,7 +410,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; - ced->rating = rating; + ced->rating = 200; ced->cpumask = cpumask_of(0); ced->set_next_event = sh_tmu_clock_event_next; ced->set_mode = sh_tmu_clock_event_mode; @@ -433,13 +433,12 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, } static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, - unsigned long clockevent_rating, - unsigned long clocksource_rating) + bool clockevent, bool clocksource) { - if (clockevent_rating) - sh_tmu_register_clockevent(ch, name, clockevent_rating); - else if (clocksource_rating) - sh_tmu_register_clocksource(ch, name, clocksource_rating); + if (clockevent) + sh_tmu_register_clockevent(ch, name); + else if (clocksource) + sh_tmu_register_clocksource(ch, name); return 0; } @@ -471,8 +470,8 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->enable_count = 0; return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0); } static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) -- cgit v0.10.2 From 8c7f21e6739ad836f30561d641393a8417abdad3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 28 Jan 2014 12:36:48 +0100 Subject: clocksource: sh_tmu: Add support for multiple channels per device TMU hardware devices can support multiple channels, with global registers and per-channel registers. The sh_tmu driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index fec9bed..0306d31 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,6 +35,12 @@ #include #include +enum sh_tmu_model { + SH_TMU_LEGACY, + SH_TMU, + SH_TMU_SH3, +}; + struct sh_tmu_device; struct sh_tmu_channel { @@ -58,8 +64,13 @@ struct sh_tmu_device { void __iomem *mapbase; struct clk *clk; + enum sh_tmu_model model; + struct sh_tmu_channel *channels; unsigned int num_channels; + + bool has_clockevent; + bool has_clocksource; }; static DEFINE_RAW_SPINLOCK(sh_tmu_lock); @@ -82,8 +93,16 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { unsigned long offs; - if (reg_nr == TSTR) - return ioread8(ch->tmu->mapbase); + if (reg_nr == TSTR) { + switch (ch->tmu->model) { + case SH_TMU_LEGACY: + return ioread8(ch->tmu->mapbase); + case SH_TMU_SH3: + return ioread8(ch->tmu->mapbase + 2); + case SH_TMU: + return ioread8(ch->tmu->mapbase + 4); + } + } offs = reg_nr << 2; @@ -99,8 +118,14 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, ch->tmu->mapbase); - return; + switch (ch->tmu->model) { + case SH_TMU_LEGACY: + return iowrite8(value, ch->tmu->mapbase); + case SH_TMU_SH3: + return iowrite8(value, ch->tmu->mapbase + 2); + case SH_TMU: + return iowrite8(value, ch->tmu->mapbase + 4); + } } offs = reg_nr << 2; @@ -435,31 +460,49 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, bool clockevent, bool clocksource) { - if (clockevent) + if (clockevent) { + ch->tmu->has_clockevent = true; sh_tmu_register_clockevent(ch, name); - else if (clocksource) + } else if (clocksource) { + ch->tmu->has_clocksource = true; sh_tmu_register_clocksource(ch, name); + } return 0; } -static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, +static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index, + bool clockevent, bool clocksource, struct sh_tmu_device *tmu) { - struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + /* Skip unused channels. */ + if (!clockevent && !clocksource) + return 0; ch->tmu = tmu; - /* - * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps channel - * registers blocks at base + 2 + 12 * index, while all other variants - * map them at base + 4 + 12 * index. We can compute the index by just - * dividing by 12, the 2 bytes or 4 bytes offset being hidden by the - * integer division. - */ - ch->index = cfg->channel_offset / 12; + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + + /* + * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps + * channel registers blocks at base + 2 + 12 * index, while all + * other variants map them at base + 4 + 12 * index. We can + * compute the index by just dividing by 12, the 2 bytes or 4 + * bytes offset being hidden by the integer division. + */ + ch->index = cfg->channel_offset / 12; + ch->base = tmu->mapbase + cfg->channel_offset; + } else { + ch->index = index; + + if (tmu->model == SH_TMU_SH3) + ch->base = tmu->mapbase + 4 + ch->index * 12; + else + ch->base = tmu->mapbase + 8 + ch->index * 12; + } - ch->irq = platform_get_irq(tmu->pdev, 0); + ch->irq = platform_get_irq(tmu->pdev, ch->index); if (ch->irq < 0) { dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n", ch->index); @@ -470,88 +513,127 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->enable_count = 0; return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), - cfg->clockevent_rating != 0, - cfg->clocksource_rating != 0); + clockevent, clocksource); } -static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) +static int sh_tmu_map_memory(struct sh_tmu_device *tmu) { - struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - void __iomem *base; - int ret; - ret = -ENXIO; - - tmu->pdev = pdev; - - if (!cfg) { - dev_err(&tmu->pdev->dev, "missing platform data\n"); - goto err0; - } - - platform_set_drvdata(pdev, tmu); res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&tmu->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } + tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (tmu->mapbase == NULL) + return -ENXIO; + /* - * Map memory, let base point to our channel and mapbase to the - * start/stop shared register. + * In legacy platform device configuration (with one device per channel) + * the resource points to the channel base address. */ - base = ioremap_nocache(res->start, resource_size(res)); - if (base == NULL) { - dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + tmu->mapbase -= cfg->channel_offset; } - tmu->mapbase = base - cfg->channel_offset; + return 0; +} - /* get hold of clock */ +static void sh_tmu_unmap_memory(struct sh_tmu_device *tmu) +{ + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + tmu->mapbase += cfg->channel_offset; + } + + iounmap(tmu->mapbase); +} + +static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int i; + int ret; + + if (!cfg) { + dev_err(&tmu->pdev->dev, "missing platform data\n"); + return -ENXIO; + } + + tmu->pdev = pdev; + tmu->model = id->driver_data; + + /* Get hold of clock. */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); if (IS_ERR(tmu->clk)) { dev_err(&tmu->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(tmu->clk); - goto err1; + return PTR_ERR(tmu->clk); } ret = clk_prepare(tmu->clk); if (ret < 0) - goto err2; + goto err_clk_put; + + /* Map the memory resource. */ + ret = sh_tmu_map_memory(tmu); + if (ret < 0) { + dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); + goto err_clk_unprepare; + } - tmu->channels = kzalloc(sizeof(*tmu->channels), GFP_KERNEL); + /* Allocate and setup the channels. */ + if (tmu->model == SH_TMU_LEGACY) + tmu->num_channels = 1; + else + tmu->num_channels = hweight8(cfg->channels_mask); + + tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels, + GFP_KERNEL); if (tmu->channels == NULL) { ret = -ENOMEM; - goto err3; + goto err_unmap; } - tmu->num_channels = 1; - - tmu->channels[0].base = base; + if (tmu->model == SH_TMU_LEGACY) { + ret = sh_tmu_channel_setup(&tmu->channels[0], 0, + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0, tmu); + if (ret < 0) + goto err_unmap; + } else { + /* + * Use the first channel as a clock event device and the second + * channel as a clock source. + */ + for (i = 0; i < tmu->num_channels; ++i) { + ret = sh_tmu_channel_setup(&tmu->channels[i], i, + i == 0, i == 1, tmu); + if (ret < 0) + goto err_unmap; + } + } - ret = sh_tmu_channel_setup(&tmu->channels[0], tmu); - if (ret < 0) - goto err3; + platform_set_drvdata(pdev, tmu); return 0; - err3: +err_unmap: kfree(tmu->channels); + sh_tmu_unmap_memory(tmu); +err_clk_unprepare: clk_unprepare(tmu->clk); - err2: +err_clk_put: clk_put(tmu->clk); - err1: - iounmap(base); - err0: return ret; } static int sh_tmu_probe(struct platform_device *pdev) { struct sh_tmu_device *tmu = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -580,7 +662,7 @@ static int sh_tmu_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating || cfg->clocksource_rating) + if (tmu->has_clockevent || tmu->has_clocksource) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -593,12 +675,21 @@ static int sh_tmu_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent and clocksource */ } +static const struct platform_device_id sh_tmu_id_table[] = { + { "sh_tmu", SH_TMU_LEGACY }, + { "sh-tmu", SH_TMU }, + { "sh-tmu-sh3", SH_TMU_SH3 }, + { } +}; +MODULE_DEVICE_TABLE(platform, sh_tmu_id_table); + static struct platform_driver sh_tmu_device_driver = { .probe = sh_tmu_probe, .remove = sh_tmu_remove, .driver = { .name = "sh_tmu", - } + }, + .id_table = sh_tmu_id_table, }; static int __init sh_tmu_init(void) -- cgit v0.10.2 From a27d922749f3be0a88f7e0aeb507c373703c08ee Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 00:35:18 +0100 Subject: clocksource: sh_tmu: Rename clock to "fck" in the non-legacy case The sh_tmu driver gets the TMU functional clock using a connection ID of "tmu_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "tmu_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 0306d31..cf07797 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -568,7 +568,8 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) tmu->model = id->driver_data; /* Get hold of clock. */ - tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); + tmu->clk = clk_get(&tmu->pdev->dev, + tmu->model == SH_TMU_LEGACY ? "tmu_fck" : "fck"); if (IS_ERR(tmu->clk)) { dev_err(&tmu->pdev->dev, "cannot get clock\n"); return PTR_ERR(tmu->clk); -- cgit v0.10.2 From 6b96c15b034813ec0b46e5bebbf8cffae0ac72d0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 01:25:50 +0100 Subject: clocksource: sh_tmu: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index cf07797..981f8d3 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v0.10.2 From 13931f8065fabff117828999e007f62a5cabea34 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 12 Feb 2014 16:56:44 +0100 Subject: clocksource: sh_tmu: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 981f8d3..4ba2c0f 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -13,23 +13,23 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include +#include #include -#include -#include #include -#include -#include #include -#include +#include #include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include enum sh_tmu_model { SH_TMU_LEGACY, -- cgit v0.10.2 From 276bee05d8b72e98d530b55161e0a2131da99f58 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_mtu2: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index e30d76e..77992e0 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -37,7 +37,7 @@ struct sh_mtu2_priv { void __iomem *mapbase; struct clk *clk; - struct irqaction irqaction; + int irq; struct platform_device *pdev; unsigned long rate; unsigned long periodic; @@ -244,10 +244,11 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, dev_info(&p->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); - ret = setup_irq(p->irqaction.irq, &p->irqaction); + ret = request_irq(p->irq, sh_mtu2_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", - p->irqaction.irq); + dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); return; } } @@ -265,7 +266,7 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - int irq, ret; + int ret; ret = -ENXIO; memset(p, 0, sizeof(*p)); @@ -284,8 +285,8 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - irq = platform_get_irq(p->pdev, 0); - if (irq < 0) { + p->irq = platform_get_irq(p->pdev, 0); + if (p->irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -297,13 +298,6 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - /* setup data for setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_mtu2_interrupt; - p->irqaction.dev_id = p; - p->irqaction.irq = irq; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "mtu2_fck"); if (IS_ERR(p->clk)) { -- cgit v0.10.2 From f92d62f53973466cccb25900c2597ff6df950d74 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 12:59:54 +0100 Subject: clocksource: sh_mtu2: Turn sh_mtu2_priv fields into local variables The rate and periodic fields are used in a single function only, as local variables. Remove them from the structure. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 77992e0..6668455 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -39,8 +39,6 @@ struct sh_mtu2_priv { struct clk *clk; int irq; struct platform_device *pdev; - unsigned long rate; - unsigned long periodic; struct clock_event_device ced; }; @@ -122,6 +120,8 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) static int sh_mtu2_enable(struct sh_mtu2_priv *p) { + unsigned long periodic; + unsigned long rate; int ret; pm_runtime_get_sync(&p->pdev->dev); @@ -137,13 +137,13 @@ static int sh_mtu2_enable(struct sh_mtu2_priv *p) /* make sure channel is disabled */ sh_mtu2_start_stop_ch(p, 0); - p->rate = clk_get_rate(p->clk) / 64; - p->periodic = (p->rate + HZ/2) / HZ; + rate = clk_get_rate(p->clk) / 64; + periodic = (rate + HZ/2) / HZ; /* "Periodic Counter Operation" */ sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */ sh_mtu2_write(p, TIOR, 0); - sh_mtu2_write(p, TGR, p->periodic); + sh_mtu2_write(p, TGR, periodic); sh_mtu2_write(p, TCNT, 0); sh_mtu2_write(p, TMDR, 0); sh_mtu2_write(p, TIER, 0x01); -- cgit v0.10.2 From 42752cc619c0ee619b56f86932ce42b00adb5052 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 12:58:30 +0100 Subject: clocksource: sh_mtu2: Split channel fields from sh_mtu2_priv Create a new sh_mtu2_channel structure to hold the channel-specific fields in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 6668455..e509f41 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -34,12 +34,21 @@ #include #include +struct sh_mtu2_priv; + +struct sh_mtu2_channel { + struct sh_mtu2_priv *mtu; + int irq; + struct clock_event_device ced; +}; + struct sh_mtu2_priv { + struct platform_device *pdev; + void __iomem *mapbase; struct clk *clk; - int irq; - struct platform_device *pdev; - struct clock_event_device ced; + + struct sh_mtu2_channel channel; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -63,10 +72,10 @@ static unsigned long mtu2_reg_offs[] = { [TGR] = 8, }; -static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr) +static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; + void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) @@ -80,11 +89,11 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr) return ioread8(base + offs); } -static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr, +static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; + void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) { @@ -100,100 +109,100 @@ static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr, iowrite8(value, base + offs); } -static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) +static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_mtu2_lock, flags); - value = sh_mtu2_read(p, TSTR); + value = sh_mtu2_read(ch, TSTR); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_mtu2_write(p, TSTR, value); + sh_mtu2_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags); } -static int sh_mtu2_enable(struct sh_mtu2_priv *p) +static int sh_mtu2_enable(struct sh_mtu2_channel *ch) { unsigned long periodic; unsigned long rate; int ret; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->mtu->pdev->dev); + dev_pm_syscore_device(&ch->mtu->pdev->dev, true); /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->mtu->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->mtu->pdev->dev, "cannot enable clock\n"); return ret; } /* make sure channel is disabled */ - sh_mtu2_start_stop_ch(p, 0); + sh_mtu2_start_stop_ch(ch, 0); - rate = clk_get_rate(p->clk) / 64; + rate = clk_get_rate(ch->mtu->clk) / 64; periodic = (rate + HZ/2) / HZ; /* "Periodic Counter Operation" */ - sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */ - sh_mtu2_write(p, TIOR, 0); - sh_mtu2_write(p, TGR, periodic); - sh_mtu2_write(p, TCNT, 0); - sh_mtu2_write(p, TMDR, 0); - sh_mtu2_write(p, TIER, 0x01); + sh_mtu2_write(ch, TCR, 0x23); /* TGRA clear, divide clock by 64 */ + sh_mtu2_write(ch, TIOR, 0); + sh_mtu2_write(ch, TGR, periodic); + sh_mtu2_write(ch, TCNT, 0); + sh_mtu2_write(ch, TMDR, 0); + sh_mtu2_write(ch, TIER, 0x01); /* enable channel */ - sh_mtu2_start_stop_ch(p, 1); + sh_mtu2_start_stop_ch(ch, 1); return 0; } -static void sh_mtu2_disable(struct sh_mtu2_priv *p) +static void sh_mtu2_disable(struct sh_mtu2_channel *ch) { /* disable channel */ - sh_mtu2_start_stop_ch(p, 0); + sh_mtu2_start_stop_ch(ch, 0); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->mtu->clk); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->mtu->pdev->dev, false); + pm_runtime_put(&ch->mtu->pdev->dev); } static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) { - struct sh_mtu2_priv *p = dev_id; + struct sh_mtu2_channel *ch = dev_id; /* acknowledge interrupt */ - sh_mtu2_read(p, TSR); - sh_mtu2_write(p, TSR, 0xfe); + sh_mtu2_read(ch, TSR); + sh_mtu2_write(ch, TSR, 0xfe); /* notify clockevent layer */ - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); return IRQ_HANDLED; } -static struct sh_mtu2_priv *ced_to_sh_mtu2(struct clock_event_device *ced) +static struct sh_mtu2_channel *ced_to_sh_mtu2(struct clock_event_device *ced) { - return container_of(ced, struct sh_mtu2_priv, ced); + return container_of(ced, struct sh_mtu2_channel, ced); } static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_mtu2_priv *p = ced_to_sh_mtu2(ced); + struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced); int disabled = 0; /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: - sh_mtu2_disable(p); + sh_mtu2_disable(ch); disabled = 1; break; default: @@ -202,12 +211,13 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_mtu2_enable(p); + dev_info(&ch->mtu->pdev->dev, + "used for periodic clock events\n"); + sh_mtu2_enable(ch); break; case CLOCK_EVT_MODE_UNUSED: if (!disabled) - sh_mtu2_disable(p); + sh_mtu2_disable(ch); break; case CLOCK_EVT_MODE_SHUTDOWN: default: @@ -217,18 +227,18 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->pdev->dev); + pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->pdev->dev); + pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } -static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, +static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; int ret; memset(ced, 0, sizeof(*ced)); @@ -241,23 +251,24 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->mtu->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); - ret = request_irq(p->irq, sh_mtu2_interrupt, + ret = request_irq(ch->irq, sh_mtu2_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&ch->mtu->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); + dev_err(&ch->mtu->pdev->dev, "failed to request irq %d\n", + ch->irq); return; } } -static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name, +static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, unsigned long clockevent_rating) { if (clockevent_rating) - sh_mtu2_register_clockevent(p, name, clockevent_rating); + sh_mtu2_register_clockevent(ch, name, clockevent_rating); return 0; } @@ -285,8 +296,8 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - p->irq = platform_get_irq(p->pdev, 0); - if (p->irq < 0) { + p->channel.irq = platform_get_irq(p->pdev, 0); + if (p->channel.irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -310,7 +321,9 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) if (ret < 0) goto err2; - ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev), + p->channel.mtu = p; + + ret = sh_mtu2_register(&p->channel, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating); if (ret < 0) goto err3; -- cgit v0.10.2 From 7dad72de1b475d02935e5c79c218637b6c63108b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:04:48 +0100 Subject: clocksource: sh_mtu2: Rename struct sh_mtu2_priv to sh_mtu2_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index e509f41..256621c 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -34,15 +34,15 @@ #include #include -struct sh_mtu2_priv; +struct sh_mtu2_device; struct sh_mtu2_channel { - struct sh_mtu2_priv *mtu; + struct sh_mtu2_device *mtu; int irq; struct clock_event_device ced; }; -struct sh_mtu2_priv { +struct sh_mtu2_device { struct platform_device *pdev; void __iomem *mapbase; @@ -273,75 +273,76 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, return 0; } -static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) +static int sh_mtu2_setup(struct sh_mtu2_device *mtu, + struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; int ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(mtu, 0, sizeof(*mtu)); + mtu->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&mtu->pdev->dev, "missing platform data\n"); goto err0; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, mtu); - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(mtu->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&mtu->pdev->dev, "failed to get I/O memory\n"); goto err0; } - p->channel.irq = platform_get_irq(p->pdev, 0); - if (p->channel.irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + mtu->channel.irq = platform_get_irq(mtu->pdev, 0); + if (mtu->channel.irq < 0) { + dev_err(&mtu->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (mtu->mapbase == NULL) { + dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "mtu2_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); + if (IS_ERR(mtu->clk)) { + dev_err(&mtu->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(mtu->clk); goto err1; } - ret = clk_prepare(p->clk); + ret = clk_prepare(mtu->clk); if (ret < 0) goto err2; - p->channel.mtu = p; + mtu->channel.mtu = mtu; - ret = sh_mtu2_register(&p->channel, (char *)dev_name(&p->pdev->dev), + ret = sh_mtu2_register(&mtu->channel, (char *)dev_name(&mtu->pdev->dev), cfg->clockevent_rating); if (ret < 0) goto err3; return 0; err3: - clk_unprepare(p->clk); + clk_unprepare(mtu->clk); err2: - clk_put(p->clk); + clk_put(mtu->clk); err1: - iounmap(p->mapbase); + iounmap(mtu->mapbase); err0: return ret; } static int sh_mtu2_probe(struct platform_device *pdev) { - struct sh_mtu2_priv *p = platform_get_drvdata(pdev); + struct sh_mtu2_device *mtu = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -350,20 +351,20 @@ static int sh_mtu2_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (mtu) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + mtu = kmalloc(sizeof(*mtu), GFP_KERNEL); + if (mtu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_mtu2_setup(p, pdev); + ret = sh_mtu2_setup(mtu, pdev); if (ret) { - kfree(p); + kfree(mtu); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v0.10.2 From 2e1a53265d550002fdd1658778854d56ae4cadc1 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:11:23 +0100 Subject: clocksource: sh_mtu2: Split channel setup to separate function Move the channel setup code from sh_mtu2_setup to a new sh_mtu2_setup_channel function and call it from sh_mtu2_setup. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 256621c..8fd7059 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -273,6 +273,24 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, return 0; } +static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, + struct sh_mtu2_device *mtu) +{ + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + + memset(ch, 0, sizeof(*ch)); + ch->mtu = mtu; + + ch->irq = platform_get_irq(mtu->pdev, 0); + if (ch->irq < 0) { + dev_err(&mtu->pdev->dev, "failed to get irq\n"); + return ch->irq; + } + + return sh_mtu2_register(ch, (char *)dev_name(&mtu->pdev->dev), + cfg->clockevent_rating); +} + static int sh_mtu2_setup(struct sh_mtu2_device *mtu, struct platform_device *pdev) { @@ -297,12 +315,6 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, goto err0; } - mtu->channel.irq = platform_get_irq(mtu->pdev, 0); - if (mtu->channel.irq < 0) { - dev_err(&mtu->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); if (mtu->mapbase == NULL) { @@ -322,10 +334,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, if (ret < 0) goto err2; - mtu->channel.mtu = mtu; - - ret = sh_mtu2_register(&mtu->channel, (char *)dev_name(&mtu->pdev->dev), - cfg->clockevent_rating); + ret = sh_mtu2_setup_channel(&mtu->channel, mtu); if (ret < 0) goto err3; -- cgit v0.10.2 From aa83804af705731d2802b80fb4b94a79045d31a3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:57:14 +0100 Subject: clocksource: sh_mtu2: Constify name argument to sh_mtu2_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 8fd7059..2fe3ab4c 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -236,7 +236,7 @@ static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) } static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; int ret; @@ -264,7 +264,7 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, } } -static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, +static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, unsigned long clockevent_rating) { if (clockevent_rating) @@ -287,7 +287,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, return ch->irq; } - return sh_mtu2_register(ch, (char *)dev_name(&mtu->pdev->dev), + return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), cfg->clockevent_rating); } -- cgit v0.10.2 From da90a1c67751a412499a9f5698c3bf0bf80f65a6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:04:24 +0100 Subject: clocksource: sh_mtu2: Add memory base to sh_mtu2_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 2fe3ab4c..97714ce 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -38,7 +38,10 @@ struct sh_mtu2_device; struct sh_mtu2_channel { struct sh_mtu2_device *mtu; + + void __iomem *base; int irq; + struct clock_event_device ced; }; @@ -74,39 +77,35 @@ static unsigned long mtu2_reg_offs[] = { static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; - void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) - return ioread8(base + cfg->channel_offset); + return ioread8(ch->mtu->mapbase); offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) - return ioread16(base + offs); + return ioread16(ch->base + offs); else - return ioread8(base + offs); + return ioread8(ch->base + offs); } static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; - void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, base + cfg->channel_offset); + iowrite8(value, ch->mtu->mapbase); return; } offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) - iowrite16(value, base + offs); + iowrite16(value, ch->base + offs); else - iowrite8(value, base + offs); + iowrite8(value, ch->base + offs); } static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) @@ -315,13 +314,18 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, goto err0; } - /* map memory, let mapbase point to our channel */ - mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (mtu->mapbase == NULL) { + /* + * Map memory, let channel.base point to our channel and mapbase to the + * start/stop shared register. + */ + mtu->channel.base = ioremap_nocache(res->start, resource_size(res)); + if (mtu->channel.base == NULL) { dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } + mtu->mapbase = mtu->channel.base + cfg->channel_offset; + /* get hold of clock */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); if (IS_ERR(mtu->clk)) { @@ -344,7 +348,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, err2: clk_put(mtu->clk); err1: - iounmap(mtu->mapbase); + iounmap(mtu->channel.base); err0: return ret; } -- cgit v0.10.2 From d2b93177065fd8e1e18f4f42880326e0881ff457 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:17:26 +0100 Subject: clocksource: sh_mtu2: Add index to struct sh_mtu2_channel Use the index as the timer start/stop bit and when printing messages to identify the channel. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 97714ce..61827c66 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -38,6 +38,7 @@ struct sh_mtu2_device; struct sh_mtu2_channel { struct sh_mtu2_device *mtu; + unsigned int index; void __iomem *base; int irq; @@ -110,7 +111,6 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -118,9 +118,9 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) value = sh_mtu2_read(ch, TSTR); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->index; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->index); sh_mtu2_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags); @@ -138,7 +138,8 @@ static int sh_mtu2_enable(struct sh_mtu2_channel *ch) /* enable clock */ ret = clk_enable(ch->mtu->clk); if (ret) { - dev_err(&ch->mtu->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->mtu->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); return ret; } @@ -211,7 +212,7 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->mtu->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_mtu2_enable(ch); break; case CLOCK_EVT_MODE_UNUSED: @@ -250,15 +251,16 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; - dev_info(&ch->mtu->pdev->dev, "used for clock events\n"); + dev_info(&ch->mtu->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_register_device(ced); ret = request_irq(ch->irq, sh_mtu2_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&ch->mtu->pdev->dev), ch); if (ret) { - dev_err(&ch->mtu->pdev->dev, "failed to request irq %d\n", - ch->irq); + dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, ch->irq); return; } } @@ -279,10 +281,12 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, memset(ch, 0, sizeof(*ch)); ch->mtu = mtu; + ch->index = cfg->timer_bit; ch->irq = platform_get_irq(mtu->pdev, 0); if (ch->irq < 0) { - dev_err(&mtu->pdev->dev, "failed to get irq\n"); + dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return ch->irq; } -- cgit v0.10.2 From 810c651369b343618d949826e0acd0df1b8b06eb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:10:55 +0100 Subject: clocksource: sh_mtu2: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 61827c66..94a5342 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -241,8 +241,6 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, struct clock_event_device *ced = &ch->ced; int ret; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->rating = rating; @@ -279,7 +277,6 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, { struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; - memset(ch, 0, sizeof(*ch)); ch->mtu = mtu; ch->index = cfg->timer_bit; @@ -302,7 +299,6 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, int ret; ret = -ENXIO; - memset(mtu, 0, sizeof(*mtu)); mtu->pdev = pdev; if (!cfg) { @@ -373,7 +369,7 @@ static int sh_mtu2_probe(struct platform_device *pdev) goto out; } - mtu = kmalloc(sizeof(*mtu), GFP_KERNEL); + mtu = kzalloc(sizeof(*mtu), GFP_KERNEL); if (mtu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v0.10.2 From c54ccb431ce6ce813bb850e8659991fc4c5bc6bc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:23:00 +0100 Subject: clocksource: sh_mtu2: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 94a5342..45e1e85 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -52,7 +52,8 @@ struct sh_mtu2_device { void __iomem *mapbase; struct clk *clk; - struct sh_mtu2_channel channel; + struct sh_mtu2_channel *channels; + unsigned int num_channels; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -296,6 +297,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; + void __iomem *base; int ret; ret = -ENXIO; @@ -315,16 +317,16 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, } /* - * Map memory, let channel.base point to our channel and mapbase to the + * Map memory, let base point to our channel and mapbase to the * start/stop shared register. */ - mtu->channel.base = ioremap_nocache(res->start, resource_size(res)); - if (mtu->channel.base == NULL) { + base = ioremap_nocache(res->start, resource_size(res)); + if (base == NULL) { dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } - mtu->mapbase = mtu->channel.base + cfg->channel_offset; + mtu->mapbase = base + cfg->channel_offset; /* get hold of clock */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); @@ -338,17 +340,28 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, if (ret < 0) goto err2; - ret = sh_mtu2_setup_channel(&mtu->channel, mtu); + mtu->channels = kzalloc(sizeof(*mtu->channels), GFP_KERNEL); + if (mtu->channels == NULL) { + ret = -ENOMEM; + goto err3; + } + + mtu->num_channels = 1; + + mtu->channels[0].base = base; + + ret = sh_mtu2_setup_channel(&mtu->channels[0], mtu); if (ret < 0) goto err3; return 0; err3: + kfree(mtu->channels); clk_unprepare(mtu->clk); err2: clk_put(mtu->clk); err1: - iounmap(mtu->channel.base); + iounmap(base); err0: return ret; } -- cgit v0.10.2 From f992c2410bd31b7c80ba8cc8b989d91b9cac3c30 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:16:25 +0100 Subject: clocksource: sh_mtu2: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 45e1e85..2cf0048 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -67,6 +67,88 @@ static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); #define TCNT 5 /* channel register */ #define TGR 6 /* channel register */ +#define TCR_CCLR_NONE (0 << 5) +#define TCR_CCLR_TGRA (1 << 5) +#define TCR_CCLR_TGRB (2 << 5) +#define TCR_CCLR_SYNC (3 << 5) +#define TCR_CCLR_TGRC (5 << 5) +#define TCR_CCLR_TGRD (6 << 5) +#define TCR_CCLR_MASK (7 << 5) +#define TCR_CKEG_RISING (0 << 3) +#define TCR_CKEG_FALLING (1 << 3) +#define TCR_CKEG_BOTH (2 << 3) +#define TCR_CKEG_MASK (3 << 3) +/* Values 4 to 7 are channel-dependent */ +#define TCR_TPSC_P1 (0 << 0) +#define TCR_TPSC_P4 (1 << 0) +#define TCR_TPSC_P16 (2 << 0) +#define TCR_TPSC_P64 (3 << 0) +#define TCR_TPSC_CH0_TCLKA (4 << 0) +#define TCR_TPSC_CH0_TCLKB (5 << 0) +#define TCR_TPSC_CH0_TCLKC (6 << 0) +#define TCR_TPSC_CH0_TCLKD (7 << 0) +#define TCR_TPSC_CH1_TCLKA (4 << 0) +#define TCR_TPSC_CH1_TCLKB (5 << 0) +#define TCR_TPSC_CH1_P256 (6 << 0) +#define TCR_TPSC_CH1_TCNT2 (7 << 0) +#define TCR_TPSC_CH2_TCLKA (4 << 0) +#define TCR_TPSC_CH2_TCLKB (5 << 0) +#define TCR_TPSC_CH2_TCLKC (6 << 0) +#define TCR_TPSC_CH2_P1024 (7 << 0) +#define TCR_TPSC_CH34_P256 (4 << 0) +#define TCR_TPSC_CH34_P1024 (5 << 0) +#define TCR_TPSC_CH34_TCLKA (6 << 0) +#define TCR_TPSC_CH34_TCLKB (7 << 0) +#define TCR_TPSC_MASK (7 << 0) + +#define TMDR_BFE (1 << 6) +#define TMDR_BFB (1 << 5) +#define TMDR_BFA (1 << 4) +#define TMDR_MD_NORMAL (0 << 0) +#define TMDR_MD_PWM_1 (2 << 0) +#define TMDR_MD_PWM_2 (3 << 0) +#define TMDR_MD_PHASE_1 (4 << 0) +#define TMDR_MD_PHASE_2 (5 << 0) +#define TMDR_MD_PHASE_3 (6 << 0) +#define TMDR_MD_PHASE_4 (7 << 0) +#define TMDR_MD_PWM_SYNC (8 << 0) +#define TMDR_MD_PWM_COMP_CREST (13 << 0) +#define TMDR_MD_PWM_COMP_TROUGH (14 << 0) +#define TMDR_MD_PWM_COMP_BOTH (15 << 0) +#define TMDR_MD_MASK (15 << 0) + +#define TIOC_IOCH(n) ((n) << 4) +#define TIOC_IOCL(n) ((n) << 0) +#define TIOR_OC_RETAIN (0 << 0) +#define TIOR_OC_0_CLEAR (1 << 0) +#define TIOR_OC_0_SET (2 << 0) +#define TIOR_OC_0_TOGGLE (3 << 0) +#define TIOR_OC_1_CLEAR (5 << 0) +#define TIOR_OC_1_SET (6 << 0) +#define TIOR_OC_1_TOGGLE (7 << 0) +#define TIOR_IC_RISING (8 << 0) +#define TIOR_IC_FALLING (9 << 0) +#define TIOR_IC_BOTH (10 << 0) +#define TIOR_IC_TCNT (12 << 0) +#define TIOR_MASK (15 << 0) + +#define TIER_TTGE (1 << 7) +#define TIER_TTGE2 (1 << 6) +#define TIER_TCIEU (1 << 5) +#define TIER_TCIEV (1 << 4) +#define TIER_TGIED (1 << 3) +#define TIER_TGIEC (1 << 2) +#define TIER_TGIEB (1 << 1) +#define TIER_TGIEA (1 << 0) + +#define TSR_TCFD (1 << 7) +#define TSR_TCFU (1 << 5) +#define TSR_TCFV (1 << 4) +#define TSR_TGFD (1 << 3) +#define TSR_TGFC (1 << 2) +#define TSR_TGFB (1 << 1) +#define TSR_TGFA (1 << 0) + static unsigned long mtu2_reg_offs[] = { [TCR] = 0, [TMDR] = 1, @@ -150,13 +232,17 @@ static int sh_mtu2_enable(struct sh_mtu2_channel *ch) rate = clk_get_rate(ch->mtu->clk) / 64; periodic = (rate + HZ/2) / HZ; - /* "Periodic Counter Operation" */ - sh_mtu2_write(ch, TCR, 0x23); /* TGRA clear, divide clock by 64 */ - sh_mtu2_write(ch, TIOR, 0); + /* + * "Periodic Counter Operation" + * Clear on TGRA compare match, divide clock by 64. + */ + sh_mtu2_write(ch, TCR, TCR_CCLR_TGRA | TCR_TPSC_P64); + sh_mtu2_write(ch, TIOR, TIOC_IOCH(TIOR_OC_0_CLEAR) | + TIOC_IOCL(TIOR_OC_0_CLEAR)); sh_mtu2_write(ch, TGR, periodic); sh_mtu2_write(ch, TCNT, 0); - sh_mtu2_write(ch, TMDR, 0); - sh_mtu2_write(ch, TIER, 0x01); + sh_mtu2_write(ch, TMDR, TMDR_MD_NORMAL); + sh_mtu2_write(ch, TIER, TIER_TGIEA); /* enable channel */ sh_mtu2_start_stop_ch(ch, 1); @@ -182,7 +268,7 @@ static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) /* acknowledge interrupt */ sh_mtu2_read(ch, TSR); - sh_mtu2_write(ch, TSR, 0xfe); + sh_mtu2_write(ch, TSR, ~TSR_TGFA); /* notify clockevent layer */ ch->ced.event_handler(&ch->ced); -- cgit v0.10.2 From 3cc950479891040366629247357512f1cc928da3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:22:19 +0100 Subject: clocksource: sh_mtu2: Set cpumask to cpu_possible_mask The MTU2 is not tied to CPU0, make it usable on any CPU. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 2cf0048..702ce60 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -331,7 +331,7 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->rating = rating; - ced->cpumask = cpumask_of(0); + ced->cpumask = cpu_possible_mask; ced->set_mode = sh_mtu2_clock_event_mode; ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; -- cgit v0.10.2 From 207e21a9732a27f58843ccae1c9644f3a1636b66 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:19:41 +0100 Subject: clocksource: sh_mtu2: Hardcode MTU2 clock event rating to 200 All boards use clock event ratings of 200 for the MTU2, hardcode it in the driver. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 702ce60..14cc7b6 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -323,14 +323,14 @@ static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) } static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; int ret; ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; - ced->rating = rating; + ced->rating = 200; ced->cpumask = cpu_possible_mask; ced->set_mode = sh_mtu2_clock_event_mode; ced->suspend = sh_mtu2_clock_event_suspend; @@ -351,10 +351,10 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, } static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, - unsigned long clockevent_rating) + bool clockevent) { - if (clockevent_rating) - sh_mtu2_register_clockevent(ch, name, clockevent_rating); + if (clockevent) + sh_mtu2_register_clockevent(ch, name); return 0; } @@ -375,7 +375,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, } return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), - cfg->clockevent_rating); + cfg->clockevent_rating != 0); } static int sh_mtu2_setup(struct sh_mtu2_device *mtu, -- cgit v0.10.2 From faf3f4f8c805f5f8a786ba544c94bf3e01838388 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 18:05:45 +0100 Subject: clocksource: sh_mtu2: Add support for multiple channels per device MTU2 hardware devices can support multiple channels, with global registers and per-channel registers. The sh_mtu2 driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 14cc7b6..7cc6d942 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -54,6 +54,9 @@ struct sh_mtu2_device { struct sh_mtu2_channel *channels; unsigned int num_channels; + + bool legacy; + bool has_clockevent; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -163,8 +166,12 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { unsigned long offs; - if (reg_nr == TSTR) - return ioread8(ch->mtu->mapbase); + if (reg_nr == TSTR) { + if (ch->mtu->legacy) + return ioread8(ch->mtu->mapbase); + else + return ioread8(ch->mtu->mapbase + 0x280); + } offs = mtu2_reg_offs[reg_nr]; @@ -180,8 +187,10 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, ch->mtu->mapbase); - return; + if (ch->mtu->legacy) + return iowrite8(value, ch->mtu->mapbase); + else + return iowrite8(value, ch->mtu->mapbase + 0x280); } offs = mtu2_reg_offs[reg_nr]; @@ -353,109 +362,168 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, bool clockevent) { - if (clockevent) + if (clockevent) { + ch->mtu->has_clockevent = true; sh_mtu2_register_clockevent(ch, name); + } return 0; } -static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, +static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, struct sh_mtu2_device *mtu) { - struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + static const unsigned int channel_offsets[] = { + 0x300, 0x380, 0x000, + }; + bool clockevent; ch->mtu = mtu; - ch->index = cfg->timer_bit; - ch->irq = platform_get_irq(mtu->pdev, 0); + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + + clockevent = cfg->clockevent_rating != 0; + + ch->irq = platform_get_irq(mtu->pdev, 0); + ch->base = mtu->mapbase - cfg->channel_offset; + ch->index = cfg->timer_bit; + } else { + char name[6]; + + clockevent = true; + + sprintf(name, "tgi%ua", index); + ch->irq = platform_get_irq_byname(mtu->pdev, name); + ch->base = mtu->mapbase + channel_offsets[index]; + ch->index = index; + } + if (ch->irq < 0) { + /* Skip channels with no declared interrupt. */ + if (!mtu->legacy) + return 0; + dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n", ch->index); return ch->irq; } - return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), - cfg->clockevent_rating != 0); + return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), clockevent); } -static int sh_mtu2_setup(struct sh_mtu2_device *mtu, - struct platform_device *pdev) +static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu) { - struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - void __iomem *base; - int ret; - ret = -ENXIO; - - mtu->pdev = pdev; - - if (!cfg) { - dev_err(&mtu->pdev->dev, "missing platform data\n"); - goto err0; - } - - platform_set_drvdata(pdev, mtu); res = platform_get_resource(mtu->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&mtu->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } + mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (mtu->mapbase == NULL) + return -ENXIO; + /* - * Map memory, let base point to our channel and mapbase to the - * start/stop shared register. + * In legacy platform device configuration (with one device per channel) + * the resource points to the channel base address. */ - base = ioremap_nocache(res->start, resource_size(res)); - if (base == NULL) { - dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + mtu->mapbase += cfg->channel_offset; + } + + return 0; +} + +static void sh_mtu2_unmap_memory(struct sh_mtu2_device *mtu) +{ + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + mtu->mapbase -= cfg->channel_offset; } - mtu->mapbase = base + cfg->channel_offset; + iounmap(mtu->mapbase); +} + +static int sh_mtu2_setup(struct sh_mtu2_device *mtu, + struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int i; + int ret; + + mtu->pdev = pdev; + mtu->legacy = id->driver_data; + + if (mtu->legacy && !cfg) { + dev_err(&mtu->pdev->dev, "missing platform data\n"); + return -ENXIO; + } - /* get hold of clock */ + /* Get hold of clock. */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); if (IS_ERR(mtu->clk)) { dev_err(&mtu->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(mtu->clk); - goto err1; + return PTR_ERR(mtu->clk); } ret = clk_prepare(mtu->clk); if (ret < 0) - goto err2; + goto err_clk_put; - mtu->channels = kzalloc(sizeof(*mtu->channels), GFP_KERNEL); + /* Map the memory resource. */ + ret = sh_mtu2_map_memory(mtu); + if (ret < 0) { + dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); + goto err_clk_unprepare; + } + + /* Allocate and setup the channels. */ + if (mtu->legacy) + mtu->num_channels = 1; + else + mtu->num_channels = 3; + + mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels, + GFP_KERNEL); if (mtu->channels == NULL) { ret = -ENOMEM; - goto err3; + goto err_unmap; } - mtu->num_channels = 1; - - mtu->channels[0].base = base; + if (mtu->legacy) { + ret = sh_mtu2_setup_channel(&mtu->channels[0], 0, mtu); + if (ret < 0) + goto err_unmap; + } else { + for (i = 0; i < mtu->num_channels; ++i) { + ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu); + if (ret < 0) + goto err_unmap; + } + } - ret = sh_mtu2_setup_channel(&mtu->channels[0], mtu); - if (ret < 0) - goto err3; + platform_set_drvdata(pdev, mtu); return 0; - err3: + +err_unmap: kfree(mtu->channels); + sh_mtu2_unmap_memory(mtu); +err_clk_unprepare: clk_unprepare(mtu->clk); - err2: +err_clk_put: clk_put(mtu->clk); - err1: - iounmap(base); - err0: return ret; } static int sh_mtu2_probe(struct platform_device *pdev) { struct sh_mtu2_device *mtu = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -484,7 +552,7 @@ static int sh_mtu2_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating) + if (mtu->has_clockevent) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -497,12 +565,20 @@ static int sh_mtu2_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent */ } +static const struct platform_device_id sh_mtu2_id_table[] = { + { "sh_mtu2", 1 }, + { "sh-mtu2", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table); + static struct platform_driver sh_mtu2_device_driver = { .probe = sh_mtu2_probe, .remove = sh_mtu2_remove, .driver = { .name = "sh_mtu2", - } + }, + .id_table = sh_mtu2_id_table, }; static int __init sh_mtu2_init(void) -- cgit v0.10.2 From 6dc9693bb3997cb324a2ffb39deaa72081a9bd0d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 18:09:15 +0100 Subject: clocksource: sh_mtu2: Rename clock to "fck" in the non-legacy case The sh_mtu2 driver gets the MTU2 functional clock using a connection ID of "mtu2_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "mtu2_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 7cc6d942..3a37857 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -465,7 +465,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, } /* Get hold of clock. */ - mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); + mtu->clk = clk_get(&mtu->pdev->dev, mtu->legacy ? "mtu2_fck" : "fck"); if (IS_ERR(mtu->clk)) { dev_err(&mtu->pdev->dev, "cannot get clock\n"); return PTR_ERR(mtu->clk); -- cgit v0.10.2 From 24c8f71707087eb177b45f4a24faedaa0d8f0287 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:12:32 +0100 Subject: clocksource: sh_mtu2: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 3a37857..510bd32 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v0.10.2 From 346f5e76b3822a2530a03f33b00ee89dfc463326 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:11:47 +0100 Subject: clocksource: sh_mtu2: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 510bd32..f2c1c36 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -13,22 +13,22 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include #include -#include -#include #include -#include -#include #include -#include +#include #include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include struct sh_mtu2_device; -- cgit v0.10.2 From 983cd5238dd7b83651084ca6fe5274d1cc36ffa2 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Thu, 3 Apr 2014 12:30:13 -0300 Subject: ARM: mvebu: Enable nfsroot in the defconfig NFSroot is very frequently used by developers to boot, so let's make our lives simpler and enable it by default. Signed-off-by: Ezequiel Garcia Link: https://lkml.kernel.org/r/1396539014-8673-1-git-send-email-ezequiel.garcia@free-electrons.com Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/mvebu_v7_defconfig b/arch/arm/configs/mvebu_v7_defconfig index a34713d..bfcc362 100644 --- a/arch/arm/configs/mvebu_v7_defconfig +++ b/arch/arm/configs/mvebu_v7_defconfig @@ -29,6 +29,9 @@ CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_VFP=y CONFIG_NET=y CONFIG_INET=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y CONFIG_BT=y CONFIG_BT_MRVL=y CONFIG_BT_MRVL_SDIO=y @@ -103,6 +106,8 @@ CONFIG_UDF_FS=m CONFIG_MSDOS_FS=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y +CONFIG_NFS_FS=y +CONFIG_ROOT_NFS=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_CODEPAGE_850=y CONFIG_NLS_ISO8859_1=y -- cgit v0.10.2 From ff0403f33b2e62f15109f40460e09401e553e6f5 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Thu, 3 Apr 2014 12:30:14 -0300 Subject: ARM: mvebu: enable fhandle in the defconfigs CONFIG_FHANDLE is required by systemd >= 210 to spawn a serial TTY. Signed-off-by: Ezequiel Garcia Link: https://lkml.kernel.org/r/1396539014-8673-2-git-send-email-ezequiel.garcia@free-electrons.com Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/mvebu_v5_defconfig b/arch/arm/configs/mvebu_v5_defconfig index 36484a3..5d8ec15 100644 --- a/arch/arm/configs/mvebu_v5_defconfig +++ b/arch/arm/configs/mvebu_v5_defconfig @@ -1,4 +1,5 @@ CONFIG_SYSVIPC=y +CONFIG_FHANDLE=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=19 diff --git a/arch/arm/configs/mvebu_v7_defconfig b/arch/arm/configs/mvebu_v7_defconfig index bfcc362..b1e514e 100644 --- a/arch/arm/configs/mvebu_v7_defconfig +++ b/arch/arm/configs/mvebu_v7_defconfig @@ -1,5 +1,6 @@ CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y +CONFIG_FHANDLE=y CONFIG_IRQ_DOMAIN_DEBUG=y CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=14 -- cgit v0.10.2 From 313340d53298465a3f18859b0aff096c3fafaa8f Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Mon, 14 Apr 2014 16:41:17 +0200 Subject: ARM: configs: add CONFIG_MMC_SDHCI_PXAV3 to the mvebu_v7_defconfig The Marvell Armada 38x platform has a SDHCI interface managed by the sdhci-pxav3 MMC host driver. It therefore makes sense to enable this driver in mvebu_v7_defconfig. Signed-off-by: Thomas Petazzoni Acked-by: Andrew Lunn Link: https://lkml.kernel.org/r/1397486478-16991-3-git-send-email-thomas.petazzoni@free-electrons.com Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/mvebu_v7_defconfig b/arch/arm/configs/mvebu_v7_defconfig index b1e514e..04348ee 100644 --- a/arch/arm/configs/mvebu_v7_defconfig +++ b/arch/arm/configs/mvebu_v7_defconfig @@ -83,6 +83,7 @@ CONFIG_USB_EHCI_ROOT_HUB_TT=y CONFIG_USB_STORAGE=y CONFIG_USB_XHCI_HCD=y CONFIG_MMC=y +CONFIG_MMC_SDHCI_PXAV3=y CONFIG_MMC_MVSDIO=y CONFIG_NEW_LEDS=y CONFIG_LEDS_GPIO=y -- cgit v0.10.2 From 6bc4b91d751e2eccf1f9742e8ecf11c78c8d88c9 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 15 Apr 2014 17:00:05 +0200 Subject: ARM: configs: add ahci_mvebu to mvebu_v7_defconfig The Marvell Armada 38x platform needs the ahci_mvebu driver enabled for the AHCI interfaces, so this commit enables the corresponding Kconfig option in mvebu_v7_defconfig. Signed-off-by: Thomas Petazzoni Link: https://lkml.kernel.org/r/1397574006-5868-5-git-send-email-thomas.petazzoni@free-electrons.com Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/mvebu_v7_defconfig b/arch/arm/configs/mvebu_v7_defconfig index 04348ee..2485a5e 100644 --- a/arch/arm/configs/mvebu_v7_defconfig +++ b/arch/arm/configs/mvebu_v7_defconfig @@ -40,6 +40,7 @@ CONFIG_CFG80211=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_BLK_DEV_SD=y CONFIG_ATA=y +CONFIG_AHCI_MVEBU=y CONFIG_SATA_MV=y CONFIG_NETDEVICES=y CONFIG_MVNETA=y -- cgit v0.10.2 From 809aa6f1b4ce8322e32725437837fb92c2eaf4c8 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 30 Apr 2014 23:26:43 -0700 Subject: ARM: mvebu: defconfig: add MTD_SPI_NOR (new dependency for M25P80) These defconfigs contain the CONFIG_M25P80 symbol, which is now dependent on the MTD_SPI_NOR symbol. Add CONFIG_MTD_SPI_NOR to satisfy the new dependency. At the same time, drop the now-nonexistent CONFIG_MTD_CHAR symbol. Signed-off-by: Brian Norris Cc: Jason Cooper Cc: Andrew Lunn Cc: Sebastian Hesselbarth Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Acked-by: Jason Cooper Acked-by: Ezequiel Garcia Link: https://lkml.kernel.org/r/1398925607-7482-9-git-send-email-computersforpeace@gmail.com Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/dove_defconfig b/arch/arm/configs/dove_defconfig index f159551..701677f 100644 --- a/arch/arm/configs/dove_defconfig +++ b/arch/arm/configs/dove_defconfig @@ -37,7 +37,6 @@ CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y CONFIG_MTD=y CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_JEDECPROBE=y @@ -48,6 +47,7 @@ CONFIG_MTD_CFI_INTELEXT=y CONFIG_MTD_CFI_STAA=y CONFIG_MTD_PHYSMAP=y CONFIG_MTD_M25P80=y +CONFIG_MTD_SPI_NOR=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=1 diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig index 2e762d9..b9e480c 100644 --- a/arch/arm/configs/kirkwood_defconfig +++ b/arch/arm/configs/kirkwood_defconfig @@ -61,6 +61,7 @@ CONFIG_MTD_PHYSMAP=y CONFIG_MTD_M25P80=y CONFIG_MTD_NAND=y CONFIG_MTD_NAND_ORION=y +CONFIG_MTD_SPI_NOR=y CONFIG_BLK_DEV_LOOP=y CONFIG_EEPROM_AT24=y # CONFIG_SCSI_PROC_FS is not set diff --git a/arch/arm/configs/mvebu_v5_defconfig b/arch/arm/configs/mvebu_v5_defconfig index 5d8ec15..4a2baa9 100644 --- a/arch/arm/configs/mvebu_v5_defconfig +++ b/arch/arm/configs/mvebu_v5_defconfig @@ -51,6 +51,7 @@ CONFIG_MTD_PHYSMAP=y CONFIG_MTD_M25P80=y CONFIG_MTD_NAND=y CONFIG_MTD_NAND_ORION=y +CONFIG_MTD_SPI_NOR=y CONFIG_BLK_DEV_LOOP=y CONFIG_EEPROM_AT24=y # CONFIG_SCSI_PROC_FS is not set diff --git a/arch/arm/configs/mvebu_v7_defconfig b/arch/arm/configs/mvebu_v7_defconfig index 2485a5e..b52a6f5 100644 --- a/arch/arm/configs/mvebu_v7_defconfig +++ b/arch/arm/configs/mvebu_v7_defconfig @@ -58,6 +58,7 @@ CONFIG_I2C_MV64XXX=y CONFIG_MTD=y CONFIG_MTD_CHAR=y CONFIG_MTD_M25P80=y +CONFIG_MTD_SPI_NOR=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_INTELEXT=y CONFIG_MTD_CFI_AMDSTD=y -- cgit v0.10.2 From 474684809f76c76d87dcf8417fa9ce65dc01ac75 Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Sat, 3 May 2014 20:30:18 +0200 Subject: ARM: mvebu_v5_defconfig: Enable sound modules needed for t5325 Enable simple-card and the CODEC. Signed-off-by: Andrew Lunn Link: https://lkml.kernel.org/r/1399141819-23924-9-git-send-email-andrew@lunn.ch Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/mvebu_v5_defconfig b/arch/arm/configs/mvebu_v5_defconfig index 4a2baa9..27c732f 100644 --- a/arch/arm/configs/mvebu_v5_defconfig +++ b/arch/arm/configs/mvebu_v5_defconfig @@ -12,7 +12,6 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_ARCH_MULTI_V7 is not set CONFIG_ARCH_MVEBU=y CONFIG_MACH_KIRKWOOD=y -CONFIG_MACH_T5325=y # CONFIG_CPU_FEROCEON_OLD_ID is not set CONFIG_PCI_MVEBU=y CONFIG_PREEMPT=y @@ -102,6 +101,8 @@ CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_KIRKWOOD_SOC=y CONFIG_SND_KIRKWOOD_SOC_T5325=y +CONFIG_SND_SOC_ALC5623=y +CONFIG_SND_SIMPLE_CARD=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_HID_DRAGONRISE=y -- cgit v0.10.2 From 208f4e0d9bce775fbc7ab08c830d135d3da5777c Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Sat, 3 May 2014 20:30:19 +0200 Subject: ARM: multi_v5_defconfig: Enable sound modules needed for t5325 Enable simple-card and the CODEC. Signed-off-by: Andrew Lunn Link: https://lkml.kernel.org/r/1399141819-23924-10-git-send-email-andrew@lunn.ch Signed-off-by: Jason Cooper diff --git a/arch/arm/configs/multi_v5_defconfig b/arch/arm/configs/multi_v5_defconfig index aa3dfb0..5ebfa8b 100644 --- a/arch/arm/configs/multi_v5_defconfig +++ b/arch/arm/configs/multi_v5_defconfig @@ -11,7 +11,6 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_ARCH_MULTI_V7 is not set CONFIG_ARCH_MVEBU=y CONFIG_MACH_KIRKWOOD=y -CONFIG_MACH_T5325=y CONFIG_ARCH_MXC=y CONFIG_MACH_IMX25_DT=y CONFIG_MACH_IMX27_DT=y @@ -108,6 +107,8 @@ CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_KIRKWOOD_SOC=y CONFIG_SND_KIRKWOOD_SOC_T5325=y +CONFIG_SND_SOC_ALC5623=y +CONFIG_SND_SIMPLE_CARD=y # CONFIG_ABX500_CORE is not set CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y -- cgit v0.10.2 From 189c20832903abfec38242255b84e2c4f6a8552f Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 15 Apr 2014 15:10:27 -0600 Subject: ARM: multi_v7: enable AT24C EEPROM driver This is used for the board ID EEPROM on Jetson TK1, as well as likely a whole slew of other NVIDIA reference boards; we simply haven't added enabled the EEPROM in the DT files until now. Signed-off-by: Stephen Warren Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index d4e8a47..a692b7a 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -112,6 +112,7 @@ CONFIG_BLK_DEV_LOOP=y CONFIG_ICS932S401=y CONFIG_APDS9802ALS=y CONFIG_ISL29003=y +CONFIG_EEPROM_AT24=y CONFIG_BLK_DEV_SD=y CONFIG_BLK_DEV_SR=y CONFIG_SCSI_MULTI_LUN=y -- cgit v0.10.2 From 9630cc932489ec671a6d0ecd9b062a23bec74a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20T=C3=A9nart?= Date: Thu, 17 Apr 2014 10:42:30 +0200 Subject: ARM: multi_v7_defconfig: select CONFIG_GPIO_DWAPB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The newly integrated dwapb gpio driver handles the Berlin SoCs GPIOs. Add this driver to the multi_v7_defconfig. Signed-off-by: Antoine Ténart Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index a692b7a..1014e9d 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -192,6 +192,7 @@ CONFIG_PINCTRL_AS3722=y CONFIG_PINCTRL_PALMAS=y CONFIG_GPIO_SYSFS=y CONFIG_GPIO_GENERIC_PLATFORM=y +CONFIG_GPIO_DWAPB=y CONFIG_GPIO_PCA953X_IRQ=y CONFIG_GPIO_TWL4030=y CONFIG_GPIO_PALMAS=y -- cgit v0.10.2 From f1e9637f4b49690a6c5793f1745f743506b1bfd1 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Fri, 21 Mar 2014 20:39:17 +0100 Subject: ARM: multi_v7_defconfig: Select CONFIG_MACH_BERLIN_BG2Q Now that we support Berlin BG2Q, select CONFIG_MACH_BERLIN_BG2Q so that we can boot BG2Q based boards like the BG2Q DMP. Signed-off-by: Alexandre Belloni Acked-by: Sebastian Hesselbarth Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 1014e9d..8b3c10a 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -20,6 +20,7 @@ CONFIG_ARCH_BCM_MOBILE=y CONFIG_ARCH_BERLIN=y CONFIG_MACH_BERLIN_BG2=y CONFIG_MACH_BERLIN_BG2CD=y +CONFIG_MACH_BERLIN_BG2Q=y CONFIG_GPIO_PCA953X=y CONFIG_ARCH_HIGHBANK=y CONFIG_ARCH_HI3xxx=y -- cgit v0.10.2 From 55fc5ecd6c2746b93e1363d86692fea68ca906d0 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Mon, 14 Apr 2014 16:41:18 +0200 Subject: ARM: configs: add CONFIG_MMC_SDHCI_PXAV3 to the multi_v7_defconfig The Marvell Armada 38x platform has a SDHCI interface managed by the sdhci-pxav3 MMC host driver. It therefore makes sense to enable this driver in multi_v7_defconfig, which supports the Armada 38x platform. Signed-off-by: Thomas Petazzoni Acked-by: Jason Cooper Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 8b3c10a..5039cc6 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -276,6 +276,7 @@ CONFIG_MMC_BLOCK_MINORS=16 CONFIG_MMC_ARMMMCI=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ESDHC_IMX=y +CONFIG_MMC_SDHCI_PXAV3=y CONFIG_MMC_SDHCI_TEGRA=y CONFIG_MMC_SDHCI_DOVE=y CONFIG_MMC_SDHCI_SPEAR=y -- cgit v0.10.2 From 5659e3bcbcb5d454fa183351362e852321784f7c Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Fri, 9 May 2014 12:27:48 +0530 Subject: ARM: sunxi: drop CONFIG_COMMON_CLK_DEBUG this patch drops CONFIG_COMMON_CLK_DEBUG option as this config option is now obsolete. CC: Maxime Ripard CC: Olof Johansson Signed-off-by: Lad, Prabhakar Signed-off-by: Maxime Ripard diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig index b5df4a5..28287ae 100644 --- a/arch/arm/configs/sunxi_defconfig +++ b/arch/arm/configs/sunxi_defconfig @@ -62,7 +62,6 @@ CONFIG_LEDS_GPIO=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_LEDS_TRIGGER_DEFAULT_ON=y -CONFIG_COMMON_CLK_DEBUG=y # CONFIG_IOMMU_SUPPORT is not set CONFIG_TMPFS=y CONFIG_NFS_FS=y -- cgit v0.10.2 From 9b17e48cd4df4e129976c37660cf9ec644c66059 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:08 +0200 Subject: sh: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c index f59b1f3..8de314b 100644 --- a/arch/sh/kernel/cpu/clock-cpg.c +++ b/arch/sh/kernel/cpu/clock-cpg.c @@ -58,7 +58,8 @@ int __init __deprecated cpg_clk_init(void) clk_add_alias("tmu_fck", NULL, "peripheral_clk", NULL); clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL); - clk_add_alias("cmt_fck", NULL, "peripheral_clk", NULL); + clk_add_alias("fck", "sh-cmt-16.0", "peripheral_clk", NULL); + clk_add_alias("fck", "sh-cmt-32.0", "peripheral_clk", NULL); clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL); return ret; diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c index 3860b0b..58c19ad 100644 --- a/arch/sh/kernel/cpu/sh2/setup-sh7619.c +++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c @@ -152,62 +152,24 @@ static struct platform_device eth_device = { .resource = eth_resources, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 3, }; -static struct resource cmt0_resources[] = { - [0] = { - .start = 0xf84a0072, - .end = 0xf84a0077, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 86, - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0xf84a0070, 0x10), + DEFINE_RES_IRQ(86), + DEFINE_RES_IRQ(87), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-16", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .channel_offset = 0x08, - .timer_bit = 1, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ -}; - -static struct resource cmt1_resources[] = { - [0] = { - .start = 0xf84a0078, - .end = 0xf84a007d, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 87, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct platform_device *sh7619_devices[] __initdata = { @@ -215,8 +177,7 @@ static struct platform_device *sh7619_devices[] __initdata = { &scif1_device, &scif2_device, ð_device, - &cmt0_device, - &cmt1_device, + &cmt_device, }; static int __init sh7619_devices_setup(void) @@ -235,8 +196,7 @@ static struct platform_device *sh7619_early_devices[] __initdata = { &scif0_device, &scif1_device, &scif2_device, - &cmt0_device, - &cmt1_device, + &cmt_device, }; #define STBCR3 0xf80a0000 diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7264.c b/arch/sh/kernel/cpu/sh2a/clock-sh7264.c index fdf585c..c7f3c66 100644 --- a/arch/sh/kernel/cpu/sh2a/clock-sh7264.c +++ b/arch/sh/kernel/cpu/sh2a/clock-sh7264.c @@ -117,7 +117,7 @@ static struct clk_lookup lookups[] = { /* MSTP clocks */ CLKDEV_CON_ID("sci_ick", &mstp_clks[MSTP77]), CLKDEV_CON_ID("vdc3", &mstp_clks[MSTP74]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP72]), + CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]), CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]), CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]), CLKDEV_CON_ID("sdhi0", &mstp_clks[MSTP34]), diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7269.c b/arch/sh/kernel/cpu/sh2a/clock-sh7269.c index 6b78762..4f47464 100644 --- a/arch/sh/kernel/cpu/sh2a/clock-sh7269.c +++ b/arch/sh/kernel/cpu/sh2a/clock-sh7269.c @@ -158,7 +158,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP42]), CLKDEV_ICK_ID("sci_fck", "sh-sci.6", &mstp_clks[MSTP41]), CLKDEV_ICK_ID("sci_fck", "sh-sci.7", &mstp_clks[MSTP40]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP72]), + CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]), CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]), CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]), CLKDEV_CON_ID("adc0", &mstp_clks[MSTP32]), diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c index d55a0f3..374f8c0 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c @@ -265,62 +265,24 @@ static struct platform_device scif3_device = { }, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 3, }; -static struct resource cmt0_resources[] = { - [0] = { - .start = 0xfffec002, - .end = 0xfffec007, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 142, - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0xfffec000, 0x10), + DEFINE_RES_IRQ(142), + DEFINE_RES_IRQ(143), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-16", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .channel_offset = 0x08, - .timer_bit = 1, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ -}; - -static struct resource cmt1_resources[] = { - [0] = { - .start = 0xfffec008, - .end = 0xfffec00d, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 143, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct sh_timer_config mtu2_0_platform_data = { @@ -404,8 +366,7 @@ static struct platform_device *sh7203_devices[] __initdata = { &scif1_device, &scif2_device, &scif3_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, &rtc_device, @@ -428,8 +389,7 @@ static struct platform_device *sh7203_early_devices[] __initdata = { &scif1_device, &scif2_device, &scif3_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, }; diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c index 241e745..d00e6fd 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c @@ -217,62 +217,24 @@ static struct platform_device scif3_device = { }, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 3, }; -static struct resource cmt0_resources[] = { - [0] = { - .start = 0xfffec002, - .end = 0xfffec007, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 140, - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0xfffec000, 0x10), + DEFINE_RES_IRQ(140), + DEFINE_RES_IRQ(144), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-16", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .channel_offset = 0x08, - .timer_bit = 1, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ -}; - -static struct resource cmt1_resources[] = { - [0] = { - .start = 0xfffec008, - .end = 0xfffec00d, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 144, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct sh_timer_config mtu2_0_platform_data = { @@ -364,8 +326,7 @@ static struct platform_device *sh7206_devices[] __initdata = { &scif1_device, &scif2_device, &scif3_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, &mtu2_2_device, @@ -388,8 +349,7 @@ static struct platform_device *sh7206_early_devices[] __initdata = { &scif1_device, &scif2_device, &scif3_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, &mtu2_2_device, diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7264.c b/arch/sh/kernel/cpu/sh2a/setup-sh7264.c index ad5b0f4..e95250e 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7264.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7264.c @@ -433,65 +433,24 @@ static struct platform_device scif7_device = { }, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 3, }; -static struct resource cmt0_resources[] = { - [0] = { - .name = "CMT0", - .start = 0xfffec002, - .end = 0xfffec007, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 175, - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0xfffec000, 0x10), + DEFINE_RES_IRQ(175), + DEFINE_RES_IRQ(176), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-16", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .name = "CMT1", - .channel_offset = 0x08, - .timer_bit = 1, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ -}; - -static struct resource cmt1_resources[] = { - [0] = { - .name = "CMT1", - .start = 0xfffec008, - .end = 0xfffec00d, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 176, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct sh_timer_config mtu2_0_platform_data = { @@ -620,8 +579,7 @@ static struct platform_device *sh7264_devices[] __initdata = { &scif5_device, &scif6_device, &scif7_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, &rtc_device, @@ -649,8 +607,7 @@ static struct platform_device *sh7264_early_devices[] __initdata = { &scif5_device, &scif6_device, &scif7_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, }; diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7269.c b/arch/sh/kernel/cpu/sh2a/setup-sh7269.c index 3995119..0191e1a 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7269.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7269.c @@ -455,62 +455,24 @@ static struct platform_device scif7_device = { }, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 3, }; -static struct resource cmt0_resources[] = { - [0] = { - .start = 0xfffec002, - .end = 0xfffec007, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 188, - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0xfffec000, 0x10), + DEFINE_RES_IRQ(188), + DEFINE_RES_IRQ(189), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-16", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .channel_offset = 0x08, - .timer_bit = 1, - .clockevent_rating = 125, - .clocksource_rating = 0, /* disabled due to code generation issues */ -}; - -static struct resource cmt1_resources[] = { - [0] = { - .start = 0xfffec008, - .end = 0xfffec00d, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 189, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct sh_timer_config mtu2_0_platform_data = { @@ -629,8 +591,7 @@ static struct platform_device *sh7269_devices[] __initdata = { &scif5_device, &scif6_device, &scif7_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, &rtc_device, @@ -658,8 +619,7 @@ static struct platform_device *sh7269_early_devices[] __initdata = { &scif5_device, &scif6_device, &scif7_device, - &cmt0_device, - &cmt1_device, + &cmt_device, &mtu2_0_device, &mtu2_1_device, }; diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c index 1d5729d..a53d219 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c @@ -152,141 +152,23 @@ static struct platform_device usbf_device = { .resource = usbf_resources, }; -static struct sh_timer_config cmt0_platform_data = { - .channel_offset = 0x10, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 125, +static struct sh_timer_config cmt_platform_data = { + .channels_mask = 0x1f, }; -static struct resource cmt0_resources[] = { - [0] = { - .start = 0x044a0010, - .end = 0x044a001b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt_resources[] = { + DEFINE_RES_MEM(0x044a0000, 0x60), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; -static struct platform_device cmt0_device = { - .name = "sh_cmt", +static struct platform_device cmt_device = { + .name = "sh-cmt-32", .id = 0, .dev = { - .platform_data = &cmt0_platform_data, - }, - .resource = cmt0_resources, - .num_resources = ARRAY_SIZE(cmt0_resources), -}; - -static struct sh_timer_config cmt1_platform_data = { - .channel_offset = 0x20, - .timer_bit = 1, -}; - -static struct resource cmt1_resources[] = { - [0] = { - .start = 0x044a0020, - .end = 0x044a002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt1_device = { - .name = "sh_cmt", - .id = 1, - .dev = { - .platform_data = &cmt1_platform_data, - }, - .resource = cmt1_resources, - .num_resources = ARRAY_SIZE(cmt1_resources), -}; - -static struct sh_timer_config cmt2_platform_data = { - .channel_offset = 0x30, - .timer_bit = 2, -}; - -static struct resource cmt2_resources[] = { - [0] = { - .start = 0x044a0030, - .end = 0x044a003b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt2_device = { - .name = "sh_cmt", - .id = 2, - .dev = { - .platform_data = &cmt2_platform_data, - }, - .resource = cmt2_resources, - .num_resources = ARRAY_SIZE(cmt2_resources), -}; - -static struct sh_timer_config cmt3_platform_data = { - .channel_offset = 0x40, - .timer_bit = 3, -}; - -static struct resource cmt3_resources[] = { - [0] = { - .start = 0x044a0040, - .end = 0x044a004b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt3_device = { - .name = "sh_cmt", - .id = 3, - .dev = { - .platform_data = &cmt3_platform_data, - }, - .resource = cmt3_resources, - .num_resources = ARRAY_SIZE(cmt3_resources), -}; - -static struct sh_timer_config cmt4_platform_data = { - .channel_offset = 0x50, - .timer_bit = 4, -}; - -static struct resource cmt4_resources[] = { - [0] = { - .start = 0x044a0050, - .end = 0x044a005b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device cmt4_device = { - .name = "sh_cmt", - .id = 4, - .dev = { - .platform_data = &cmt4_platform_data, + .platform_data = &cmt_platform_data, }, - .resource = cmt4_resources, - .num_resources = ARRAY_SIZE(cmt4_resources), + .resource = cmt_resources, + .num_resources = ARRAY_SIZE(cmt_resources), }; static struct sh_timer_config tmu0_platform_data = { @@ -375,11 +257,7 @@ static struct platform_device tmu2_device = { static struct platform_device *sh7720_devices[] __initdata = { &scif0_device, &scif1_device, - &cmt0_device, - &cmt1_device, - &cmt2_device, - &cmt3_device, - &cmt4_device, + &cmt_device, &tmu0_device, &tmu1_device, &tmu2_device, @@ -398,11 +276,7 @@ arch_initcall(sh7720_devices_setup); static struct platform_device *sh7720_early_devices[] __initdata = { &scif0_device, &scif1_device, - &cmt0_device, - &cmt1_device, - &cmt2_device, - &cmt3_device, - &cmt4_device, + &cmt_device, &tmu0_device, &tmu1_device, &tmu2_device, diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c index 53638e2..9edc06c 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c @@ -227,7 +227,7 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("hudi0", &mstp_clks[MSTP019]), CLKDEV_CON_ID("ubc0", &mstp_clks[MSTP017]), CLKDEV_CON_ID("tmu_fck", &mstp_clks[MSTP015]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP014]), + CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[MSTP014]), CLKDEV_CON_ID("rwdt0", &mstp_clks[MSTP013]), CLKDEV_CON_ID("mfi0", &mstp_clks[MSTP011]), CLKDEV_CON_ID("flctl0", &mstp_clks[MSTP010]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c index 22e485d..955b9ad 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c @@ -225,7 +225,7 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("hudi0", &mstp_clks[MSTP019]), CLKDEV_CON_ID("ubc0", &mstp_clks[MSTP017]), CLKDEV_CON_ID("tmu_fck", &mstp_clks[MSTP015]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP014]), + CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[MSTP014]), CLKDEV_CON_ID("rwdt0", &mstp_clks[MSTP013]), CLKDEV_CON_ID("mfi0", &mstp_clks[MSTP011]), CLKDEV_CON_ID("flctl0", &mstp_clks[MSTP010]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c index c4cb740..4097493 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c @@ -207,7 +207,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU]), CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]), + CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]), CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c index 37c41c7..da64734 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c @@ -236,7 +236,7 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("sh0", &mstp_clks[HWBLK_SHYWAY]), CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]), CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]), + CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]), CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]), CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c index 0128af3..f917f19 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c @@ -309,7 +309,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU0]), CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[HWBLK_TMU1]), - CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]), + CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[HWBLK_CMT]), CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]), diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c index 245d192..ad96492 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c @@ -228,26 +228,16 @@ static struct platform_device jpu_device = { }; static struct sh_timer_config cmt_platform_data = { - .channel_offset = 0x60, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 200, + .channels_mask = 0x20, }; static struct resource cmt_resources[] = { - [0] = { - .start = 0x044a0060, - .end = 0x044a006b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0x044a0000, 0x70), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; static struct platform_device cmt_device = { - .name = "sh_cmt", + .name = "sh-cmt-32", .id = 0, .dev = { .platform_data = &cmt_platform_data, diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c index 6f56cbd..4e4985d 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c @@ -176,26 +176,16 @@ static struct platform_device veu1_device = { }; static struct sh_timer_config cmt_platform_data = { - .channel_offset = 0x60, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 200, + .channels_mask = 0x20, }; static struct resource cmt_resources[] = { - [0] = { - .start = 0x044a0060, - .end = 0x044a006b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0x044a0000, 0x70), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; static struct platform_device cmt_device = { - .name = "sh_cmt", + .name = "sh-cmt-32", .id = 0, .dev = { .platform_data = &cmt_platform_data, diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c index 5a94efc..4e3218f 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c @@ -413,26 +413,16 @@ static struct platform_device jpu_device = { }; static struct sh_timer_config cmt_platform_data = { - .channel_offset = 0x60, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 125, + .channels_mask = 0x20, }; static struct resource cmt_resources[] = { - [0] = { - .start = 0x044a0060, - .end = 0x044a006b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0x044a0000, 0x70), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; static struct platform_device cmt_device = { - .name = "sh_cmt", + .name = "sh-cmt-32", .id = 0, .dev = { .platform_data = &cmt_platform_data, diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c index 3c5eb09..5dfdb85 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c @@ -245,26 +245,16 @@ static struct platform_device veu1_device = { }; static struct sh_timer_config cmt_platform_data = { - .channel_offset = 0x60, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 125, + .channels_mask = 0x20, }; static struct resource cmt_resources[] = { - [0] = { - .start = 0x044a0060, - .end = 0x044a006b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0x044a0000, 0x70), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; static struct platform_device cmt_device = { - .name = "sh_cmt", + .name = "sh-cmt-32", .id = 0, .dev = { .platform_data = &cmt_platform_data, diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c index 60ebbc6..b435f07 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c @@ -648,26 +648,16 @@ static struct platform_device beu1_device = { }; static struct sh_timer_config cmt_platform_data = { - .channel_offset = 0x60, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 200, + .channels_mask = 0x20, }; static struct resource cmt_resources[] = { - [0] = { - .start = 0x044a0060, - .end = 0x044a006b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xf00), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0x044a0000, 0x70), + DEFINE_RES_IRQ(evt2irq(0xf00)), }; static struct platform_device cmt_device = { - .name = "sh_cmt", + .name = "sh-cmt-32", .id = 0, .dev = { .platform_data = &cmt_platform_data, -- cgit v0.10.2 From 386f60aae35271efa4dc7c407f65269b7cb71edb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:09 +0200 Subject: ARM: shmobile: sh7372: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c index 2848997..c622b49 100644 --- a/arch/arm/mach-shmobile/clock-sh7372.c +++ b/arch/arm/mach-shmobile/clock-sh7372.c @@ -565,10 +565,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("r8a66597_hcd.1", &mstp_clks[MSTP406]), /* USB1 */ CLKDEV_DEV_ID("r8a66597_udc.1", &mstp_clks[MSTP406]), /* USB1 */ CLKDEV_DEV_ID("renesas_usbhs.1", &mstp_clks[MSTP406]), /* USB1 */ - CLKDEV_DEV_ID("sh_cmt.4", &mstp_clks[MSTP405]), /* CMT4 */ - CLKDEV_DEV_ID("sh_cmt.3", &mstp_clks[MSTP404]), /* CMT3 */ CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */ - CLKDEV_DEV_ID("sh_cmt.2", &mstp_clks[MSTP400]), /* CMT2 */ /* ICK */ CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]), @@ -581,6 +578,9 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]), CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]), CLKDEV_ICK_ID("spu2", "sh_fsi2", &mstp_clks[MSTP223]), + CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.4", &mstp_clks[MSTP405]), /* CMT4 */ + CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.3", &mstp_clks[MSTP404]), /* CMT3 */ + CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.2", &mstp_clks[MSTP400]), /* CMT2 */ CLKDEV_ICK_ID("diva", "sh_fsi2", &fsidivs[FSIDIV_A]), CLKDEV_ICK_ID("divb", "sh_fsi2", &fsidivs[FSIDIV_B]), CLKDEV_ICK_ID("xcka", "sh_fsi2", &fsiack_clk), diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c index 2730127..4c0e943 100644 --- a/arch/arm/mach-shmobile/setup-sh7372.c +++ b/arch/arm/mach-shmobile/setup-sh7372.c @@ -119,28 +119,16 @@ SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60)); /* CMT */ static struct sh_timer_config cmt2_platform_data = { - .name = "CMT2", - .channel_offset = 0x40, - .timer_bit = 5, - .clockevent_rating = 125, - .clocksource_rating = 125, + .channels_mask = 0x20, }; static struct resource cmt2_resources[] = { - [0] = { - .name = "CMT2", - .start = 0xe6130040, - .end = 0xe613004b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x0b80), /* CMT2 */ - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xe6130000, 0x50), + DEFINE_RES_IRQ(evt2irq(0x0b80)), }; static struct platform_device cmt2_device = { - .name = "sh_cmt", + .name = "sh-cmt-32-fast", .id = 2, .dev = { .platform_data = &cmt2_platform_data, -- cgit v0.10.2 From 652256fd475053f7fd8c2cd3e85f37be96d594db Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:10 +0200 Subject: ARM: shmobile: sh73a0: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c index 23edf83..ca03989 100644 --- a/arch/arm/mach-shmobile/clock-sh73a0.c +++ b/arch/arm/mach-shmobile/clock-sh73a0.c @@ -650,7 +650,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */ CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ - CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */ CLKDEV_DEV_ID("ec230000.sound", &mstp_clks[MSTP328]), /* FSI */ CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */ @@ -683,6 +682,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]), CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk), CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk), + CLKDEV_ICK_ID("fck", "sh-cmt-48.1", &mstp_clks[MSTP329]), /* CMT1 */ }; void __init sh73a0_clock_init(void) diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c index f74ab53..71d0e44 100644 --- a/arch/arm/mach-shmobile/setup-sh73a0.c +++ b/arch/arm/mach-shmobile/setup-sh73a0.c @@ -104,35 +104,23 @@ SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156)); SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143)); SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80)); -static struct sh_timer_config cmt10_platform_data = { - .name = "CMT10", - .channel_offset = 0x10, - .timer_bit = 0, - .clockevent_rating = 80, - .clocksource_rating = 125, +static struct sh_timer_config cmt1_platform_data = { + .channels_mask = 0x3f, }; -static struct resource cmt10_resources[] = { - [0] = { - .name = "CMT10", - .start = 0xe6138010, - .end = 0xe613801b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_spi(65), - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt1_resources[] = { + DEFINE_RES_MEM(0xe6138000, 0x200), + DEFINE_RES_IRQ(gic_spi(65)), }; -static struct platform_device cmt10_device = { - .name = "sh_cmt", - .id = 10, +static struct platform_device cmt1_device = { + .name = "sh-cmt-48", + .id = 1, .dev = { - .platform_data = &cmt10_platform_data, + .platform_data = &cmt1_platform_data, }, - .resource = cmt10_resources, - .num_resources = ARRAY_SIZE(cmt10_resources), + .resource = cmt1_resources, + .num_resources = ARRAY_SIZE(cmt1_resources), }; /* TMU */ @@ -746,7 +734,7 @@ static struct platform_device *sh73a0_devices_dt[] __initdata = { &scif6_device, &scif7_device, &scif8_device, - &cmt10_device, + &cmt1_device, }; static struct platform_device *sh73a0_early_devices[] __initdata = { -- cgit v0.10.2 From 52065ef71e2c4da9e9661da68915741afc72ec1d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:11 +0200 Subject: ARM: shmobile: r8a73a4: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmobile/clock-r8a73a4.c index 7348d58..b5bc22c 100644 --- a/arch/arm/mach-shmobile/clock-r8a73a4.c +++ b/arch/arm/mach-shmobile/clock-r8a73a4.c @@ -597,7 +597,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("e6560000.i2c", &mstp_clks[MSTP317]), CLKDEV_DEV_ID("e6500000.i2c", &mstp_clks[MSTP318]), CLKDEV_DEV_ID("e6510000.i2c", &mstp_clks[MSTP323]), - CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), + CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.1", &mstp_clks[MSTP329]), CLKDEV_DEV_ID("e60b0000.i2c", &mstp_clks[MSTP409]), CLKDEV_DEV_ID("e6540000.i2c", &mstp_clks[MSTP410]), CLKDEV_DEV_ID("e6530000.i2c", &mstp_clks[MSTP411]), diff --git a/arch/arm/mach-shmobile/setup-r8a73a4.c b/arch/arm/mach-shmobile/setup-r8a73a4.c index cd36f80..9333770 100644 --- a/arch/arm/mach-shmobile/setup-r8a73a4.c +++ b/arch/arm/mach-shmobile/setup-r8a73a4.c @@ -169,20 +169,17 @@ static const struct resource thermal0_resources[] = { thermal0_resources, \ ARRAY_SIZE(thermal0_resources)) -static struct sh_timer_config cmt10_platform_data = { - .name = "CMT10", - .timer_bit = 0, - .clockevent_rating = 80, +static struct sh_timer_config cmt1_platform_data = { + .channels_mask = 0xff, }; -static struct resource cmt10_resources[] = { - DEFINE_RES_MEM(0xe6130010, 0x0c), - DEFINE_RES_MEM(0xe6130000, 0x04), - DEFINE_RES_IRQ(gic_spi(120)), /* CMT1_0 */ +static struct resource cmt1_resources[] = { + DEFINE_RES_MEM(0xe6130000, 0x1004), + DEFINE_RES_IRQ(gic_spi(120)), }; #define r8a7790_register_cmt(idx) \ - platform_device_register_resndata(&platform_bus, "sh_cmt", \ + platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \ idx, cmt##idx##_resources, \ ARRAY_SIZE(cmt##idx##_resources), \ &cmt##idx##_platform_data, \ @@ -196,7 +193,7 @@ void __init r8a73a4_add_dt_devices(void) r8a73a4_register_scif(3); r8a73a4_register_scif(4); r8a73a4_register_scif(5); - r8a7790_register_cmt(10); + r8a7790_register_cmt(1); } /* DMA */ -- cgit v0.10.2 From e0ad56a35e02fe16f12cc18867903f8462d587bf Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:12 +0200 Subject: ARM: shmobile: r8a7740: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c index dd989f9..cdb303c 100644 --- a/arch/arm/mach-shmobile/clock-r8a7740.c +++ b/arch/arm/mach-shmobile/clock-r8a7740.c @@ -583,7 +583,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]), CLKDEV_DEV_ID("e6cc0000.sci", &mstp_clks[MSTP230]), - CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), CLKDEV_DEV_ID("fe1f0000.sound", &mstp_clks[MSTP328]), CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), @@ -604,6 +603,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("e6870000.sd", &mstp_clks[MSTP415]), /* ICK */ + CLKDEV_ICK_ID("fck", "sh-cmt-48.1", &mstp_clks[MSTP329]), CLKDEV_ICK_ID("host", "renesas_usbhs", &mstp_clks[MSTP416]), CLKDEV_ICK_ID("func", "renesas_usbhs", &mstp_clks[MSTP407]), CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]), diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index 8f3c681..495e9bd 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c @@ -237,35 +237,23 @@ R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107)); R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108)); /* CMT */ -static struct sh_timer_config cmt10_platform_data = { - .name = "CMT10", - .channel_offset = 0x10, - .timer_bit = 0, - .clockevent_rating = 125, - .clocksource_rating = 125, +static struct sh_timer_config cmt1_platform_data = { + .channels_mask = 0x3f, }; -static struct resource cmt10_resources[] = { - [0] = { - .name = "CMT10", - .start = 0xe6138010, - .end = 0xe613801b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_spi(58), - .flags = IORESOURCE_IRQ, - }, +static struct resource cmt1_resources[] = { + DEFINE_RES_MEM(0xe6138000, 0x170), + DEFINE_RES_IRQ(gic_spi(58)), }; -static struct platform_device cmt10_device = { - .name = "sh_cmt", - .id = 10, +static struct platform_device cmt1_device = { + .name = "sh-cmt-48", + .id = 1, .dev = { - .platform_data = &cmt10_platform_data, + .platform_data = &cmt1_platform_data, }, - .resource = cmt10_resources, - .num_resources = ARRAY_SIZE(cmt10_resources), + .resource = cmt1_resources, + .num_resources = ARRAY_SIZE(cmt1_resources), }; /* TMU */ @@ -400,7 +388,7 @@ static struct platform_device *r8a7740_devices_dt[] __initdata = { &scif6_device, &scif7_device, &scif8_device, - &cmt10_device, + &cmt1_device, }; static struct platform_device *r8a7740_early_devices[] __initdata = { -- cgit v0.10.2 From 711ee6c8dee1df265773786cd0ec96f2cae5c189 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:13 +0200 Subject: ARM: shmobile: r8a7790: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart [horms+renesas@verge.net.au resolved conflict: use clk_names] Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 1eb48cf..1bca2748 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -90,7 +90,7 @@ static void __init lager_add_du_device(void) * devices until they get moved to DT. */ static const struct clk_name clk_names[] __initconst = { - { "cmt0", NULL, "sh_cmt.0" }, + { "cmt0", "fck", "sh-cmt-48-gen2.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, { "scifb0", NULL, "sh-sci.2" }, diff --git a/arch/arm/mach-shmobile/clock-r8a7790.c b/arch/arm/mach-shmobile/clock-r8a7790.c index a936ae7..296a057 100644 --- a/arch/arm/mach-shmobile/clock-r8a7790.c +++ b/arch/arm/mach-shmobile/clock-r8a7790.c @@ -357,7 +357,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP312]), CLKDEV_DEV_ID("sh_mobile_sdhi.3", &mstp_clks[MSTP311]), CLKDEV_DEV_ID("sh_mmcif.1", &mstp_clks[MSTP305]), - CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]), CLKDEV_DEV_ID("qspi.0", &mstp_clks[MSTP917]), CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP704]), CLKDEV_DEV_ID("pci-rcar-gen2.0", &mstp_clks[MSTP703]), @@ -367,6 +366,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sata-r8a7790.1", &mstp_clks[MSTP814]), /* ICK */ + CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.0", &mstp_clks[MSTP124]), CLKDEV_ICK_ID("usbhs", "usb_phy_rcar_gen2", &mstp_clks[MSTP704]), CLKDEV_ICK_ID("lvds.0", "rcar-du-r8a7790", &mstp_clks[MSTP726]), CLKDEV_ICK_ID("lvds.1", "rcar-du-r8a7790", &mstp_clks[MSTP725]), diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c index c4616f0..87327f3 100644 --- a/arch/arm/mach-shmobile/setup-r8a7790.c +++ b/arch/arm/mach-shmobile/setup-r8a7790.c @@ -269,20 +269,17 @@ static const struct resource thermal_resources[] __initconst = { thermal_resources, \ ARRAY_SIZE(thermal_resources)) -static const struct sh_timer_config cmt00_platform_data __initconst = { - .name = "CMT00", - .timer_bit = 0, - .clockevent_rating = 80, +static struct sh_timer_config cmt0_platform_data = { + .channels_mask = 0x60, }; -static const struct resource cmt00_resources[] __initconst = { - DEFINE_RES_MEM(0xffca0510, 0x0c), - DEFINE_RES_MEM(0xffca0500, 0x04), - DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */ +static struct resource cmt0_resources[] = { + DEFINE_RES_MEM(0xffca0000, 0x1004), + DEFINE_RES_IRQ(gic_spi(142)), }; #define r8a7790_register_cmt(idx) \ - platform_device_register_resndata(&platform_bus, "sh_cmt", \ + platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \ idx, cmt##idx##_resources, \ ARRAY_SIZE(cmt##idx##_resources), \ &cmt##idx##_platform_data, \ @@ -300,7 +297,7 @@ void __init r8a7790_add_dt_devices(void) r8a7790_register_scif(7); r8a7790_register_scif(8); r8a7790_register_scif(9); - r8a7790_register_cmt(00); + r8a7790_register_cmt(0); } void __init r8a7790_add_standard_devices(void) -- cgit v0.10.2 From 356af68bf483e4564f75a35287a8f5f39d31041f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:14 +0200 Subject: ARM: shmobile: r8a7791: Switch to new style CMT device The CMT (Compare Match Timer) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart [horms+renesas@verge.net.au resolved conflict: use clk_names] Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index 941f8b3..bd90932 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -86,7 +86,7 @@ static void __init koelsch_add_du_device(void) * devices until they get moved to DT. */ static const struct clk_name clk_names[] __initconst = { - { "cmt0", NULL, "sh_cmt.0" }, + { "cmt0", "fck", "sh-cmt-48-gen2.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, { "scifb0", NULL, "sh-sci.2" }, diff --git a/arch/arm/mach-shmobile/clock-r8a7791.c b/arch/arm/mach-shmobile/clock-r8a7791.c index 3b26c7e..e2fdfcc 100644 --- a/arch/arm/mach-shmobile/clock-r8a7791.c +++ b/arch/arm/mach-shmobile/clock-r8a7791.c @@ -264,7 +264,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP312]), CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP311]), - CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]), + CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.0", &mstp_clks[MSTP124]), CLKDEV_DEV_ID("qspi.0", &mstp_clks[MSTP917]), CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]), CLKDEV_DEV_ID("i2c-rcar_gen2.0", &mstp_clks[MSTP931]), diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c index e28404e..561653d 100644 --- a/arch/arm/mach-shmobile/setup-r8a7791.c +++ b/arch/arm/mach-shmobile/setup-r8a7791.c @@ -128,20 +128,17 @@ R8A7791_SCIFA(14, 0xe6c80000, gic_spi(31)); /* SCIFA5 */ &scif##index##_platform_data, \ sizeof(scif##index##_platform_data)) -static const struct sh_timer_config cmt00_platform_data __initconst = { - .name = "CMT00", - .timer_bit = 0, - .clockevent_rating = 80, +static struct sh_timer_config cmt0_platform_data = { + .channels_mask = 0x60, }; -static const struct resource cmt00_resources[] __initconst = { - DEFINE_RES_MEM(0xffca0510, 0x0c), - DEFINE_RES_MEM(0xffca0500, 0x04), - DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */ +static struct resource cmt0_resources[] = { + DEFINE_RES_MEM(0xffca0000, 0x1004), + DEFINE_RES_IRQ(gic_spi(142)), }; #define r8a7791_register_cmt(idx) \ - platform_device_register_resndata(&platform_bus, "sh_cmt", \ + platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \ idx, cmt##idx##_resources, \ ARRAY_SIZE(cmt##idx##_resources), \ &cmt##idx##_platform_data, \ @@ -200,7 +197,7 @@ void __init r8a7791_add_dt_devices(void) r8a7791_register_scif(12); r8a7791_register_scif(13); r8a7791_register_scif(14); - r8a7791_register_cmt(00); + r8a7791_register_cmt(0); } void __init r8a7791_add_standard_devices(void) -- cgit v0.10.2 From 1399c195ef5009bf44a41649da4718f6e67c0bff Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:15 +0200 Subject: sh: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c index 8de314b..121ef69 100644 --- a/arch/sh/kernel/cpu/clock-cpg.c +++ b/arch/sh/kernel/cpu/clock-cpg.c @@ -56,7 +56,10 @@ int __init __deprecated cpg_clk_init(void) clkdev_add_table(lookups, ARRAY_SIZE(lookups)); - clk_add_alias("tmu_fck", NULL, "peripheral_clk", NULL); + clk_add_alias("fck", "sh-tmu-sh3.0", "peripheral_clk", NULL); + clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL); + clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL); + clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL); clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL); clk_add_alias("fck", "sh-cmt-16.0", "peripheral_clk", NULL); clk_add_alias("fck", "sh-cmt-32.0", "peripheral_clk", NULL); diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7705.c b/arch/sh/kernel/cpu/sh3/setup-sh7705.c index c76b254..6a72fd1 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh7705.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh7705.c @@ -143,25 +143,18 @@ static struct platform_device rtc_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xfffffe94, - .end = 0xfffffe9f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xfffffe90, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu-sh3", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -170,67 +163,10 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0xe, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xfffffea0, - .end = 0xfffffeab, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1a, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xfffffeac, - .end = 0xfffffebb, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7705_devices[] __initdata = { &scif0_device, &scif1_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &rtc_device, }; @@ -245,8 +181,6 @@ static struct platform_device *sh7705_early_devices[] __initdata = { &scif0_device, &scif1_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c index ff1465c..9139d14 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c @@ -185,25 +185,18 @@ static struct platform_device scif2_device = { #endif static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xfffffe94, - .end = 0xfffffe9f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xfffffe90, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu-sh3", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -212,61 +205,6 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0xe, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xfffffea0, - .end = 0xfffffeab, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1a, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xfffffeac, - .end = 0xfffffebb, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh770x_devices[] __initdata = { &scif0_device, #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ @@ -279,8 +217,6 @@ static struct platform_device *sh770x_devices[] __initdata = { &scif2_device, #endif &tmu0_device, - &tmu1_device, - &tmu2_device, &rtc_device, }; @@ -303,8 +239,6 @@ static struct platform_device *sh770x_early_devices[] __initdata = { &scif2_device, #endif &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7710.c b/arch/sh/kernel/cpu/sh3/setup-sh7710.c index e2ce936..e9ed300 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh7710.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh7710.c @@ -142,25 +142,18 @@ static struct platform_device scif1_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xa412fe94, - .end = 0xa412fe9f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xa412fe90, 0x28), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu-sh3", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -169,67 +162,10 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0xe, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xa412fea0, - .end = 0xa412feab, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1a, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xa412feac, - .end = 0xa412feb5, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7710_devices[] __initdata = { &scif0_device, &scif1_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &rtc_device, }; @@ -244,8 +180,6 @@ static struct platform_device *sh7710_early_devices[] __initdata = { &scif0_device, &scif1_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c index a53d219..84df85a 100644 --- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c +++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c @@ -172,25 +172,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x02, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xa412fe94, - .end = 0xa412fe9f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xa412fe90, 0x28), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu-sh3", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -199,68 +192,11 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0xe, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xa412fea0, - .end = 0xa412feab, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1a, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xa412feac, - .end = 0xa412feb5, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7720_devices[] __initdata = { &scif0_device, &scif1_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &rtc_device, &usb_ohci_device, &usbf_device, @@ -278,8 +214,6 @@ static struct platform_device *sh7720_early_devices[] __initdata = { &scif1_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c index a8bd778..e7a7b3c 100644 --- a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c +++ b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c @@ -41,25 +41,18 @@ static struct platform_device scif0_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -68,66 +61,9 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh4202_devices[] __initdata = { &scif0_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; static int __init sh4202_devices_setup(void) @@ -140,8 +76,6 @@ arch_initcall(sh4202_devices_setup); static struct platform_device *sh4202_early_devices[] __initdata = { &scif0_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c index a447a24..5f08c59 100644 --- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c +++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c @@ -82,25 +82,18 @@ static struct platform_device scif_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -109,26 +102,23 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; +/* SH7750R, SH7751 and SH7751R all have two extra timer channels */ +#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ + defined(CONFIG_CPU_SUBTYPE_SH7751) || \ + defined(CONFIG_CPU_SUBTYPE_SH7751R) + static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 3, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xfe100000, 0x20), + DEFINE_RES_IRQ(evt2irq(0xb00)), + DEFINE_RES_IRQ(evt2irq(0xb80)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -137,104 +127,15 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -/* SH7750R, SH7751 and SH7751R all have two extra timer channels */ -#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ - defined(CONFIG_CPU_SUBTYPE_SH7751) || \ - defined(CONFIG_CPU_SUBTYPE_SH7751R) - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xfe100008, - .end = 0xfe100013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xb00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xfe100014, - .end = 0xfe10001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xb80), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - #endif static struct platform_device *sh7750_devices[] __initdata = { &rtc_device, &tmu0_device, - &tmu1_device, - &tmu2_device, #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ defined(CONFIG_CPU_SUBTYPE_SH7751) || \ defined(CONFIG_CPU_SUBTYPE_SH7751R) - &tmu3_device, - &tmu4_device, + &tmu1_device, #endif }; @@ -254,13 +155,10 @@ arch_initcall(sh7750_devices_setup); static struct platform_device *sh7750_early_devices[] __initdata = { &tmu0_device, - &tmu1_device, - &tmu2_device, #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \ defined(CONFIG_CPU_SUBTYPE_SH7751) || \ defined(CONFIG_CPU_SUBTYPE_SH7751R) - &tmu3_device, - &tmu4_device, + &tmu1_device, #endif }; diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c index 1abd9fb..973b736b 100644 --- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c +++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c @@ -227,25 +227,18 @@ static struct platform_device scif3_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -254,61 +247,6 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7760_devices[] __initdata = { &scif0_device, @@ -316,8 +254,6 @@ static struct platform_device *sh7760_devices[] __initdata = { &scif2_device, &scif3_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; static int __init sh7760_devices_setup(void) @@ -333,8 +269,6 @@ static struct platform_device *sh7760_early_devices[] __initdata = { &scif2_device, &scif3_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c index 4097493..8f07a1a 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c @@ -203,9 +203,7 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]), CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU]), CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]), CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c index da64734..ccbcab5 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c @@ -264,12 +264,8 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU2H0]), CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[HWBLK_TMU1]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[HWBLK_TMU1]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[HWBLK_TMU1]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU0]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[HWBLK_TMU1]), CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[HWBLK_SCIF0]), CLKDEV_ICK_ID("sci_fck", "sh-sci.1", &mstp_clks[HWBLK_SCIF1]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c index f917f19..f579dd5 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c @@ -304,17 +304,13 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]), CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU0]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[HWBLK_TMU1]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU0]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[HWBLK_TMU1]), CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[HWBLK_CMT]), CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]), CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[HWBLK_TMU1]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[HWBLK_TMU1]), CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[HWBLK_SCIF0]), CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[HWBLK_SCIF1]), CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[HWBLK_SCIF2]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7734.c b/arch/sh/kernel/cpu/sh4a/clock-sh7734.c index ed95015..1fdf1ee 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7734.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7734.c @@ -201,15 +201,9 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("sci_fck", "sh-sci.4", &mstp_clks[MSTP022]), CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP021]), CLKDEV_CON_ID("hscif", &mstp_clks[MSTP019]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP016]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP016]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP016]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP015]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP015]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP015]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.6", &mstp_clks[MSTP014]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.7", &mstp_clks[MSTP014]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.8", &mstp_clks[MSTP014]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP015]), + CLKDEV_ICK_ID("fck", "sh-tmu.2", &mstp_clks[MSTP014]), CLKDEV_CON_ID("ssi0", &mstp_clks[MSTP012]), CLKDEV_CON_ID("ssi1", &mstp_clks[MSTP011]), CLKDEV_CON_ID("ssi2", &mstp_clks[MSTP010]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c index 5c0e3c3..9a28fdb 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c @@ -123,8 +123,8 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("riic6", &mstp_clks[MSTP000]), CLKDEV_CON_ID("riic7", &mstp_clks[MSTP000]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP113]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP114]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP113]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP114]), CLKDEV_ICK_ID("sci_fck", "sh-sci.2", &mstp_clks[MSTP112]), CLKDEV_ICK_ID("sci_fck", "sh-sci.1", &mstp_clks[MSTP111]), CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[MSTP110]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c index 1c83788..17d0ea5 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c @@ -146,12 +146,8 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("mmcif_fck", &mstp_clks[MSTP013]), CLKDEV_CON_ID("flctl_fck", &mstp_clks[MSTP012]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]), CLKDEV_CON_ID("siof_fck", &mstp_clks[MSTP003]), CLKDEV_CON_ID("hspi_fck", &mstp_clks[MSTP002]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c index 8bba6f1..bec2a83 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c @@ -155,18 +155,10 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("i2c1_fck", &mstp_clks[MSTP015]), CLKDEV_CON_ID("i2c0_fck", &mstp_clks[MSTP014]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.6", &mstp_clks[MSTP010]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.7", &mstp_clks[MSTP010]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.8", &mstp_clks[MSTP010]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.9", &mstp_clks[MSTP011]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.10", &mstp_clks[MSTP011]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.11", &mstp_clks[MSTP011]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]), + CLKDEV_ICK_ID("fck", "sh-tmu.2", &mstp_clks[MSTP010]), + CLKDEV_ICK_ID("fck", "sh-tmu.3", &mstp_clks[MSTP011]), CLKDEV_CON_ID("sdif1_fck", &mstp_clks[MSTP005]), CLKDEV_CON_ID("sdif0_fck", &mstp_clks[MSTP004]), diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c index a9422da..9a49a44 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c +++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c @@ -124,12 +124,8 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("fe1_fck", &mstp_clks[MSTP001]), CLKDEV_CON_ID("fe0_fck", &mstp_clks[MSTP000]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]), - CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]), CLKDEV_CON_ID("hudi_fck", &mstp_clks[MSTP119]), CLKDEV_CON_ID("dmac_11_6_fck", &mstp_clks[MSTP105]), diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c index ad96492..ceb3ded 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c @@ -247,25 +247,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -274,61 +267,6 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7343_devices[] __initdata = { &scif0_device, &scif1_device, @@ -336,8 +274,6 @@ static struct platform_device *sh7343_devices[] __initdata = { &scif3_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &iic0_device, &iic1_device, &vpu_device, @@ -363,8 +299,6 @@ static struct platform_device *sh7343_early_devices[] __initdata = { &scif3_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c index 4e4985d..f75f673 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c @@ -195,25 +195,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 16, - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -222,67 +215,10 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh7366_devices[] __initdata = { &scif0_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &iic_device, &usb_host_device, &vpu_device, @@ -305,8 +241,6 @@ static struct platform_device *sh7366_early_devices[] __initdata = { &scif0_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c index 4e3218f..57f83a9 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c @@ -432,25 +432,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -459,61 +452,6 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 18, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct siu_platform siu_platform_data = { .dma_slave_tx_a = SHDMA_SLAVE_SIUA_TX, .dma_slave_rx_a = SHDMA_SLAVE_SIUA_RX, @@ -549,8 +487,6 @@ static struct platform_device *sh7722_devices[] __initdata = { &scif2_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, &rtc_device, &usbf_device, &iic_device, @@ -578,8 +514,6 @@ static struct platform_device *sh7722_early_devices[] __initdata = { &scif2_device, &cmt_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c index 5dfdb85..3533b56 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c @@ -264,25 +264,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -292,25 +285,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd90000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x920)), + DEFINE_RES_IRQ(evt2irq(0x940)), + DEFINE_RES_IRQ(evt2irq(0x960)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -319,114 +305,6 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffd90008, - .end = 0xffd90013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x920), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffd90014, - .end = 0xffd9001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x940), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffd90020, - .end = 0xffd9002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x920), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - static struct resource rtc_resources[] = { [0] = { .start = 0xa465fec0, @@ -517,10 +395,6 @@ static struct platform_device *sh7723_devices[] __initdata = { &cmt_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, &rtc_device, &iic_device, &sh7723_usb_host_device, @@ -550,10 +424,6 @@ static struct platform_device *sh7723_early_devices[] __initdata = { &cmt_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c index b435f07..b9e84b1 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c @@ -667,25 +667,18 @@ static struct platform_device cmt_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -695,25 +688,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd90000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x920)), + DEFINE_RES_IRQ(evt2irq(0x940)), + DEFINE_RES_IRQ(evt2irq(0x960)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -722,115 +708,6 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffd90008, - .end = 0xffd90013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x920), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffd90014, - .end = 0xffd9001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x940), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffd90020, - .end = 0xffd9002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x920), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - /* JPU */ static struct uio_info jpu_platform_data = { .name = "JPU", @@ -928,10 +805,6 @@ static struct platform_device *sh7724_devices[] __initdata = { &cmt_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, &dma0_device, &dma1_device, &rtc_device, @@ -971,10 +844,6 @@ static struct platform_device *sh7724_early_devices[] __initdata = { &cmt_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7734.c b/arch/sh/kernel/cpu/sh4a/setup-sh7734.c index dad4ed1..f617bcb 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7734.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7734.c @@ -200,25 +200,18 @@ static struct platform_device i2c0_device = { /* TMU */ static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xFFD80008, - .end = 0xFFD80014 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -228,26 +221,19 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xFFD80014, - .end = 0xFFD80020 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd81000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x480)), + DEFINE_RES_IRQ(evt2irq(0x4a0)), + DEFINE_RES_IRQ(evt2irq(0x4c0)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, + .name = "sh-tmu", + .id = 1, .dev = { .platform_data = &tmu1_platform_data, }, @@ -256,25 +242,19 @@ static struct platform_device tmu1_device = { }; static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, + .channels_mask = 7, }; static struct resource tmu2_resources[] = { - [0] = { - .start = 0xFFD80020, - .end = 0xFFD80030 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd82000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x500)), + DEFINE_RES_IRQ(evt2irq(0x520)), + DEFINE_RES_IRQ(evt2irq(0x540)), }; static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, + .name = "sh-tmu", + .id = 2, .dev = { .platform_data = &tmu2_platform_data, }, @@ -282,169 +262,6 @@ static struct platform_device tmu2_device = { .num_resources = ARRAY_SIZE(tmu2_resources), }; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xFFD81008, - .end = 0xFFD81014 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x480), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xFFD81014, - .end = 0xFFD81020 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4A0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xFFD81020, - .end = 0xFFD81030 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4C0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - -static struct sh_timer_config tmu6_platform_data = { - .channel_offset = 0x4, - .timer_bit = 0, -}; - -static struct resource tmu6_resources[] = { - [0] = { - .start = 0xFFD82008, - .end = 0xFFD82014 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x500), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu6_device = { - .name = "sh_tmu", - .id = 6, - .dev = { - .platform_data = &tmu6_platform_data, - }, - .resource = tmu6_resources, - .num_resources = ARRAY_SIZE(tmu6_resources), -}; - -static struct sh_timer_config tmu7_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu7_resources[] = { - [0] = { - .start = 0xFFD82014, - .end = 0xFFD82020 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x520), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu7_device = { - .name = "sh_tmu", - .id = 7, - .dev = { - .platform_data = &tmu7_platform_data, - }, - .resource = tmu7_resources, - .num_resources = ARRAY_SIZE(tmu7_resources), -}; - -static struct sh_timer_config tmu8_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu8_resources[] = { - [0] = { - .start = 0xFFD82020, - .end = 0xFFD82030 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x540), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu8_device = { - .name = "sh_tmu", - .id = 8, - .dev = { - .platform_data = &tmu8_platform_data, - }, - .resource = tmu8_resources, - .num_resources = ARRAY_SIZE(tmu8_resources), -}; - static struct platform_device *sh7734_devices[] __initdata = { &scif0_device, &scif1_device, @@ -455,12 +272,6 @@ static struct platform_device *sh7734_devices[] __initdata = { &tmu0_device, &tmu1_device, &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, - &tmu6_device, - &tmu7_device, - &tmu8_device, &rtc_device, }; @@ -474,12 +285,6 @@ static struct platform_device *sh7734_early_devices[] __initdata = { &tmu0_device, &tmu1_device, &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, - &tmu6_device, - &tmu7_device, - &tmu8_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c index e43e5db..7b24ec4 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c @@ -87,25 +87,17 @@ static struct platform_device scif4_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 3, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xfe430008, - .end = 0xfe430013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x580), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xfe430000, 0x20), + DEFINE_RES_IRQ(evt2irq(0x580)), + DEFINE_RES_IRQ(evt2irq(0x5a0)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -114,34 +106,6 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = 0xfe430014, - .end = 0xfe43001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - static struct resource spi0_resources[] = { [0] = { .start = 0xfe002000, @@ -782,7 +746,6 @@ static struct platform_device *sh7757_devices[] __initdata = { &scif3_device, &scif4_device, &tmu0_device, - &tmu1_device, &dma0_device, &dma1_device, &dma2_device, @@ -806,7 +769,6 @@ static struct platform_device *sh7757_early_devices[] __initdata = { &scif3_device, &scif4_device, &tmu0_device, - &tmu1_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c index 5eebbd7..5a47d67 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c @@ -158,25 +158,18 @@ static struct platform_device usbf_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x580), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x580)), + DEFINE_RES_IRQ(evt2irq(0x5a0)), + DEFINE_RES_IRQ(evt2irq(0x5c0)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -186,25 +179,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5a0), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd88000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0xe00)), + DEFINE_RES_IRQ(evt2irq(0xe20)), + DEFINE_RES_IRQ(evt2irq(0xe40)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -213,124 +199,12 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffd88008, - .end = 0xffd88013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffd88014, - .end = 0xffd8801f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe20), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffd88020, - .end = 0xffd8802b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe40), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - static struct platform_device *sh7763_devices[] __initdata = { &scif0_device, &scif1_device, &scif2_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, &rtc_device, &usb_ohci_device, &usbf_device, @@ -349,10 +223,6 @@ static struct platform_device *sh7763_early_devices[] __initdata = { &scif2_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c index e1ba8cb7..e9b532a 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c @@ -226,25 +226,18 @@ static struct platform_device scif9_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -254,25 +247,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd81000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x460)), + DEFINE_RES_IRQ(evt2irq(0x480)), + DEFINE_RES_IRQ(evt2irq(0x4a0)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -282,24 +268,18 @@ static struct platform_device tmu1_device = { }; static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, + .channels_mask = 7, }; static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd82000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x4c0)), + DEFINE_RES_IRQ(evt2irq(0x4e0)), + DEFINE_RES_IRQ(evt2irq(0x500)), }; static struct platform_device tmu2_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 2, .dev = { .platform_data = &tmu2_platform_data, @@ -308,168 +288,6 @@ static struct platform_device tmu2_device = { .num_resources = ARRAY_SIZE(tmu2_resources), }; -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffd81008, - .end = 0xffd81013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x460), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffd81014, - .end = 0xffd8101f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x480), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffd81020, - .end = 0xffd8102f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - -static struct sh_timer_config tmu6_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu6_resources[] = { - [0] = { - .start = 0xffd82008, - .end = 0xffd82013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu6_device = { - .name = "sh_tmu", - .id = 6, - .dev = { - .platform_data = &tmu6_platform_data, - }, - .resource = tmu6_resources, - .num_resources = ARRAY_SIZE(tmu6_resources), -}; - -static struct sh_timer_config tmu7_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu7_resources[] = { - [0] = { - .start = 0xffd82014, - .end = 0xffd8201f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4e0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu7_device = { - .name = "sh_tmu", - .id = 7, - .dev = { - .platform_data = &tmu7_platform_data, - }, - .resource = tmu7_resources, - .num_resources = ARRAY_SIZE(tmu7_resources), -}; - -static struct sh_timer_config tmu8_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu8_resources[] = { - [0] = { - .start = 0xffd82020, - .end = 0xffd8202b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x500), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu8_device = { - .name = "sh_tmu", - .id = 8, - .dev = { - .platform_data = &tmu8_platform_data, - }, - .resource = tmu8_resources, - .num_resources = ARRAY_SIZE(tmu8_resources), -}; - static struct platform_device *sh7770_devices[] __initdata = { &scif0_device, &scif1_device, @@ -484,12 +302,6 @@ static struct platform_device *sh7770_devices[] __initdata = { &tmu0_device, &tmu1_device, &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, - &tmu6_device, - &tmu7_device, - &tmu8_device, }; static int __init sh7770_devices_setup(void) @@ -513,12 +325,6 @@ static struct platform_device *sh7770_early_devices[] __initdata = { &tmu0_device, &tmu1_device, &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, - &tmu6_device, - &tmu7_device, - &tmu8_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c index 668e54b..3ee7dd9 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c @@ -62,25 +62,18 @@ static struct platform_device scif1_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x580), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x580)), + DEFINE_RES_IRQ(evt2irq(0x5a0)), + DEFINE_RES_IRQ(evt2irq(0x5c0)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -90,25 +83,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5a0), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffdc0000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0xe00)), + DEFINE_RES_IRQ(evt2irq(0xe20)), + DEFINE_RES_IRQ(evt2irq(0xe40)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -117,114 +103,6 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffdc0008, - .end = 0xffdc0013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffdc0014, - .end = 0xffdc001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe20), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffdc0020, - .end = 0xffdc002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe40), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - static struct resource rtc_resources[] = { [0] = { .start = 0xffe80000, @@ -386,10 +264,6 @@ static struct platform_device *sh7780_devices[] __initdata = { &scif1_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, &rtc_device, &dma0_device, &dma1_device, @@ -407,10 +281,6 @@ static struct platform_device *sh7780_early_devices[] __initdata = { &scif1_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c index 4aa6791..c72d5a5 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c @@ -152,25 +152,18 @@ static struct platform_device scif5_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x580), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x580)), + DEFINE_RES_IRQ(evt2irq(0x5a0)), + DEFINE_RES_IRQ(evt2irq(0x5c0)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -180,25 +173,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5a0), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffdc0000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0xe00)), + DEFINE_RES_IRQ(evt2irq(0xe20)), + DEFINE_RES_IRQ(evt2irq(0xe40)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -207,114 +193,6 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x5c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffdc0008, - .end = 0xffdc0013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe00), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffdc0014, - .end = 0xffdc001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe20), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffdc0020, - .end = 0xffdc002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0xe40), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - /* DMA */ static const struct sh_dmae_channel sh7785_dmae0_channels[] = { { @@ -460,10 +338,6 @@ static struct platform_device *sh7785_devices[] __initdata = { &scif5_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, &dma0_device, &dma1_device, }; @@ -484,10 +358,6 @@ static struct platform_device *sh7785_early_devices[] __initdata = { &scif5_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c index 5d619a5..479e79b 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c @@ -175,25 +175,18 @@ static struct platform_device scif5_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -203,25 +196,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffda0000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x480)), + DEFINE_RES_IRQ(evt2irq(0x4a0)), + DEFINE_RES_IRQ(evt2irq(0x4c0)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -231,24 +217,18 @@ static struct platform_device tmu1_device = { }; static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, + .channels_mask = 7, }; static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffd80020, - .end = 0xffd8002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffdc0000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x7a0)), + DEFINE_RES_IRQ(evt2irq(0x7a0)), + DEFINE_RES_IRQ(evt2irq(0x7a0)), }; static struct platform_device tmu2_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 2, .dev = { .platform_data = &tmu2_platform_data, @@ -258,24 +238,18 @@ static struct platform_device tmu2_device = { }; static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, + .channels_mask = 7, }; static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffda0008, - .end = 0xffda0013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x480), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffde0000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x7c0)), + DEFINE_RES_IRQ(evt2irq(0x7c0)), + DEFINE_RES_IRQ(evt2irq(0x7c0)), }; static struct platform_device tmu3_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 3, .dev = { .platform_data = &tmu3_platform_data, @@ -284,222 +258,6 @@ static struct platform_device tmu3_device = { .num_resources = ARRAY_SIZE(tmu3_resources), }; -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffda0014, - .end = 0xffda001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffda0020, - .end = 0xffda002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - -static struct sh_timer_config tmu6_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu6_resources[] = { - [0] = { - .start = 0xffdc0008, - .end = 0xffdc0013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu6_device = { - .name = "sh_tmu", - .id = 6, - .dev = { - .platform_data = &tmu6_platform_data, - }, - .resource = tmu6_resources, - .num_resources = ARRAY_SIZE(tmu6_resources), -}; - -static struct sh_timer_config tmu7_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu7_resources[] = { - [0] = { - .start = 0xffdc0014, - .end = 0xffdc001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu7_device = { - .name = "sh_tmu", - .id = 7, - .dev = { - .platform_data = &tmu7_platform_data, - }, - .resource = tmu7_resources, - .num_resources = ARRAY_SIZE(tmu7_resources), -}; - -static struct sh_timer_config tmu8_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu8_resources[] = { - [0] = { - .start = 0xffdc0020, - .end = 0xffdc002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu8_device = { - .name = "sh_tmu", - .id = 8, - .dev = { - .platform_data = &tmu8_platform_data, - }, - .resource = tmu8_resources, - .num_resources = ARRAY_SIZE(tmu8_resources), -}; - -static struct sh_timer_config tmu9_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu9_resources[] = { - [0] = { - .start = 0xffde0008, - .end = 0xffde0013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu9_device = { - .name = "sh_tmu", - .id = 9, - .dev = { - .platform_data = &tmu9_platform_data, - }, - .resource = tmu9_resources, - .num_resources = ARRAY_SIZE(tmu9_resources), -}; - -static struct sh_timer_config tmu10_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu10_resources[] = { - [0] = { - .start = 0xffde0014, - .end = 0xffde001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu10_device = { - .name = "sh_tmu", - .id = 10, - .dev = { - .platform_data = &tmu10_platform_data, - }, - .resource = tmu10_resources, - .num_resources = ARRAY_SIZE(tmu10_resources), -}; - -static struct sh_timer_config tmu11_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu11_resources[] = { - [0] = { - .start = 0xffde0020, - .end = 0xffde002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x7c0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu11_device = { - .name = "sh_tmu", - .id = 11, - .dev = { - .platform_data = &tmu11_platform_data, - }, - .resource = tmu11_resources, - .num_resources = ARRAY_SIZE(tmu11_resources), -}; - static const struct sh_dmae_channel dmac0_channels[] = { { .offset = 0, @@ -641,15 +399,6 @@ static struct platform_device *sh7786_early_devices[] __initdata = { &tmu0_device, &tmu1_device, &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, - &tmu6_device, - &tmu7_device, - &tmu8_device, - &tmu9_device, - &tmu10_device, - &tmu11_device, }; static struct platform_device *sh7786_devices[] __initdata = { diff --git a/arch/sh/kernel/cpu/sh4a/setup-shx3.c b/arch/sh/kernel/cpu/sh4a/setup-shx3.c index 0856bcb..a78c5fe 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-shx3.c +++ b/arch/sh/kernel/cpu/sh4a/setup-shx3.c @@ -100,25 +100,18 @@ static struct platform_device scif2_device = { }; static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = 0xffc10008, - .end = 0xffc10013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x400), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffc10000, 0x30), + DEFINE_RES_IRQ(evt2irq(0x400)), + DEFINE_RES_IRQ(evt2irq(0x420)), + DEFINE_RES_IRQ(evt2irq(0x440)), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -128,25 +121,18 @@ static struct platform_device tmu0_device = { }; static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + .channels_mask = 7, }; static struct resource tmu1_resources[] = { - [0] = { - .start = 0xffc10014, - .end = 0xffc1001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x420), - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(0xffc20000, 0x2c), + DEFINE_RES_IRQ(evt2irq(0x460)), + DEFINE_RES_IRQ(evt2irq(0x480)), + DEFINE_RES_IRQ(evt2irq(0x4a0)), }; static struct platform_device tmu1_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 1, .dev = { .platform_data = &tmu1_platform_data, @@ -155,124 +141,12 @@ static struct platform_device tmu1_device = { .num_resources = ARRAY_SIZE(tmu1_resources), }; -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = 0xffc10020, - .end = 0xffc1002f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x440), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - -static struct sh_timer_config tmu3_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, -}; - -static struct resource tmu3_resources[] = { - [0] = { - .start = 0xffc20008, - .end = 0xffc20013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x460), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu3_device = { - .name = "sh_tmu", - .id = 3, - .dev = { - .platform_data = &tmu3_platform_data, - }, - .resource = tmu3_resources, - .num_resources = ARRAY_SIZE(tmu3_resources), -}; - -static struct sh_timer_config tmu4_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, -}; - -static struct resource tmu4_resources[] = { - [0] = { - .start = 0xffc20014, - .end = 0xffc2001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x480), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu4_device = { - .name = "sh_tmu", - .id = 4, - .dev = { - .platform_data = &tmu4_platform_data, - }, - .resource = tmu4_resources, - .num_resources = ARRAY_SIZE(tmu4_resources), -}; - -static struct sh_timer_config tmu5_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu5_resources[] = { - [0] = { - .start = 0xffc20020, - .end = 0xffc2002b, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = evt2irq(0x4a0), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu5_device = { - .name = "sh_tmu", - .id = 5, - .dev = { - .platform_data = &tmu5_platform_data, - }, - .resource = tmu5_resources, - .num_resources = ARRAY_SIZE(tmu5_resources), -}; - static struct platform_device *shx3_early_devices[] __initdata = { &scif0_device, &scif1_device, &scif2_device, &tmu0_device, &tmu1_device, - &tmu2_device, - &tmu3_device, - &tmu4_device, - &tmu5_device, }; static int __init shx3_devices_setup(void) diff --git a/arch/sh/kernel/cpu/sh5/setup-sh5.c b/arch/sh/kernel/cpu/sh5/setup-sh5.c index 14d6821..1bf0b2c 100644 --- a/arch/sh/kernel/cpu/sh5/setup-sh5.c +++ b/arch/sh/kernel/cpu/sh5/setup-sh5.c @@ -71,30 +71,20 @@ static struct platform_device rtc_device = { #define TMU_BLOCK_OFF 0x01020000 #define TMU_BASE PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF -#define TMU0_BASE (TMU_BASE + 0x8 + (0xc * 0x0)) -#define TMU1_BASE (TMU_BASE + 0x8 + (0xc * 0x1)) -#define TMU2_BASE (TMU_BASE + 0x8 + (0xc * 0x2)) static struct sh_timer_config tmu0_platform_data = { - .channel_offset = 0x04, - .timer_bit = 0, - .clockevent_rating = 200, + .channels_mask = 7, }; static struct resource tmu0_resources[] = { - [0] = { - .start = TMU0_BASE, - .end = TMU0_BASE + 0xc - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_TUNI0, - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM(TMU_BASE, 0x30), + DEFINE_RES_IRQ(IRQ_TUNI0), + DEFINE_RES_IRQ(IRQ_TUNI1), + DEFINE_RES_IRQ(IRQ_TUNI2), }; static struct platform_device tmu0_device = { - .name = "sh_tmu", + .name = "sh-tmu", .id = 0, .dev = { .platform_data = &tmu0_platform_data, @@ -103,66 +93,9 @@ static struct platform_device tmu0_device = { .num_resources = ARRAY_SIZE(tmu0_resources), }; -static struct sh_timer_config tmu1_platform_data = { - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu1_resources[] = { - [0] = { - .start = TMU1_BASE, - .end = TMU1_BASE + 0xc - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_TUNI1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu1_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu1_platform_data, - }, - .resource = tmu1_resources, - .num_resources = ARRAY_SIZE(tmu1_resources), -}; - -static struct sh_timer_config tmu2_platform_data = { - .channel_offset = 0x1c, - .timer_bit = 2, -}; - -static struct resource tmu2_resources[] = { - [0] = { - .start = TMU2_BASE, - .end = TMU2_BASE + 0xc - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_TUNI2, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu2_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu2_platform_data, - }, - .resource = tmu2_resources, - .num_resources = ARRAY_SIZE(tmu2_resources), -}; - static struct platform_device *sh5_early_devices[] __initdata = { &scif0_device, &tmu0_device, - &tmu1_device, - &tmu2_device, }; static struct platform_device *sh5_devices[] __initdata = { -- cgit v0.10.2 From 8e8236a9d86e5cf5979be13c3063d2381fbed285 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:16 +0200 Subject: ARM: shmobile: sh7372: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c index c622b49..d16d9ca 100644 --- a/arch/arm/mach-shmobile/clock-sh7372.c +++ b/arch/arm/mach-shmobile/clock-sh7372.c @@ -515,8 +515,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("uio_pdrv_genirq.1", &mstp_clks[MSTP128]), /* VEU0 */ CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU */ CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */ - CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ - CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX0 */ CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */ CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */ @@ -577,6 +575,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("ick", "sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]), CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]), CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP125]), /* TMU0 */ CLKDEV_ICK_ID("spu2", "sh_fsi2", &mstp_clks[MSTP223]), CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.4", &mstp_clks[MSTP405]), /* CMT4 */ CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.3", &mstp_clks[MSTP404]), /* CMT3 */ diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c index 4c0e943..178acfe 100644 --- a/arch/arm/mach-shmobile/setup-sh7372.c +++ b/arch/arm/mach-shmobile/setup-sh7372.c @@ -138,64 +138,25 @@ static struct platform_device cmt2_device = { }; /* TMU */ -static struct sh_timer_config tmu00_platform_data = { - .name = "TMU00", - .channel_offset = 0x4, - .timer_bit = 0, - .clockevent_rating = 200, +static struct sh_timer_config tmu0_platform_data = { + .channels_mask = 7, }; -static struct resource tmu00_resources[] = { - [0] = { - .name = "TMU00", - .start = 0xfff60008, - .end = 0xfff60013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */ - .flags = IORESOURCE_IRQ, - }, +static struct resource tmu0_resources[] = { + DEFINE_RES_MEM(0xfff60000, 0x2c), + DEFINE_RES_IRQ(intcs_evt2irq(0xe80)), + DEFINE_RES_IRQ(intcs_evt2irq(0xea0)), + DEFINE_RES_IRQ(intcs_evt2irq(0xec0)), }; -static struct platform_device tmu00_device = { - .name = "sh_tmu", +static struct platform_device tmu0_device = { + .name = "sh-tmu", .id = 0, .dev = { - .platform_data = &tmu00_platform_data, - }, - .resource = tmu00_resources, - .num_resources = ARRAY_SIZE(tmu00_resources), -}; - -static struct sh_timer_config tmu01_platform_data = { - .name = "TMU01", - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu01_resources[] = { - [0] = { - .name = "TMU01", - .start = 0xfff60014, - .end = 0xfff6001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */ - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu01_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu01_platform_data, + .platform_data = &tmu0_platform_data, }, - .resource = tmu01_resources, - .num_resources = ARRAY_SIZE(tmu01_resources), + .resource = tmu0_resources, + .num_resources = ARRAY_SIZE(tmu0_resources), }; /* I2C */ @@ -940,8 +901,7 @@ static struct platform_device *sh7372_early_devices[] __initdata = { &scif5_device, &scif6_device, &cmt2_device, - &tmu00_device, - &tmu01_device, + &tmu0_device, &ipmmu_device, }; @@ -988,8 +948,7 @@ void __init sh7372_add_standard_devices(void) { "A4R", &veu2_device, }, { "A4R", &veu3_device, }, { "A4R", &jpu_device, }, - { "A4R", &tmu00_device, }, - { "A4R", &tmu01_device, }, + { "A4R", &tmu0_device, }, }; sh7372_init_pm_domains(); -- cgit v0.10.2 From 3df592bc335a6efe30c88c9e39d29ceb5c20bbfb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:17 +0200 Subject: ARM: shmobile: sh73a0: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c index ca03989..0d9cd1f 100644 --- a/arch/arm/mach-shmobile/clock-sh73a0.c +++ b/arch/arm/mach-shmobile/clock-sh73a0.c @@ -633,8 +633,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh-mobile-csi2.1", &mstp_clks[MSTP128]), /* CSI2-RX1 */ CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU0 */ CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2-RX0 */ - CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */ - CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */ CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */ CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */ CLKDEV_DEV_ID("e6820000.i2c", &mstp_clks[MSTP116]), /* I2C0 */ @@ -683,6 +681,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk), CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk), CLKDEV_ICK_ID("fck", "sh-cmt-48.1", &mstp_clks[MSTP329]), /* CMT1 */ + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP125]), /* TMU0 */ }; void __init sh73a0_clock_init(void) diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c index 71d0e44..ad00724 100644 --- a/arch/arm/mach-shmobile/setup-sh73a0.c +++ b/arch/arm/mach-shmobile/setup-sh73a0.c @@ -124,54 +124,25 @@ static struct platform_device cmt1_device = { }; /* TMU */ -static struct sh_timer_config tmu00_platform_data = { - .name = "TMU00", - .channel_offset = 0x4, - .timer_bit = 0, - .clockevent_rating = 200, +static struct sh_timer_config tmu0_platform_data = { + .channels_mask = 7, }; -static struct resource tmu00_resources[] = { - [0] = DEFINE_RES_MEM(0xfff60008, 0xc), - [1] = { - .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */ - .flags = IORESOURCE_IRQ, - }, +static struct resource tmu0_resources[] = { + DEFINE_RES_MEM(0xfff60000, 0x2c), + DEFINE_RES_IRQ(intcs_evt2irq(0xe80)), + DEFINE_RES_IRQ(intcs_evt2irq(0xea0)), + DEFINE_RES_IRQ(intcs_evt2irq(0xec0)), }; -static struct platform_device tmu00_device = { - .name = "sh_tmu", +static struct platform_device tmu0_device = { + .name = "sh-tmu", .id = 0, .dev = { - .platform_data = &tmu00_platform_data, - }, - .resource = tmu00_resources, - .num_resources = ARRAY_SIZE(tmu00_resources), -}; - -static struct sh_timer_config tmu01_platform_data = { - .name = "TMU01", - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu01_resources[] = { - [0] = DEFINE_RES_MEM(0xfff60014, 0xc), - [1] = { - .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */ - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu01_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu01_platform_data, + .platform_data = &tmu0_platform_data, }, - .resource = tmu01_resources, - .num_resources = ARRAY_SIZE(tmu01_resources), + .resource = tmu0_resources, + .num_resources = ARRAY_SIZE(tmu0_resources), }; static struct resource i2c0_resources[] = { @@ -738,8 +709,7 @@ static struct platform_device *sh73a0_devices_dt[] __initdata = { }; static struct platform_device *sh73a0_early_devices[] __initdata = { - &tmu00_device, - &tmu01_device, + &tmu0_device, &ipmmu_device, }; -- cgit v0.10.2 From 8ec72e46067d237dd60a08582e6427159c3f4b5f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:18 +0200 Subject: ARM: shmobile: r8a7740: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c index cdb303c..2c1044a 100644 --- a/arch/arm/mach-shmobile/clock-r8a7740.c +++ b/arch/arm/mach-shmobile/clock-r8a7740.c @@ -548,15 +548,9 @@ static struct clk_lookup lookups[] = { /* MSTP32 clocks */ CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), - CLKDEV_DEV_ID("sh_tmu.3", &mstp_clks[MSTP111]), - CLKDEV_DEV_ID("sh_tmu.4", &mstp_clks[MSTP111]), - CLKDEV_DEV_ID("sh_tmu.5", &mstp_clks[MSTP111]), CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), CLKDEV_DEV_ID("fff20000.i2c", &mstp_clks[MSTP116]), CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), - CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), - CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), - CLKDEV_DEV_ID("sh_tmu.2", &mstp_clks[MSTP125]), CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[MSTP128]), @@ -603,6 +597,8 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("e6870000.sd", &mstp_clks[MSTP415]), /* ICK */ + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP111]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP125]), CLKDEV_ICK_ID("fck", "sh-cmt-48.1", &mstp_clks[MSTP329]), CLKDEV_ICK_ID("host", "renesas_usbhs", &mstp_clks[MSTP416]), CLKDEV_ICK_ID("func", "renesas_usbhs", &mstp_clks[MSTP407]), diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index 495e9bd..b7a09bb 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c @@ -257,94 +257,25 @@ static struct platform_device cmt1_device = { }; /* TMU */ -static struct sh_timer_config tmu00_platform_data = { - .name = "TMU00", - .channel_offset = 0x4, - .timer_bit = 0, - .clockevent_rating = 200, +static struct sh_timer_config tmu0_platform_data = { + .channels_mask = 7, }; -static struct resource tmu00_resources[] = { - [0] = { - .name = "TMU00", - .start = 0xfff80008, - .end = 0xfff80014 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_spi(198), - .flags = IORESOURCE_IRQ, - }, +static struct resource tmu0_resources[] = { + DEFINE_RES_MEM(0xfff80000, 0x2c), + DEFINE_RES_IRQ(gic_spi(198)), + DEFINE_RES_IRQ(gic_spi(199)), + DEFINE_RES_IRQ(gic_spi(200)), }; -static struct platform_device tmu00_device = { - .name = "sh_tmu", +static struct platform_device tmu0_device = { + .name = "sh-tmu", .id = 0, .dev = { - .platform_data = &tmu00_platform_data, - }, - .resource = tmu00_resources, - .num_resources = ARRAY_SIZE(tmu00_resources), -}; - -static struct sh_timer_config tmu01_platform_data = { - .name = "TMU01", - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu01_resources[] = { - [0] = { - .name = "TMU01", - .start = 0xfff80014, - .end = 0xfff80020 - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_spi(199), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu01_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu01_platform_data, - }, - .resource = tmu01_resources, - .num_resources = ARRAY_SIZE(tmu01_resources), -}; - -static struct sh_timer_config tmu02_platform_data = { - .name = "TMU02", - .channel_offset = 0x1C, - .timer_bit = 2, - .clocksource_rating = 200, -}; - -static struct resource tmu02_resources[] = { - [0] = { - .name = "TMU02", - .start = 0xfff80020, - .end = 0xfff8002C - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_spi(200), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu02_device = { - .name = "sh_tmu", - .id = 2, - .dev = { - .platform_data = &tmu02_platform_data, + .platform_data = &tmu0_platform_data, }, - .resource = tmu02_resources, - .num_resources = ARRAY_SIZE(tmu02_resources), + .resource = tmu0_resources, + .num_resources = ARRAY_SIZE(tmu0_resources), }; /* IPMMUI (an IPMMU module for ICB/LMB) */ @@ -396,9 +327,7 @@ static struct platform_device *r8a7740_early_devices[] __initdata = { &irqpin1_device, &irqpin2_device, &irqpin3_device, - &tmu00_device, - &tmu01_device, - &tmu02_device, + &tmu0_device, &ipmmu_device, }; -- cgit v0.10.2 From 535ef0d9575b0809915341481ef3bac6bb5d0aaa Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 2 May 2014 20:21:25 +0200 Subject: ARM: shmobile: r8a7778: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c index 201fc48..65f08f7 100644 --- a/arch/arm/mach-shmobile/clock-r8a7778.c +++ b/arch/arm/mach-shmobile/clock-r8a7778.c @@ -207,8 +207,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP023]), /* SCIF3 */ CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP022]), /* SCIF4 */ CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP021]), /* SCIF6 */ - CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */ - CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP015]), /* TMU01 */ CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */ CLKDEV_DEV_ID("fffc7000.spi", &mstp_clks[MSTP007]), /* HSPI0 */ CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */ @@ -239,6 +237,8 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("src.6", "rcar_sound", &mstp_clks[MSTP525]), CLKDEV_ICK_ID("src.7", "rcar_sound", &mstp_clks[MSTP524]), CLKDEV_ICK_ID("src.8", "rcar_sound", &mstp_clks[MSTP523]), + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]), + CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP015]), }; void __init r8a7778_clock_init(void) diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c index 6d69452..8c02e24 100644 --- a/arch/arm/mach-shmobile/setup-r8a7778.c +++ b/arch/arm/mach-shmobile/setup-r8a7778.c @@ -71,33 +71,20 @@ R8A7778_SCIF(5, 0xffe45000, gic_iid(0x6b)); sizeof(scif##index##_platform_data)) /* TMU */ -static struct resource sh_tmu0_resources[] __initdata = { - DEFINE_RES_MEM(0xffd80008, 12), - DEFINE_RES_IRQ(gic_iid(0x40)), -}; - -static struct sh_timer_config sh_tmu0_platform_data __initdata = { - .name = "TMU00", - .channel_offset = 0x4, - .timer_bit = 0, - .clockevent_rating = 200, +static struct sh_timer_config sh_tmu0_platform_data = { + .channels_mask = 7, }; -static struct resource sh_tmu1_resources[] __initdata = { - DEFINE_RES_MEM(0xffd80014, 12), +static struct resource sh_tmu0_resources[] = { + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(gic_iid(0x40)), DEFINE_RES_IRQ(gic_iid(0x41)), -}; - -static struct sh_timer_config sh_tmu1_platform_data __initdata = { - .name = "TMU01", - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, + DEFINE_RES_IRQ(gic_iid(0x42)), }; #define r8a7778_register_tmu(idx) \ platform_device_register_resndata( \ - &platform_bus, "sh_tmu", idx, \ + &platform_bus, "sh-tmu", idx, \ sh_tmu##idx##_resources, \ ARRAY_SIZE(sh_tmu##idx##_resources), \ &sh_tmu##idx##_platform_data, \ @@ -312,7 +299,6 @@ void __init r8a7778_add_dt_devices(void) r8a7778_register_scif(4); r8a7778_register_scif(5); r8a7778_register_tmu(0); - r8a7778_register_tmu(1); } /* HPB-DMA */ -- cgit v0.10.2 From e4ae34e285b1c102686cb1c2a39ef93f930bf8f4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:20 +0200 Subject: ARM: shmobile: r8a7779: Switch to new style TMU device The TMU (Timer Unit) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c index 8e403ae..a13298b 100644 --- a/arch/arm/mach-shmobile/clock-r8a7779.c +++ b/arch/arm/mach-shmobile/clock-r8a7779.c @@ -173,9 +173,7 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("ohci-platform.1", &mstp_clks[MSTP101]), /* USB OHCI port2 */ CLKDEV_DEV_ID("ehci-platform.0", &mstp_clks[MSTP100]), /* USB EHCI port0/1 */ CLKDEV_DEV_ID("ohci-platform.0", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */ - CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */ - CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP016]), /* TMU01 */ - CLKDEV_DEV_ID("sh_tmu.2", &mstp_clks[MSTP016]), /* TMU02 */ + CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]), /* TMU0 */ CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */ CLKDEV_DEV_ID("ffc70000.i2c", &mstp_clks[MSTP030]), /* I2C0 */ CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */ diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c index 8e860b3..d197b5a 100644 --- a/arch/arm/mach-shmobile/setup-r8a7779.c +++ b/arch/arm/mach-shmobile/setup-r8a7779.c @@ -219,64 +219,25 @@ R8A7779_SCIF(4, 0xffe44000, gic_iid(0x7c)); R8A7779_SCIF(5, 0xffe45000, gic_iid(0x7d)); /* TMU */ -static struct sh_timer_config tmu00_platform_data = { - .name = "TMU00", - .channel_offset = 0x4, - .timer_bit = 0, - .clockevent_rating = 200, +static struct sh_timer_config tmu0_platform_data = { + .channels_mask = 7, }; -static struct resource tmu00_resources[] = { - [0] = { - .name = "TMU00", - .start = 0xffd80008, - .end = 0xffd80013, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_iid(0x40), - .flags = IORESOURCE_IRQ, - }, +static struct resource tmu0_resources[] = { + DEFINE_RES_MEM(0xffd80000, 0x30), + DEFINE_RES_IRQ(gic_iid(0x40)), + DEFINE_RES_IRQ(gic_iid(0x41)), + DEFINE_RES_IRQ(gic_iid(0x42)), }; -static struct platform_device tmu00_device = { - .name = "sh_tmu", +static struct platform_device tmu0_device = { + .name = "sh-tmu", .id = 0, .dev = { - .platform_data = &tmu00_platform_data, - }, - .resource = tmu00_resources, - .num_resources = ARRAY_SIZE(tmu00_resources), -}; - -static struct sh_timer_config tmu01_platform_data = { - .name = "TMU01", - .channel_offset = 0x10, - .timer_bit = 1, - .clocksource_rating = 200, -}; - -static struct resource tmu01_resources[] = { - [0] = { - .name = "TMU01", - .start = 0xffd80014, - .end = 0xffd8001f, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = gic_iid(0x41), - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device tmu01_device = { - .name = "sh_tmu", - .id = 1, - .dev = { - .platform_data = &tmu01_platform_data, + .platform_data = &tmu0_platform_data, }, - .resource = tmu01_resources, - .num_resources = ARRAY_SIZE(tmu01_resources), + .resource = tmu0_resources, + .num_resources = ARRAY_SIZE(tmu0_resources), }; /* I2C */ @@ -685,8 +646,7 @@ static struct platform_device *r8a7779_devices_dt[] __initdata = { &scif3_device, &scif4_device, &scif5_device, - &tmu00_device, - &tmu01_device, + &tmu0_device, }; static struct platform_device *r8a7779_standard_devices[] __initdata = { -- cgit v0.10.2 From 5204601c0877b3ffc90e417bf30fccc9bdf47962 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:21 +0200 Subject: sh: Switch to new style MTU2 device The MTU2 (Multi-Function Timer Pulse Unit 2) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/sh/kernel/cpu/clock-cpg.c b/arch/sh/kernel/cpu/clock-cpg.c index 121ef69..8525a67 100644 --- a/arch/sh/kernel/cpu/clock-cpg.c +++ b/arch/sh/kernel/cpu/clock-cpg.c @@ -60,7 +60,7 @@ int __init __deprecated cpg_clk_init(void) clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL); clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL); clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL); - clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL); + clk_add_alias("fck", "sh-mtu2", "peripheral_clk", NULL); clk_add_alias("fck", "sh-cmt-16.0", "peripheral_clk", NULL); clk_add_alias("fck", "sh-cmt-32.0", "peripheral_clk", NULL); clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL); diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7264.c b/arch/sh/kernel/cpu/sh2a/clock-sh7264.c index c7f3c66..8638fba 100644 --- a/arch/sh/kernel/cpu/sh2a/clock-sh7264.c +++ b/arch/sh/kernel/cpu/sh2a/clock-sh7264.c @@ -119,7 +119,7 @@ static struct clk_lookup lookups[] = { CLKDEV_CON_ID("vdc3", &mstp_clks[MSTP74]), CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]), CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]), - CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]), + CLKDEV_ICK_ID("fck", "sh-mtu2", &mstp_clks[MSTP35]), CLKDEV_CON_ID("sdhi0", &mstp_clks[MSTP34]), CLKDEV_CON_ID("sdhi1", &mstp_clks[MSTP33]), CLKDEV_CON_ID("adc0", &mstp_clks[MSTP32]), diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7269.c b/arch/sh/kernel/cpu/sh2a/clock-sh7269.c index 4f47464..f8a5c2a 100644 --- a/arch/sh/kernel/cpu/sh2a/clock-sh7269.c +++ b/arch/sh/kernel/cpu/sh2a/clock-sh7269.c @@ -160,7 +160,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("sci_fck", "sh-sci.7", &mstp_clks[MSTP40]), CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]), CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]), - CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]), + CLKDEV_ICK_ID("fck", "sh-mtu2", &mstp_clks[MSTP35]), CLKDEV_CON_ID("adc0", &mstp_clks[MSTP32]), CLKDEV_CON_ID("rtc0", &mstp_clks[MSTP30]), }; diff --git a/arch/sh/kernel/cpu/sh2a/setup-mxg.c b/arch/sh/kernel/cpu/sh2a/setup-mxg.c index 63e996f..26fcdbd 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-mxg.c +++ b/arch/sh/kernel/cpu/sh2a/setup-mxg.c @@ -114,88 +114,18 @@ static struct intc_mask_reg mask_registers[] __initdata = { static DECLARE_INTC_DESC(intc_desc, "mxg", vectors, groups, mask_registers, prio_registers, NULL); -static struct sh_timer_config mtu2_0_platform_data = { - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xff801000, 0x400), + DEFINE_RES_IRQ_NAMED(228, "tgi0a"), + DEFINE_RES_IRQ_NAMED(234, "tgi1a"), + DEFINE_RES_IRQ_NAMED(240, "tgi2a"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .start = 0xff801300, - .end = 0xff801326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 228, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .start = 0xff801380, - .end = 0xff801390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 234, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), -}; - -static struct sh_timer_config mtu2_2_platform_data = { - .channel_offset = 0x80, - .timer_bit = 2, - .clockevent_rating = 200, -}; - -static struct resource mtu2_2_resources[] = { - [0] = { - .start = 0xff801000, - .end = 0xff80100a, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 240, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_2_device = { - .name = "sh_mtu2", - .id = 2, - .dev = { - .platform_data = &mtu2_2_platform_data, - }, - .resource = mtu2_2_resources, - .num_resources = ARRAY_SIZE(mtu2_2_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct plat_sci_port scif0_platform_data = { @@ -221,9 +151,7 @@ static struct platform_device scif0_device = { static struct platform_device *mxg_devices[] __initdata = { &scif0_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; static int __init mxg_devices_setup(void) @@ -240,9 +168,7 @@ void __init plat_irq_setup(void) static struct platform_device *mxg_early_devices[] __initdata = { &scif0_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7201.c b/arch/sh/kernel/cpu/sh2a/setup-sh7201.c index 2c68744..abc0ce9 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7201.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7201.c @@ -365,88 +365,18 @@ static struct platform_device rtc_device = { .resource = rtc_resources, }; -static struct sh_timer_config mtu2_0_platform_data = { - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xfffe4000, 0x400), + DEFINE_RES_IRQ_NAMED(108, "tgi0a"), + DEFINE_RES_IRQ_NAMED(116, "tgi1a"), + DEFINE_RES_IRQ_NAMED(124, "tgi1b"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .start = 0xfffe4300, - .end = 0xfffe4326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 108, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .start = 0xfffe4380, - .end = 0xfffe4390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 116, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), -}; - -static struct sh_timer_config mtu2_2_platform_data = { - .channel_offset = 0x80, - .timer_bit = 2, - .clockevent_rating = 200, -}; - -static struct resource mtu2_2_resources[] = { - [0] = { - .start = 0xfffe4000, - .end = 0xfffe400a, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 124, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_2_device = { - .name = "sh_mtu2", - .id = 2, - .dev = { - .platform_data = &mtu2_2_platform_data, - }, - .resource = mtu2_2_resources, - .num_resources = ARRAY_SIZE(mtu2_2_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct platform_device *sh7201_devices[] __initdata = { @@ -459,9 +389,7 @@ static struct platform_device *sh7201_devices[] __initdata = { &scif6_device, &scif7_device, &rtc_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; static int __init sh7201_devices_setup(void) @@ -485,9 +413,7 @@ static struct platform_device *sh7201_early_devices[] __initdata = { &scif5_device, &scif6_device, &scif7_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; #define STBCR3 0xfffe0408 diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c index 374f8c0..3b4894c 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c @@ -285,60 +285,17 @@ static struct platform_device cmt_device = { .num_resources = ARRAY_SIZE(cmt_resources), }; -static struct sh_timer_config mtu2_0_platform_data = { - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xfffe4000, 0x400), + DEFINE_RES_IRQ_NAMED(146, "tgi0a"), + DEFINE_RES_IRQ_NAMED(153, "tgi1a"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .start = 0xfffe4300, - .end = 0xfffe4326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 146, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .start = 0xfffe4380, - .end = 0xfffe4390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 153, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct resource rtc_resources[] = { @@ -367,8 +324,7 @@ static struct platform_device *sh7203_devices[] __initdata = { &scif2_device, &scif3_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, &rtc_device, }; @@ -390,8 +346,7 @@ static struct platform_device *sh7203_early_devices[] __initdata = { &scif2_device, &scif3_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, }; #define STBCR3 0xfffe0408 diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c index d00e6fd..49bc5a3 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c @@ -237,88 +237,18 @@ static struct platform_device cmt_device = { .num_resources = ARRAY_SIZE(cmt_resources), }; -static struct sh_timer_config mtu2_0_platform_data = { - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xfffe4000, 0x400), + DEFINE_RES_IRQ_NAMED(156, "tgi0a"), + DEFINE_RES_IRQ_NAMED(164, "tgi1a"), + DEFINE_RES_IRQ_NAMED(180, "tgi2a"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .start = 0xfffe4300, - .end = 0xfffe4326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 156, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .start = 0xfffe4380, - .end = 0xfffe4390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 164, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), -}; - -static struct sh_timer_config mtu2_2_platform_data = { - .channel_offset = 0x80, - .timer_bit = 2, - .clockevent_rating = 200, -}; - -static struct resource mtu2_2_resources[] = { - [0] = { - .start = 0xfffe4000, - .end = 0xfffe400a, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 180, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_2_device = { - .name = "sh_mtu2", - .id = 2, - .dev = { - .platform_data = &mtu2_2_platform_data, - }, - .resource = mtu2_2_resources, - .num_resources = ARRAY_SIZE(mtu2_2_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2s", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct platform_device *sh7206_devices[] __initdata = { @@ -327,9 +257,7 @@ static struct platform_device *sh7206_devices[] __initdata = { &scif2_device, &scif3_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; static int __init sh7206_devices_setup(void) @@ -350,9 +278,7 @@ static struct platform_device *sh7206_early_devices[] __initdata = { &scif2_device, &scif3_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, - &mtu2_2_device, + &mtu2_device, }; #define STBCR3 0xfffe0408 diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7264.c b/arch/sh/kernel/cpu/sh2a/setup-sh7264.c index e95250e..6081464 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7264.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7264.c @@ -453,64 +453,17 @@ static struct platform_device cmt_device = { .num_resources = ARRAY_SIZE(cmt_resources), }; -static struct sh_timer_config mtu2_0_platform_data = { - .name = "MTU2_0", - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xfffe4000, 0x400), + DEFINE_RES_IRQ_NAMED(179, "tgi0a"), + DEFINE_RES_IRQ_NAMED(186, "tgi1a"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .name = "MTU2_0", - .start = 0xfffe4300, - .end = 0xfffe4326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 179, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .name = "MTU2_1", - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .name = "MTU2_1", - .start = 0xfffe4380, - .end = 0xfffe4390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 186, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct resource rtc_resources[] = { @@ -580,8 +533,7 @@ static struct platform_device *sh7264_devices[] __initdata = { &scif6_device, &scif7_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, &rtc_device, &r8a66597_usb_host_device, }; @@ -608,8 +560,7 @@ static struct platform_device *sh7264_early_devices[] __initdata = { &scif6_device, &scif7_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, }; void __init plat_early_device_setup(void) diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7269.c b/arch/sh/kernel/cpu/sh2a/setup-sh7269.c index 0191e1a..16ce5aa 100644 --- a/arch/sh/kernel/cpu/sh2a/setup-sh7269.c +++ b/arch/sh/kernel/cpu/sh2a/setup-sh7269.c @@ -475,60 +475,17 @@ static struct platform_device cmt_device = { .num_resources = ARRAY_SIZE(cmt_resources), }; -static struct sh_timer_config mtu2_0_platform_data = { - .channel_offset = -0x80, - .timer_bit = 0, - .clockevent_rating = 200, +static struct resource mtu2_resources[] = { + DEFINE_RES_MEM(0xfffe4000, 0x400), + DEFINE_RES_IRQ_NAMED(192, "tgi0a"), + DEFINE_RES_IRQ_NAMED(203, "tgi1a"), }; -static struct resource mtu2_0_resources[] = { - [0] = { - .start = 0xfffe4300, - .end = 0xfffe4326, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 192, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_0_device = { - .name = "sh_mtu2", - .id = 0, - .dev = { - .platform_data = &mtu2_0_platform_data, - }, - .resource = mtu2_0_resources, - .num_resources = ARRAY_SIZE(mtu2_0_resources), -}; - -static struct sh_timer_config mtu2_1_platform_data = { - .channel_offset = -0x100, - .timer_bit = 1, - .clockevent_rating = 200, -}; - -static struct resource mtu2_1_resources[] = { - [0] = { - .start = 0xfffe4380, - .end = 0xfffe4390, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 203, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device mtu2_1_device = { - .name = "sh_mtu2", - .id = 1, - .dev = { - .platform_data = &mtu2_1_platform_data, - }, - .resource = mtu2_1_resources, - .num_resources = ARRAY_SIZE(mtu2_1_resources), +static struct platform_device mtu2_device = { + .name = "sh-mtu2", + .id = -1, + .resource = mtu2_resources, + .num_resources = ARRAY_SIZE(mtu2_resources), }; static struct resource rtc_resources[] = { @@ -592,8 +549,7 @@ static struct platform_device *sh7269_devices[] __initdata = { &scif6_device, &scif7_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, &rtc_device, &r8a66597_usb_host_device, }; @@ -620,8 +576,7 @@ static struct platform_device *sh7269_early_devices[] __initdata = { &scif6_device, &scif7_device, &cmt_device, - &mtu2_0_device, - &mtu2_1_device, + &mtu2_device, }; void __init plat_early_device_setup(void) -- cgit v0.10.2 From c17fcfbcc0f6b4f3cae761149e1a6108dd6750e7 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 Apr 2014 13:15:22 +0200 Subject: ARM: shmobile: r7s72100: Switch to new style MTU2 device The MTU2 (Multi-Function Timer Pulse Unit 2) driver implements a new style of platform data that handles the timer as a single device with multiple channel. Switch from the old-style platform data to the new-style platform data. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c index bee0073..644f1c2 100644 --- a/arch/arm/mach-shmobile/clock-r7s72100.c +++ b/arch/arm/mach-shmobile/clock-r7s72100.c @@ -204,7 +204,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("fcfee800.i2c", &mstp_clks[MSTP95]), CLKDEV_DEV_ID("fcfeec00.i2c", &mstp_clks[MSTP94]), CLKDEV_DEV_ID("r7s72100-ether", &mstp_clks[MSTP74]), - CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP33]), /* ICK */ CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[MSTP47]), @@ -215,6 +214,7 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP42]), CLKDEV_ICK_ID("sci_fck", "sh-sci.6", &mstp_clks[MSTP41]), CLKDEV_ICK_ID("sci_fck", "sh-sci.7", &mstp_clks[MSTP40]), + CLKDEV_ICK_ID("fck", "sh-mtu2", &mstp_clks[MSTP33]), }; void __init r7s72100_clock_init(void) diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c index 9c0b3a9..545db15 100644 --- a/arch/arm/mach-shmobile/setup-r7s72100.c +++ b/arch/arm/mach-shmobile/setup-r7s72100.c @@ -62,24 +62,16 @@ R7S72100_SCIF(7, 0xe800a800, gic_iid(249)); sizeof(scif##index##_platform_data)) -static struct sh_timer_config mtu2_0_platform_data __initdata = { - .name = "MTU2_0", - .timer_bit = 0, - .channel_offset = -0x80, - .clockevent_rating = 200, +static struct resource mtu2_resources[] __initdata = { + DEFINE_RES_MEM(0xfcff0000, 0x400), + DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"), }; -static struct resource mtu2_0_resources[] __initdata = { - DEFINE_RES_MEM(0xfcff0300, 0x27), - DEFINE_RES_IRQ(gic_iid(139)), /* MTU2 TGI0A */ -}; - -#define r7s72100_register_mtu2(idx) \ - platform_device_register_resndata(&platform_bus, "sh_mtu2", \ - idx, mtu2_##idx##_resources, \ - ARRAY_SIZE(mtu2_##idx##_resources), \ - &mtu2_##idx##_platform_data, \ - sizeof(struct sh_timer_config)) +#define r7s72100_register_mtu2() \ + platform_device_register_resndata(&platform_bus, "sh-mtu2", \ + -1, mtu2_resources, \ + ARRAY_SIZE(mtu2_resources), \ + NULL, 0) void __init r7s72100_add_dt_devices(void) { @@ -91,7 +83,7 @@ void __init r7s72100_add_dt_devices(void) r7s72100_register_scif(5); r7s72100_register_scif(6); r7s72100_register_scif(7); - r7s72100_register_mtu2(0); + r7s72100_register_mtu2(); } void __init r7s72100_init_early(void) -- cgit v0.10.2 From fd105ecf17fe459d979f336a7389d87172a1cf6d Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 8 May 2014 08:37:53 +0900 Subject: ARM: shmobile: Minor cleanup of the Armadillo legacy board code Cleanup the legacy Armadillo board code slightly by removing the pointless eva_add_early_devices() function Signed-off-by: Magnus Damm Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index 2858f38..4eb9a13 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c @@ -1299,11 +1299,6 @@ static void __init eva_earlytimer_init(void) eva_clock_init(); } -static void __init eva_add_early_devices(void) -{ - r8a7740_add_early_devices(); -} - #define RESCNT2 IOMEM(0xe6188020) static void eva_restart(enum reboot_mode mode, const char *cmd) { @@ -1318,7 +1313,7 @@ static const char *eva_boards_compat_dt[] __initdata = { DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva") .map_io = r8a7740_map_io, - .init_early = eva_add_early_devices, + .init_early = r8a7740_add_early_devices, .init_irq = r8a7740_init_irq_of, .init_machine = eva_init, .init_late = shmobile_init_late, -- cgit v0.10.2 From 14c0a5b4b909b6276f5cdcdbaaa2cfe6cc2b1309 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 7 Apr 2014 14:28:46 +0200 Subject: ARM: OMAP2+: Add support for RNG on DT booted N900 Add support for OMAP3 ROM Random Number Generator via pdata-quirks. Signed-off-by: Sebastian Reichel Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index c3b7335..fa298bd 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -226,6 +226,14 @@ static void __init am3517_evm_legacy_init(void) am35xx_emac_reset(); } +static struct platform_device omap3_rom_rng_device = { + .name = "omap3-rom-rng", + .id = -1, + .dev = { + .platform_data = rx51_secure_rng_call, + }, +}; + static void __init nokia_n900_legacy_init(void) { hsmmc2_internal_input_clk(); @@ -239,6 +247,10 @@ static void __init nokia_n900_legacy_init(void) pr_warning("RX-51: Not enabling ARM errata 430973 workaround\n"); pr_warning("Thumb binaries may crash randomly without this workaround\n"); } + + pr_info("RX-51: Registring OMAP3 HWRNG device\n"); + platform_device_register(&omap3_rom_rng_device); + } } #endif /* CONFIG_ARCH_OMAP3 */ -- cgit v0.10.2 From 4e9c4877aacc134b568e480eb8998de58b43d63e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 30 Apr 2014 02:31:45 +0200 Subject: ARM: shmobile: lager: Enable SCIF0 and SCIF1 serial ports in DT SCIF0 and SCIF1 are used as debug serial ports. Enable them and configure pinmuxing appropriately. We can now remove the clkdev registration hack for SCIF devices from the Lager reference board file. Signed-off-by: Laurent Pinchart [horms+renesas@verge.net.au: updated changelog to remove references to device renaming] [horms+renesas@verge.net.au: resolved conflicts] Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index 6e99eb2..25e0485 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -17,6 +17,11 @@ model = "Lager"; compatible = "renesas,lager", "renesas,r8a7790"; + aliases { + serial6 = &scif0; + serial7 = &scif1; + }; + chosen { bootargs = "console=ttySC6,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp"; }; @@ -112,7 +117,7 @@ }; &pfc { - pinctrl-0 = <&du_pins &scif0_pins &scif1_pins>; + pinctrl-0 = <&du_pins>; pinctrl-names = "default"; du_pins: du { @@ -221,6 +226,20 @@ }; }; +&scif0 { + pinctrl-0 = <&scif0_pins>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&scif1 { + pinctrl-0 = <&scif1_pins>; + pinctrl-names = "default"; + + status = "okay"; +}; + &sdhi0 { pinctrl-0 = <&sdhi0_pins>; pinctrl-names = "default"; diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 1bca2748..749832e 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -91,16 +91,6 @@ static void __init lager_add_du_device(void) */ static const struct clk_name clk_names[] __initconst = { { "cmt0", "fck", "sh-cmt-48-gen2.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "hscif0", NULL, "sh-sci.8" }, - { "hscif1", NULL, "sh-sci.9" }, { "du0", "du.0", "rcar-du-r8a7790" }, { "du1", "du.1", "rcar-du-r8a7790" }, { "du2", "du.2", "rcar-du-r8a7790" }, diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c index 87327f3..5fc9b17 100644 --- a/arch/arm/mach-shmobile/setup-r8a7790.c +++ b/arch/arm/mach-shmobile/setup-r8a7790.c @@ -287,6 +287,11 @@ static struct resource cmt0_resources[] = { void __init r8a7790_add_dt_devices(void) { + r8a7790_register_cmt(0); +} + +void __init r8a7790_add_standard_devices(void) +{ r8a7790_register_scif(0); r8a7790_register_scif(1); r8a7790_register_scif(2); @@ -297,11 +302,6 @@ void __init r8a7790_add_dt_devices(void) r8a7790_register_scif(7); r8a7790_register_scif(8); r8a7790_register_scif(9); - r8a7790_register_cmt(0); -} - -void __init r8a7790_add_standard_devices(void) -{ r8a7790_add_dt_devices(); r8a7790_register_irqc(0); r8a7790_register_thermal(); -- cgit v0.10.2 From 5ba55fa81aee9493928c245f142a0bfe9f32d02f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 30 Apr 2014 02:31:46 +0200 Subject: ARM: shmobile: koelsch: Enable SCIF0 and SCIF1 serial ports in DT SCIF0 and SCIF1 are used as debug serial ports. Enable them and configure pinmuxing appropriately. We can now remove the clkdev registration hack for SCIF devices from the Koelsch reference board file. Signed-off-by: Laurent Pinchart [horms+renesas@verge.net.au: added aliases to avoid device renumbering] [horms+renesas@verge.net.au: resolved conflicts] Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index bdd73e6..10c6b40 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -18,6 +18,11 @@ model = "Koelsch"; compatible = "renesas,koelsch", "renesas,r8a7791"; + aliases { + serial6 = &scif0; + serial7 = &scif1; + }; + chosen { bootargs = "console=ttySC6,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp"; }; @@ -196,7 +201,7 @@ }; &pfc { - pinctrl-0 = <&du_pins &scif0_pins &scif1_pins>; + pinctrl-0 = <&du_pins>; pinctrl-names = "default"; i2c2_pins: i2c { @@ -269,6 +274,20 @@ status = "okay"; }; +&scif0 { + pinctrl-0 = <&scif0_pins>; + pinctrl-names = "default"; + + status = "okay"; +}; + +&scif1 { + pinctrl-0 = <&scif1_pins>; + pinctrl-names = "default"; + + status = "okay"; +}; + &sdhi0 { pinctrl-0 = <&sdhi0_pins>; pinctrl-names = "default"; diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index bd90932..0b0ce5a 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -87,21 +87,6 @@ static void __init koelsch_add_du_device(void) */ static const struct clk_name clk_names[] __initconst = { { "cmt0", "fck", "sh-cmt-48-gen2.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "scif2", NULL, "sh-sci.8" }, - { "scif3", NULL, "sh-sci.9" }, - { "scif4", NULL, "sh-sci.10" }, - { "scif5", NULL, "sh-sci.11" }, - { "scifa3", NULL, "sh-sci.12" }, - { "scifa4", NULL, "sh-sci.13" }, - { "scifa5", NULL, "sh-sci.14" }, { "du0", "du.0", "rcar-du-r8a7791" }, { "du1", "du.1", "rcar-du-r8a7791" }, { "lvds0", "lvds.0", "rcar-du-r8a7791" }, diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c index 561653d..b3f42b5 100644 --- a/arch/arm/mach-shmobile/setup-r8a7791.c +++ b/arch/arm/mach-shmobile/setup-r8a7791.c @@ -182,6 +182,11 @@ static const struct resource thermal_resources[] __initconst = { void __init r8a7791_add_dt_devices(void) { + r8a7791_register_cmt(0); +} + +void __init r8a7791_add_standard_devices(void) +{ r8a7791_register_scif(0); r8a7791_register_scif(1); r8a7791_register_scif(2); @@ -197,11 +202,6 @@ void __init r8a7791_add_dt_devices(void) r8a7791_register_scif(12); r8a7791_register_scif(13); r8a7791_register_scif(14); - r8a7791_register_cmt(0); -} - -void __init r8a7791_add_standard_devices(void) -{ r8a7791_add_dt_devices(); r8a7791_register_irqc(0); r8a7791_register_thermal(); -- cgit v0.10.2 From b557deadc5cca47aff93781b21fef468233c2ea8 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:05 +0200 Subject: ARM: shmobile: r7s72100: document MSTP clock support Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Acked-by: Mike Turquette Signed-off-by: Simon Horman diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt index 5992dce..b5fc726 100644 --- a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt +++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt @@ -10,6 +10,7 @@ index in the group, from 0 to 31. Required Properties: - compatible: Must be one of the following + - "renesas,r7s72100-mstp-clocks" for R7S72100 (RZ) MSTP gate clocks - "renesas,r8a7790-mstp-clocks" for R8A7790 (R-Car H2) MSTP gate clocks - "renesas,r8a7791-mstp-clocks" for R8A7791 (R-Car M2) MSTP gate clocks - "renesas,cpg-mstp-clock" for generic MSTP gate clocks -- cgit v0.10.2 From b6face404f38f783c4428d953efa4eeb68d7cc24 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:06 +0200 Subject: ARM: shmobile: r7s72100: add essential clock nodes to dtsi Only essential clocks are added for now. Other clocks will be added when needed. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi index ee70071..5a6e248 100644 --- a/arch/arm/boot/dts/r7s72100.dtsi +++ b/arch/arm/boot/dts/r7s72100.dtsi @@ -1,13 +1,15 @@ /* * Device Tree Source for the r7s72100 SoC * - * Copyright (C) 2013 Renesas Solutions Corp. + * Copyright (C) 2013-14 Renesas Solutions Corp. + * Copyright (C) 2014 Wolfram Sang, Sang Engineering * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any * kind, whether express or implied. */ +#include #include / { @@ -28,6 +30,88 @@ spi4 = &spi4; }; + clocks { + ranges; + #address-cells = <1>; + #size-cells = <1>; + + /* External clocks */ + extal_clk: extal_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; + /* If clk present, value must be set by board */ + clock-frequency = <0>; + clock-output-names = "extal"; + }; + + usb_x1_clk: usb_x1_clk { + #clock-cells = <0>; + compatible = "fixed-clock"; + /* If clk present, value must be set by board */ + clock-frequency = <0>; + clock-output-names = "usb_x1"; + }; + + /* Special CPG clocks */ + cpg_clocks: cpg_clocks@fcfe0000 { + #clock-cells = <1>; + compatible = "renesas,r7s72100-cpg-clocks", + "renesas,rz-cpg-clocks"; + reg = <0xfcfe0000 0x18>; + clocks = <&extal_clk>, <&usb_x1_clk>; + clock-output-names = "pll", "i", "g"; + }; + + /* Fixed factor clocks */ + b_clk: b_clk { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&cpg_clocks R7S72100_CLK_PLL>; + clock-mult = <1>; + clock-div = <3>; + clock-output-names = "b"; + }; + p1_clk: p1_clk { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&cpg_clocks R7S72100_CLK_PLL>; + clock-mult = <1>; + clock-div = <6>; + clock-output-names = "p1"; + }; + p0_clk: p0_clk { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&cpg_clocks R7S72100_CLK_PLL>; + clock-mult = <1>; + clock-div = <12>; + clock-output-names = "p0"; + }; + + /* MSTP clocks */ + mstp3_clks: mstp3_clks@fcfe0420 { + #clock-cells = <1>; + compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks"; + reg = <0xfcfe0420 4>; + clocks = <&p0_clk>; + clock-indices = ; + clock-output-names = "mtu2"; + }; + + mstp4_clks: mstp4_clks@fcfe0424 { + #clock-cells = <1>; + compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks"; + reg = <0xfcfe0424 4>; + clocks = <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>, + <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>; + clock-indices = < + R7S72100_CLK_SCIF0 R7S72100_CLK_SCIF1 R7S72100_CLK_SCIF2 R7S72100_CLK_SCIF3 + R7S72100_CLK_SCIF4 R7S72100_CLK_SCIF5 R7S72100_CLK_SCIF6 R7S72100_CLK_SCIF7 + >; + clock-output-names = "scif0", "scif1", "scif2", "scif3", "scif4", "scif5", "scif6", "scif7"; + }; + }; + cpus { #address-cells = <1>; #size-cells = <0>; diff --git a/include/dt-bindings/clock/r7s72100-clock.h b/include/dt-bindings/clock/r7s72100-clock.h new file mode 100644 index 0000000..c756f1c --- /dev/null +++ b/include/dt-bindings/clock/r7s72100-clock.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 Renesas Solutions Corp. + * Copyright (C) 2014 Wolfram Sang, Sang Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#ifndef __DT_BINDINGS_CLOCK_R7S72100_H__ +#define __DT_BINDINGS_CLOCK_R7S72100_H__ + +#define R7S72100_CLK_PLL 0 + +/* MSTP3 */ +#define R7S72100_CLK_MTU2 3 + +/* MSTP4 */ +#define R7S72100_CLK_SCIF0 7 +#define R7S72100_CLK_SCIF1 6 +#define R7S72100_CLK_SCIF2 5 +#define R7S72100_CLK_SCIF3 4 +#define R7S72100_CLK_SCIF4 3 +#define R7S72100_CLK_SCIF5 2 +#define R7S72100_CLK_SCIF6 1 +#define R7S72100_CLK_SCIF7 0 + +#endif /* __DT_BINDINGS_CLOCK_R7S72100_H__ */ -- cgit v0.10.2 From 5f76a5699f52052468e006e6c58010c5183b8386 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:07 +0200 Subject: ARM: shmobile: r7s72100: genmai: populate nodes for external clocks Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100-genmai-reference.dts b/arch/arm/boot/dts/r7s72100-genmai-reference.dts index e664611..941e72c 100644 --- a/arch/arm/boot/dts/r7s72100-genmai-reference.dts +++ b/arch/arm/boot/dts/r7s72100-genmai-reference.dts @@ -30,6 +30,14 @@ }; }; +&extal_clk { + clock-frequency = <13330000>; +}; + +&usb_x1_clk { + clock-frequency = <48000000>; +}; + &i2c2 { status = "okay"; clock-frequency = <400000>; -- cgit v0.10.2 From 4c84c1b3accabdfb7aa8e98a4644c94df0703bb0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:08 +0200 Subject: ARM: shmobile: r7s72100: add scif nodes to dtsi Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi index 5a6e248..a4a6738 100644 --- a/arch/arm/boot/dts/r7s72100.dtsi +++ b/arch/arm/boot/dts/r7s72100.dtsi @@ -200,6 +200,102 @@ status = "disabled"; }; + scif0: serial@e8007000 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8007000 64>; + interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>, + <0 191 IRQ_TYPE_LEVEL_HIGH>, + <0 192 IRQ_TYPE_LEVEL_HIGH>, + <0 189 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF0>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif1: serial@e8007800 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8007800 64>; + interrupts = <0 194 IRQ_TYPE_LEVEL_HIGH>, + <0 195 IRQ_TYPE_LEVEL_HIGH>, + <0 196 IRQ_TYPE_LEVEL_HIGH>, + <0 193 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF1>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif2: serial@e8008000 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8008000 64>; + interrupts = <0 198 IRQ_TYPE_LEVEL_HIGH>, + <0 199 IRQ_TYPE_LEVEL_HIGH>, + <0 200 IRQ_TYPE_LEVEL_HIGH>, + <0 197 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF2>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif3: serial@e8008800 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8008800 64>; + interrupts = <0 202 IRQ_TYPE_LEVEL_HIGH>, + <0 203 IRQ_TYPE_LEVEL_HIGH>, + <0 204 IRQ_TYPE_LEVEL_HIGH>, + <0 201 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF3>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif4: serial@e8009000 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8009000 64>; + interrupts = <0 206 IRQ_TYPE_LEVEL_HIGH>, + <0 207 IRQ_TYPE_LEVEL_HIGH>, + <0 208 IRQ_TYPE_LEVEL_HIGH>, + <0 205 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF4>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif5: serial@e8009800 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe8009800 64>; + interrupts = <0 210 IRQ_TYPE_LEVEL_HIGH>, + <0 211 IRQ_TYPE_LEVEL_HIGH>, + <0 212 IRQ_TYPE_LEVEL_HIGH>, + <0 209 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF5>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif6: serial@e800a000 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe800a000 64>; + interrupts = <0 214 IRQ_TYPE_LEVEL_HIGH>, + <0 215 IRQ_TYPE_LEVEL_HIGH>, + <0 216 IRQ_TYPE_LEVEL_HIGH>, + <0 213 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF6>; + clock-names = "sci_ick"; + status = "disabled"; + }; + + scif7: serial@e800a800 { + compatible = "renesas,scif-r7s72100", "renesas,scif"; + reg = <0xe800a800 64>; + interrupts = <0 218 IRQ_TYPE_LEVEL_HIGH>, + <0 219 IRQ_TYPE_LEVEL_HIGH>, + <0 220 IRQ_TYPE_LEVEL_HIGH>, + <0 217 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp4_clks R7S72100_CLK_SCIF7>; + clock-names = "sci_ick"; + status = "disabled"; + }; + spi0: spi@e800c800 { compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz"; reg = <0xe800c800 0x24>; -- cgit v0.10.2 From 5be13fefdb83c15ed69eb032dfe011162d1a5269 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:09 +0200 Subject: ARM: shmobile: r7s72100: genmai: add uart alias and activate scif2 as console We keep the UART naming backwards compatible with the legacy version. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100-genmai-reference.dts b/arch/arm/boot/dts/r7s72100-genmai-reference.dts index 941e72c..ca88458 100644 --- a/arch/arm/boot/dts/r7s72100-genmai-reference.dts +++ b/arch/arm/boot/dts/r7s72100-genmai-reference.dts @@ -1,7 +1,8 @@ /* * Device Tree Source for the Genmai board * - * Copyright (C) 2013 Renesas Solutions Corp. + * Copyright (C) 2013-14 Renesas Solutions Corp. + * Copyright (C) 2014 Wolfram Sang, Sang Engineering * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any @@ -15,6 +16,10 @@ model = "Genmai"; compatible = "renesas,genmai-reference", "renesas,r7s72100"; + aliases { + serial2 = &scif2; + }; + chosen { bootargs = "console=ttySC2,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp"; }; @@ -48,3 +53,7 @@ pagesize = <64>; }; }; + +&scif2 { + status = "okay"; +}; -- cgit v0.10.2 From d45b21c9021d7de7941b00f0902a9401fb32a3d9 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:10 +0200 Subject: ARM: shmobile: r7s72100: genmai: platform scif devices only for legacy support We have now DT support for SCIF, so use the platform_device initialization only for the legacy support. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-genmai.c b/arch/arm/mach-shmobile/board-genmai.c index 6c328d6..c94201e 100644 --- a/arch/arm/mach-shmobile/board-genmai.c +++ b/arch/arm/mach-shmobile/board-genmai.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -89,6 +90,40 @@ static const struct spi_board_info spi_info[] __initconst = { }, }; +/* SCIF */ +#define R7S72100_SCIF(index, baseaddr, irq) \ +static const struct plat_sci_port scif##index##_platform_data = { \ + .type = PORT_SCIF, \ + .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \ + .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ + .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \ + SCSCR_REIE, \ +}; \ + \ +static struct resource scif##index##_resources[] = { \ + DEFINE_RES_MEM(baseaddr, 0x100), \ + DEFINE_RES_IRQ(irq + 1), \ + DEFINE_RES_IRQ(irq + 2), \ + DEFINE_RES_IRQ(irq + 3), \ + DEFINE_RES_IRQ(irq), \ +} \ + +R7S72100_SCIF(0, 0xe8007000, gic_iid(221)); +R7S72100_SCIF(1, 0xe8007800, gic_iid(225)); +R7S72100_SCIF(2, 0xe8008000, gic_iid(229)); +R7S72100_SCIF(3, 0xe8008800, gic_iid(233)); +R7S72100_SCIF(4, 0xe8009000, gic_iid(237)); +R7S72100_SCIF(5, 0xe8009800, gic_iid(241)); +R7S72100_SCIF(6, 0xe800a000, gic_iid(245)); +R7S72100_SCIF(7, 0xe800a800, gic_iid(249)); + +#define r7s72100_register_scif(index) \ + platform_device_register_resndata(&platform_bus, "sh-sci", index, \ + scif##index##_resources, \ + ARRAY_SIZE(scif##index##_resources), \ + &scif##index##_platform_data, \ + sizeof(scif##index##_platform_data)) + static void __init genmai_add_standard_devices(void) { r7s72100_clock_init(); @@ -102,6 +137,15 @@ static void __init genmai_add_standard_devices(void) r7s72100_register_rspi(3); r7s72100_register_rspi(4); spi_register_board_info(spi_info, ARRAY_SIZE(spi_info)); + + r7s72100_register_scif(0); + r7s72100_register_scif(1); + r7s72100_register_scif(2); + r7s72100_register_scif(3); + r7s72100_register_scif(4); + r7s72100_register_scif(5); + r7s72100_register_scif(6); + r7s72100_register_scif(7); } static const char * const genmai_boards_compat_dt[] __initconst = { diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c index 545db15..412e179 100644 --- a/arch/arm/mach-shmobile/setup-r7s72100.c +++ b/arch/arm/mach-shmobile/setup-r7s72100.c @@ -21,47 +21,12 @@ #include #include #include -#include #include #include #include #include #include -#define R7S72100_SCIF(index, baseaddr, irq) \ -static const struct plat_sci_port scif##index##_platform_data = { \ - .type = PORT_SCIF, \ - .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \ - .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ - .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \ - SCSCR_REIE, \ -}; \ - \ -static struct resource scif##index##_resources[] = { \ - DEFINE_RES_MEM(baseaddr, 0x100), \ - DEFINE_RES_IRQ(irq + 1), \ - DEFINE_RES_IRQ(irq + 2), \ - DEFINE_RES_IRQ(irq + 3), \ - DEFINE_RES_IRQ(irq), \ -} \ - -R7S72100_SCIF(0, 0xe8007000, gic_iid(221)); -R7S72100_SCIF(1, 0xe8007800, gic_iid(225)); -R7S72100_SCIF(2, 0xe8008000, gic_iid(229)); -R7S72100_SCIF(3, 0xe8008800, gic_iid(233)); -R7S72100_SCIF(4, 0xe8009000, gic_iid(237)); -R7S72100_SCIF(5, 0xe8009800, gic_iid(241)); -R7S72100_SCIF(6, 0xe800a000, gic_iid(245)); -R7S72100_SCIF(7, 0xe800a800, gic_iid(249)); - -#define r7s72100_register_scif(index) \ - platform_device_register_resndata(&platform_bus, "sh-sci", index, \ - scif##index##_resources, \ - ARRAY_SIZE(scif##index##_resources), \ - &scif##index##_platform_data, \ - sizeof(scif##index##_platform_data)) - - static struct resource mtu2_resources[] __initdata = { DEFINE_RES_MEM(0xfcff0000, 0x400), DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"), @@ -75,14 +40,6 @@ static struct resource mtu2_resources[] __initdata = { void __init r7s72100_add_dt_devices(void) { - r7s72100_register_scif(0); - r7s72100_register_scif(1); - r7s72100_register_scif(2); - r7s72100_register_scif(3); - r7s72100_register_scif(4); - r7s72100_register_scif(5); - r7s72100_register_scif(6); - r7s72100_register_scif(7); r7s72100_register_mtu2(); } -- cgit v0.10.2 From d165566b8dc425e52a4f2c19c27c63d9807128b2 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:11 +0200 Subject: ARM: shmobile: r7s72100: add i2c clocks to dtsi Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi index a4a6738..afce2e3 100644 --- a/arch/arm/boot/dts/r7s72100.dtsi +++ b/arch/arm/boot/dts/r7s72100.dtsi @@ -110,6 +110,17 @@ >; clock-output-names = "scif0", "scif1", "scif2", "scif3", "scif4", "scif5", "scif6", "scif7"; }; + + mstp9_clks: mstp9_clks@fcfe0438 { + #clock-cells = <1>; + compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks"; + reg = <0xfcfe0438 4>; + clocks = <&p0_clk>, <&p0_clk>, <&p0_clk>, <&p0_clk>; + clock-indices = < + R7S72100_CLK_I2C0 R7S72100_CLK_I2C1 R7S72100_CLK_I2C2 R7S72100_CLK_I2C3 + >; + clock-output-names = "i2c0", "i2c1", "i2c2", "i2c3"; + }; }; cpus { @@ -145,6 +156,7 @@ <0 162 IRQ_TYPE_LEVEL_HIGH>, <0 163 IRQ_TYPE_LEVEL_HIGH>, <0 164 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R7S72100_CLK_I2C0>; clock-frequency = <100000>; status = "disabled"; }; @@ -162,6 +174,7 @@ <0 170 IRQ_TYPE_LEVEL_HIGH>, <0 171 IRQ_TYPE_LEVEL_HIGH>, <0 172 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R7S72100_CLK_I2C1>; clock-frequency = <100000>; status = "disabled"; }; @@ -179,6 +192,7 @@ <0 178 IRQ_TYPE_LEVEL_HIGH>, <0 179 IRQ_TYPE_LEVEL_HIGH>, <0 180 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R7S72100_CLK_I2C2>; clock-frequency = <100000>; status = "disabled"; }; @@ -196,6 +210,7 @@ <0 186 IRQ_TYPE_LEVEL_HIGH>, <0 187 IRQ_TYPE_LEVEL_HIGH>, <0 188 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R7S72100_CLK_I2C3>; clock-frequency = <100000>; status = "disabled"; }; diff --git a/include/dt-bindings/clock/r7s72100-clock.h b/include/dt-bindings/clock/r7s72100-clock.h index c756f1c..ff84e0b 100644 --- a/include/dt-bindings/clock/r7s72100-clock.h +++ b/include/dt-bindings/clock/r7s72100-clock.h @@ -25,4 +25,10 @@ #define R7S72100_CLK_SCIF6 1 #define R7S72100_CLK_SCIF7 0 +/* MSTP9 */ +#define R7S72100_CLK_I2C0 7 +#define R7S72100_CLK_I2C1 6 +#define R7S72100_CLK_I2C2 5 +#define R7S72100_CLK_I2C3 4 + #endif /* __DT_BINDINGS_CLOCK_R7S72100_H__ */ -- cgit v0.10.2 From 316b9353784386aedc4f2643dfdfda30da268b0b Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:12 +0200 Subject: ARM: shmobile: r7s72100: remove I2C DT clocks from legacy clock support Not used anymore since we switched to CCF. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c index 644f1c2..1a797fe 100644 --- a/arch/arm/mach-shmobile/clock-r7s72100.c +++ b/arch/arm/mach-shmobile/clock-r7s72100.c @@ -199,10 +199,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("e800d800.spi", &mstp_clks[MSTP105]), CLKDEV_DEV_ID("e800e000.spi", &mstp_clks[MSTP104]), CLKDEV_DEV_ID("e800e800.spi", &mstp_clks[MSTP103]), - CLKDEV_DEV_ID("fcfee000.i2c", &mstp_clks[MSTP97]), - CLKDEV_DEV_ID("fcfee400.i2c", &mstp_clks[MSTP96]), - CLKDEV_DEV_ID("fcfee800.i2c", &mstp_clks[MSTP95]), - CLKDEV_DEV_ID("fcfeec00.i2c", &mstp_clks[MSTP94]), CLKDEV_DEV_ID("r7s72100-ether", &mstp_clks[MSTP74]), /* ICK */ -- cgit v0.10.2 From 52eed4f5c267bd50d870f9c63d0a83d6f83d8bab Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:13 +0200 Subject: ARM: shmobile: r7s72100: add spi clocks to dtsi Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi index afce2e3..f50fbc8 100644 --- a/arch/arm/boot/dts/r7s72100.dtsi +++ b/arch/arm/boot/dts/r7s72100.dtsi @@ -121,6 +121,19 @@ >; clock-output-names = "i2c0", "i2c1", "i2c2", "i2c3"; }; + + mstp10_clks: mstp10_clks@fcfe043c { + #clock-cells = <1>; + compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks"; + reg = <0xfcfe043c 4>; + clocks = <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>, + <&p1_clk>; + clock-indices = < + R7S72100_CLK_SPI0 R7S72100_CLK_SPI1 R7S72100_CLK_SPI2 R7S72100_CLK_SPI3 + R7S72100_CLK_SPI4 + >; + clock-output-names = "spi0", "spi1", "spi2", "spi3", "spi4"; + }; }; cpus { @@ -318,6 +331,7 @@ <0 239 IRQ_TYPE_LEVEL_HIGH>, <0 240 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "error", "rx", "tx"; + clocks = <&mstp10_clks R7S72100_CLK_SPI0>; num-cs = <1>; #address-cells = <1>; #size-cells = <0>; @@ -331,6 +345,7 @@ <0 242 IRQ_TYPE_LEVEL_HIGH>, <0 243 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "error", "rx", "tx"; + clocks = <&mstp10_clks R7S72100_CLK_SPI1>; num-cs = <1>; #address-cells = <1>; #size-cells = <0>; @@ -344,6 +359,7 @@ <0 245 IRQ_TYPE_LEVEL_HIGH>, <0 246 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "error", "rx", "tx"; + clocks = <&mstp10_clks R7S72100_CLK_SPI2>; num-cs = <1>; #address-cells = <1>; #size-cells = <0>; @@ -357,6 +373,7 @@ <0 248 IRQ_TYPE_LEVEL_HIGH>, <0 249 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "error", "rx", "tx"; + clocks = <&mstp10_clks R7S72100_CLK_SPI3>; num-cs = <1>; #address-cells = <1>; #size-cells = <0>; @@ -370,6 +387,7 @@ <0 251 IRQ_TYPE_LEVEL_HIGH>, <0 252 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "error", "rx", "tx"; + clocks = <&mstp10_clks R7S72100_CLK_SPI4>; num-cs = <1>; #address-cells = <1>; #size-cells = <0>; diff --git a/include/dt-bindings/clock/r7s72100-clock.h b/include/dt-bindings/clock/r7s72100-clock.h index ff84e0b..5128f4d 100644 --- a/include/dt-bindings/clock/r7s72100-clock.h +++ b/include/dt-bindings/clock/r7s72100-clock.h @@ -31,4 +31,11 @@ #define R7S72100_CLK_I2C2 5 #define R7S72100_CLK_I2C3 4 +/* MSTP10 */ +#define R7S72100_CLK_SPI0 7 +#define R7S72100_CLK_SPI1 6 +#define R7S72100_CLK_SPI2 5 +#define R7S72100_CLK_SPI3 4 +#define R7S72100_CLK_SPI4 3 + #endif /* __DT_BINDINGS_CLOCK_R7S72100_H__ */ -- cgit v0.10.2 From 3158e053ff45ed36d531d775cf0040642b91b606 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:14 +0200 Subject: ARM: shmobile: r7s72100: remove SPI DT clocks from legacy clock support Not used anymore since we switched to CCF. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c index 1a797fe..df18748 100644 --- a/arch/arm/mach-shmobile/clock-r7s72100.c +++ b/arch/arm/mach-shmobile/clock-r7s72100.c @@ -194,11 +194,6 @@ static struct clk_lookup lookups[] = { CLKDEV_DEV_ID("rspi-rz.2", &mstp_clks[MSTP105]), CLKDEV_DEV_ID("rspi-rz.3", &mstp_clks[MSTP104]), CLKDEV_DEV_ID("rspi-rz.4", &mstp_clks[MSTP103]), - CLKDEV_DEV_ID("e800c800.spi", &mstp_clks[MSTP107]), - CLKDEV_DEV_ID("e800d000.spi", &mstp_clks[MSTP106]), - CLKDEV_DEV_ID("e800d800.spi", &mstp_clks[MSTP105]), - CLKDEV_DEV_ID("e800e000.spi", &mstp_clks[MSTP104]), - CLKDEV_DEV_ID("e800e800.spi", &mstp_clks[MSTP103]), CLKDEV_DEV_ID("r7s72100-ether", &mstp_clks[MSTP74]), /* ICK */ -- cgit v0.10.2 From 1f9c7a691fefc2158bed4d5403422cc9b99ca335 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 14 May 2014 03:10:16 +0200 Subject: ARM: shmobile: Add forward declaration of struct clk to silence warning arch/arm/mach-shmobile/board-genmai-reference.c:23:0: arch/arm/mach-shmobile/include/mach/clock.h:19:54: warning: 'struct clk' declared inside parameter list [enabled by default] arch/arm/mach-shmobile/include/mach/clock.h:19:54: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] Signed-off-by: Geert Uytterhoeven Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/include/mach/clock.h b/arch/arm/mach-shmobile/include/mach/clock.h index 9a93cf9..31b6417 100644 --- a/arch/arm/mach-shmobile/include/mach/clock.h +++ b/arch/arm/mach-shmobile/include/mach/clock.h @@ -16,6 +16,7 @@ void shmobile_clk_workaround(const struct clk_name *clks, int nr_clks, #else /* CONFIG_COMMON_CLK */ /* legacy clock implementation */ +struct clk; unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk); extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops; -- cgit v0.10.2 From 9fbb1ae01b878e2cce9626fa6fdc9e5dcefeb6b5 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 14 May 2014 03:10:15 +0200 Subject: ARM: shmobile: r7s72100: use workaround for non DT-clocks MTU2 is not yet prepared for DT usage, so use the common workaround via clkdev for now. Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Geert Uytterhoeven Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c index 7630c10..33015e5 100644 --- a/arch/arm/mach-shmobile/board-genmai-reference.c +++ b/arch/arm/mach-shmobile/board-genmai-reference.c @@ -18,18 +18,28 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include +#include #include #include #include #include +#ifdef CONFIG_COMMON_CLK +/* + * This is a really crude hack to provide clkdev support to platform + * devices until they get moved to DT. + */ +static const struct clk_name clk_names[] = { + { "mtu2", "fck", "sh-mtu2" }, +}; +#endif + static void __init genmai_add_standard_devices(void) { #ifdef CONFIG_COMMON_CLK - of_clk_init(NULL); + shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), true); #else r7s72100_clock_init(); #endif -- cgit v0.10.2 From 9956dcc5d136248a415234381311543c8cdf869a Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 19 Mar 2014 17:15:14 -0600 Subject: ARM: tegra: tegra_defconfig updates AT24C EEPROM: This is used for the board ID EEPROM on Jetson TK1, as well as likely a whole slew of other NVIDIA reference boards; we simply haven't added enabled the EEPROM in the DT files until now. MTD_SPI_NOR: This defconfig contains the CONFIG_M25P80 symbol, which is now dependent on the MTD_SPI_NOR symbol. Add CONFIG_MTD_SPI_NOR to satisfy the new dependency. FRAMEBUFFER_CONSOLE_ROTATION: Needed for devices like Tegra Note 7 and NVIDIA SHIELD to get the boot console in the expected orientation. CAN*, RTC_DRV_DS1307: Toradex Colibri Evaluation Board uses the DS1307 RTC and the MCP251x CAN controller. The NVIDIA Tegra 3 based Colibri T30 module can be used on this carrier board. Furthermore the NVIDIA Tegra 3 based Apalis T30 module too contains two MCP251x CAN controllers. INPUT_JOYDEV: NVIDIA SHIELD embeds a USB joystick device. Signed-off-by: Brian Norris Signed-off-by: Alexandre Courbot Signed-off-by: Stefan Agner Signed-off-by: Stephen Warren diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig index 2926281..fb25e29 100644 --- a/arch/arm/configs/tegra_defconfig +++ b/arch/arm/configs/tegra_defconfig @@ -73,6 +73,11 @@ CONFIG_INET6_IPCOMP=y CONFIG_IPV6_MIP6=y CONFIG_IPV6_TUNNEL=y CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_CAN=y +CONFIG_CAN_RAW=y +CONFIG_CAN_BCM=y +CONFIG_CAN_DEV=y +CONFIG_CAN_MCP251X=y CONFIG_BT=y CONFIG_BT_RFCOMM=y CONFIG_BT_BNEP=y @@ -90,6 +95,7 @@ CONFIG_DMA_CMA=y CONFIG_CMA_SIZE_MBYTES=64 CONFIG_MTD=y CONFIG_MTD_M25P80=y +CONFIG_MTD_SPI_NOR=y CONFIG_PROC_DEVICETREE=y CONFIG_BLK_DEV_LOOP=y CONFIG_AD525X_DPOT=y @@ -97,6 +103,7 @@ CONFIG_AD525X_DPOT_I2C=y CONFIG_ICS932S401=y CONFIG_APDS9802ALS=y CONFIG_ISL29003=y +CONFIG_EEPROM_AT24=y CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_BLK_DEV_SR=y @@ -112,6 +119,7 @@ CONFIG_USB_NET_SMSC95XX=y CONFIG_BRCMFMAC=m CONFIG_RT2X00=y CONFIG_RT2800USB=m +CONFIG_INPUT_JOYDEV=y CONFIG_INPUT_EVDEV=y CONFIG_KEYBOARD_GPIO=y CONFIG_KEYBOARD_TEGRA=y @@ -181,6 +189,7 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y # CONFIG_BACKLIGHT_GENERIC is not set CONFIG_BACKLIGHT_PWM=y CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y CONFIG_LOGO=y CONFIG_SOUND=y CONFIG_SND=y @@ -222,6 +231,7 @@ CONFIG_LEDS_TRIGGER_TRANSIENT=y CONFIG_LEDS_TRIGGER_CAMERA=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_AS3722=y +CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_MAX8907=y CONFIG_RTC_DRV_PALMAS=y CONFIG_RTC_DRV_TPS6586X=y -- cgit v0.10.2 From d8c270a874e9586ca8c8f888e47a9e3b8878dca9 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 15 May 2014 20:37:45 +0200 Subject: ARM: OMAP: omap3stalker: remove two Kconfig macros Checks for CONFIG_OMAP2_VENC_OUT_TYPE_SVIDEO and CONFIG_OMAP2_VENC_OUT_TYPE_COMPOSITE were added in v2.6.35. But the related Kconfig symbols have never been added to the tree. Remove these checks. Initialize connector_type to OMAP_DSS_VENC_TYPE_COMPOSITE explicitly. That's what's happening currently: OMAP_DSS_VENC_TYPE_COMPOSITE equals zero and connector_type remains zero since both checks currently fail. Signed-off-by: Paul Bolle Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c index 119efaf..a2e035e 100644 --- a/arch/arm/mach-omap2/board-omap3stalker.c +++ b/arch/arm/mach-omap2/board-omap3stalker.c @@ -121,11 +121,7 @@ static struct platform_device omap3stalker_tfp410_device = { static struct connector_atv_platform_data omap3stalker_tv_pdata = { .name = "tv", .source = "venc.0", -#if defined(CONFIG_OMAP2_VENC_OUT_TYPE_SVIDEO) - .connector_type = OMAP_DSS_VENC_TYPE_SVIDEO, -#elif defined(CONFIG_OMAP2_VENC_OUT_TYPE_COMPOSITE) .connector_type = OMAP_DSS_VENC_TYPE_COMPOSITE, -#endif .invert_polarity = false, }; -- cgit v0.10.2 From 7d684ff8a9d0a12ce2a62a5842e3b01f686bac85 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 15 May 2014 21:16:21 +0200 Subject: ARM: OMAP: remove some dead code A check for CONFIG_CBUS_TAHVO_USB was added in v2.6.17. The related Kconfig symbol has never been part of the tree. Remove that check. Replace the while (...) loop with a simple if (...) statement, while we're at it. Signed-off-by: Paul Bolle Acked-by: Aaro Koskinen Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c index dbee729..34b4c00 100644 --- a/arch/arm/mach-omap1/pm.c +++ b/arch/arm/mach-omap1/pm.c @@ -123,19 +123,8 @@ void omap1_pm_idle(void) #warning Enable 32kHz OS timer in order to allow sleep states in idle use_idlect1 = use_idlect1 & ~(1 << 9); #else - - while (enable_dyn_sleep) { - -#ifdef CONFIG_CBUS_TAHVO_USB - extern int vbus_active; - /* Clock requirements? */ - if (vbus_active) - break; -#endif + if (enable_dyn_sleep) do_sleep = 1; - break; - } - #endif #ifdef CONFIG_OMAP_DM_TIMER -- cgit v0.10.2 From 4906cc73c2e55217d71bd9e4b79708d6b41eaef4 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 15 May 2014 21:41:42 +0200 Subject: ARM: OMAP: SX1: remove check for CONFIG_SX1_OLD_FLASH A check for CONFIG_SX1_OLD_FLASH was added in v2.6.24. But the related Kconfig symbol was never part of the tree. So we can remove some dead code. Signed-off-by: Paul Bolle Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c index 0a8d334..29e5262 100644 --- a/arch/arm/mach-omap1/board-sx1.c +++ b/arch/arm/mach-omap1/board-sx1.c @@ -266,31 +266,6 @@ static struct physmap_flash_data sx1_flash_data = { .nr_parts = ARRAY_SIZE(sx1_partitions), }; -#ifdef CONFIG_SX1_OLD_FLASH -/* MTD Intel StrataFlash - old flashes */ -static struct resource sx1_old_flash_resource[] = { - [0] = { - .start = OMAP_CS0_PHYS, /* Physical */ - .end = OMAP_CS0_PHYS + SZ_16M - 1,, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = OMAP_CS1_PHYS, - .end = OMAP_CS1_PHYS + SZ_8M - 1, - .flags = IORESOURCE_MEM, - }, -}; - -static struct platform_device sx1_flash_device = { - .name = "physmap-flash", - .id = 0, - .dev = { - .platform_data = &sx1_flash_data, - }, - .num_resources = 2, - .resource = &sx1_old_flash_resource, -}; -#else /* MTD Intel 4000 flash - new flashes */ static struct resource sx1_new_flash_resource = { .start = OMAP_CS0_PHYS, @@ -307,7 +282,6 @@ static struct platform_device sx1_flash_device = { .num_resources = 1, .resource = &sx1_new_flash_resource, }; -#endif /*----------- USB -------------------------*/ -- cgit v0.10.2 From 4513c3b8c4370d795d9856f7589c64cd216772ab Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 15 May 2014 21:54:52 +0200 Subject: ARM: OMAP: AM3517EVM: remove check for CONFIG_PANEL_SHARP_LQ043T1DG01 The Kconfig symbol PANEL_SHARP_LQ043T1DG01 was removed in v2.6.38. The check for CONFIG_PANEL_SHARP_LQ043T1DG01 and its MODULE variant has evaluated to false ever since. Remove that check. Signed-off-by: Paul Bolle Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c index 543d9a8..4f9383c 100644 --- a/arch/arm/mach-omap2/board-am3517evm.c +++ b/arch/arm/mach-omap2/board-am3517evm.c @@ -262,12 +262,7 @@ static struct usbhs_phy_data phy_data[] __initdata = { static struct usbhs_omap_platform_data usbhs_bdata __initdata = { .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, -#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \ - defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE) - .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, -#else .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, -#endif }; #ifdef CONFIG_OMAP_MUX -- cgit v0.10.2 From 77c2f02edbeda9409a7cf3fd66233015820c213a Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Fri, 16 May 2014 12:00:57 +0200 Subject: ARM: OMAP: replace checks for CONFIG_USB_GADGET_OMAP Commit 193ab2a60700 ("usb: gadget: allow multiple gadgets to be built") apparently required that checks for CONFIG_USB_GADGET_OMAP would be replaced with checks for CONFIG_USB_OMAP. Do so now for the remaining checks for CONFIG_USB_GADGET_OMAP, even though these checks have basically been broken since v3.1. And, since we're touching this code, use the IS_ENABLED() macro, so things will now (hopefully) also work if USB_OMAP is modular. Fixes: 193ab2a60700 ("usb: gadget: allow multiple gadgets to be built") Signed-off-by: Paul Bolle Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index 65d2acb..5b45d26 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c @@ -346,7 +346,7 @@ static struct omap_usb_config h2_usb_config __initdata = { /* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED(CONFIG_USB_OMAP) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */ /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */ #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index 816ecd1..bfed4f9 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c @@ -366,7 +366,7 @@ static struct omap_usb_config h3_usb_config __initdata = { /* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED(CONFIG_USB_OMAP) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */ #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */ diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c index bd5f02e..c49ce83 100644 --- a/arch/arm/mach-omap1/board-innovator.c +++ b/arch/arm/mach-omap1/board-innovator.c @@ -312,7 +312,7 @@ static struct omap_usb_config h2_usb_config __initdata = { /* usb1 has a Mini-AB port and external isp1301 transceiver */ .otg = 2, -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED(CONFIG_USB_OMAP) .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */ /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */ #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c index 3a02621..7436d4c 100644 --- a/arch/arm/mach-omap1/board-osk.c +++ b/arch/arm/mach-omap1/board-osk.c @@ -283,7 +283,7 @@ static struct omap_usb_config osk_usb_config __initdata = { * be used, with a NONSTANDARD gender-bending cable/dongle, as * a peripheral. */ -#ifdef CONFIG_USB_GADGET_OMAP +#if IS_ENABLED(CONFIG_USB_OMAP) .register_dev = 1, .hmc_mode = 0, #else diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c index 6e146d7..69e49be 100644 --- a/drivers/usb/phy/phy-isp1301-omap.c +++ b/drivers/usb/phy/phy-isp1301-omap.c @@ -1295,7 +1295,7 @@ isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) return isp1301_otg_enable(isp); return 0; -#elif !defined(CONFIG_USB_GADGET_OMAP) +#elif !IS_ENABLED(CONFIG_USB_OMAP) // FIXME update its refcount otg->host = host; -- cgit v0.10.2 From a29269db817a3f8f5ced51a0c7ed7b1f3ad418ba Mon Sep 17 00:00:00 2001 From: Gregory CLEMENT Date: Wed, 7 May 2014 15:52:21 +0200 Subject: ARM: configs: enable XHCI mvebu support in multi_v7_defconfig The Marvell Armada 38x platform needs the xhci_mvebu driver enabled for the xHCI USB hosts, so this commit enables the corresponding Kconfig option in multi_v7_defconfig. Signed-off-by: Gregory CLEMENT Signed-off-by: Thomas Petazzoni Cc: arm@kernel.org Cc: Kevin Hilman Cc: Olof Johansson Cc: Arnd Bergmann Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 5039cc6..2fbafc5 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -257,6 +257,7 @@ CONFIG_SND_SOC_TEGRA_ALC5632=y CONFIG_SND_SOC_TEGRA_MAX98090=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_MVEBU=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_TEGRA=y CONFIG_USB_EHCI_HCD_PLATFORM=y -- cgit v0.10.2 From 551f80a5c915c4615cd4065ad4db5cf68f765b97 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 16 May 2014 14:10:12 +0200 Subject: ARM: shmobile: Remove non-multiplatform Genmai reference support Now that r7s72100 has CCF support, remove the legacy Genmai reference Kconfig bits for the non-multiplatform case. Starting from this commit Genmai board support is always enabled via CONFIG_MACH_GENMAI, and CONFIG_ARCH_MULTIPLATFORM is used to select between board-genmai.c and board-genmai-reference.c The file board-genmai-reference.c can no longer be used together with the legacy sh-clk clock framework, instead CCF is used. Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 35c146f..4ede75e 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -306,7 +306,6 @@ dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \ s3c6410-smdk6410.dtb dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \ r7s72100-genmai.dtb \ - r7s72100-genmai-reference.dtb \ r8a7740-armadillo800eva.dtb \ r8a7778-bockw.dtb \ r8a7778-bockw-reference.dtb \ diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 0f92ba8..2ba18c6 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -240,17 +240,6 @@ config MACH_GENMAI depends on ARCH_R7S72100 select USE_OF -config MACH_GENMAI_REFERENCE - bool "Genmai board - Reference Device Tree Implementation" - depends on ARCH_R7S72100 - select USE_OF - ---help--- - Use reference implementation of Genmai board support - which makes use of device tree at the expense - of not supporting a number of devices. - - This is intended to aid developers - config MACH_MARZEN bool "MARZEN board" depends on ARCH_R8A7779 diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index c12a1c5..a455584b 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -67,7 +67,6 @@ obj-$(CONFIG_MACH_MACKEREL) += board-mackerel.o obj-$(CONFIG_MACH_BOCKW) += board-bockw.o obj-$(CONFIG_MACH_BOCKW_REFERENCE) += board-bockw-reference.o obj-$(CONFIG_MACH_GENMAI) += board-genmai.o -obj-$(CONFIG_MACH_GENMAI_REFERENCE) += board-genmai-reference.o obj-$(CONFIG_MACH_MARZEN) += board-marzen.o obj-$(CONFIG_MACH_MARZEN_REFERENCE) += board-marzen-reference.o obj-$(CONFIG_MACH_LAGER) += board-lager.o diff --git a/arch/arm/mach-shmobile/Makefile.boot b/arch/arm/mach-shmobile/Makefile.boot index 99455ec..918fccf 100644 --- a/arch/arm/mach-shmobile/Makefile.boot +++ b/arch/arm/mach-shmobile/Makefile.boot @@ -7,7 +7,6 @@ loadaddr-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE) += 0x40008000 loadaddr-$(CONFIG_MACH_BOCKW) += 0x60008000 loadaddr-$(CONFIG_MACH_BOCKW_REFERENCE) += 0x60008000 loadaddr-$(CONFIG_MACH_GENMAI) += 0x08008000 -loadaddr-$(CONFIG_MACH_GENMAI_REFERENCE) += 0x08008000 loadaddr-$(CONFIG_MACH_KOELSCH) += 0x40008000 loadaddr-$(CONFIG_MACH_KZM9G) += 0x41008000 loadaddr-$(CONFIG_MACH_KZM9G_REFERENCE) += 0x41008000 -- cgit v0.10.2 From 88351216f595786a24ff6cb7df7b101811981c78 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 16 May 2014 14:10:13 +0200 Subject: ARM: shmobile: genmai-reference: Remove legacy clock support genmai-reference is now only built for multiplatform which means that CCF comes with the package. Remove unused legacy code ifdefs to clean up the code. Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c index 33015e5..968bbba 100644 --- a/arch/arm/mach-shmobile/board-genmai-reference.c +++ b/arch/arm/mach-shmobile/board-genmai-reference.c @@ -26,7 +26,6 @@ #include #include -#ifdef CONFIG_COMMON_CLK /* * This is a really crude hack to provide clkdev support to platform * devices until they get moved to DT. @@ -34,15 +33,10 @@ static const struct clk_name clk_names[] = { { "mtu2", "fck", "sh-mtu2" }, }; -#endif static void __init genmai_add_standard_devices(void) { -#ifdef CONFIG_COMMON_CLK shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), true); -#else - r7s72100_clock_init(); -#endif r7s72100_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } -- cgit v0.10.2 From 2606f47be55fd4545ed9236467682c636fd23f9d Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 16 May 2014 14:10:14 +0200 Subject: ARM: shmobile: Sync Genmai DTS with Genmai reference DTS Copy the device nodes from Genmai reference into the Genmai device tree file. This will allow us to use a single DTS file regardless of kernel configuration. In case of legacy C board code the device nodes may or may not be used, but in the multiplatform case all the DT device nodes will be used. Signed-off-by: Wolfram Sang Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100-genmai.dts b/arch/arm/boot/dts/r7s72100-genmai.dts index b1deaf7..56849b5 100644 --- a/arch/arm/boot/dts/r7s72100-genmai.dts +++ b/arch/arm/boot/dts/r7s72100-genmai.dts @@ -1,7 +1,8 @@ /* * Device Tree Source for the Genmai board * - * Copyright (C) 2013 Renesas Solutions Corp. + * Copyright (C) 2013-14 Renesas Solutions Corp. + * Copyright (C) 2014 Wolfram Sang, Sang Engineering * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any @@ -15,6 +16,10 @@ model = "Genmai"; compatible = "renesas,genmai", "renesas,r7s72100"; + aliases { + serial2 = &scif2; + }; + chosen { bootargs = "console=ttySC2,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp"; }; @@ -29,3 +34,26 @@ #size-cells = <1>; }; }; + +&extal_clk { + clock-frequency = <13330000>; +}; + +&usb_x1_clk { + clock-frequency = <48000000>; +}; + +&i2c2 { + status = "okay"; + clock-frequency = <400000>; + + eeprom@50 { + compatible = "renesas,24c128"; + reg = <0x50>; + pagesize = <64>; + }; +}; + +&scif2 { + status = "okay"; +}; -- cgit v0.10.2 From 23f679fa6de3b3f7e1d9e1d8eaeafa5167a55a17 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 16 May 2014 14:10:15 +0200 Subject: ARM: shmobile: Let Genmai multiplatform boot with Genmai DTB Let the multiplatform Genmai support boot with the unified DTS. Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 4ede75e..1329d4d 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -320,7 +320,7 @@ dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \ r8a73a4-ape6evm-reference.dtb \ sh7372-mackerel.dtb dtb-$(CONFIG_ARCH_SHMOBILE_MULTI) += emev2-kzm9d.dtb \ - r7s72100-genmai-reference.dtb \ + r7s72100-genmai.dtb \ r8a7791-koelsch.dtb \ r8a7790-lager.dtb dtb-$(CONFIG_ARCH_SOCFPGA) += socfpga_arria5_socdk.dtb \ diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c index 968bbba..2ff6ad6 100644 --- a/arch/arm/mach-shmobile/board-genmai-reference.c +++ b/arch/arm/mach-shmobile/board-genmai-reference.c @@ -42,7 +42,7 @@ static void __init genmai_add_standard_devices(void) } static const char * const genmai_boards_compat_dt[] __initconst = { - "renesas,genmai-reference", + "renesas,genmai", NULL, }; -- cgit v0.10.2 From a5176e0d9de31a54e08468f21c15dc08e006857f Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 16 May 2014 14:10:16 +0200 Subject: ARM: shmobile: Remove Genmai reference DTS Now that the DTS file r7s72100-genmai.dts can be used with board-genmai.c and board-genmai-reference.c, proceed with removing r7s72100-genmai-reference.dts. Signed-off-by: Wolfram Sang Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman diff --git a/arch/arm/boot/dts/r7s72100-genmai-reference.dts b/arch/arm/boot/dts/r7s72100-genmai-reference.dts deleted file mode 100644 index ca88458..0000000 --- a/arch/arm/boot/dts/r7s72100-genmai-reference.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Device Tree Source for the Genmai board - * - * Copyright (C) 2013-14 Renesas Solutions Corp. - * Copyright (C) 2014 Wolfram Sang, Sang Engineering - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - */ - -/dts-v1/; -#include "r7s72100.dtsi" - -/ { - model = "Genmai"; - compatible = "renesas,genmai-reference", "renesas,r7s72100"; - - aliases { - serial2 = &scif2; - }; - - chosen { - bootargs = "console=ttySC2,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp"; - }; - - memory { - device_type = "memory"; - reg = <0x08000000 0x08000000>; - }; - - lbsc { - #address-cells = <1>; - #size-cells = <1>; - }; -}; - -&extal_clk { - clock-frequency = <13330000>; -}; - -&usb_x1_clk { - clock-frequency = <48000000>; -}; - -&i2c2 { - status = "okay"; - clock-frequency = <400000>; - - eeprom@50 { - compatible = "renesas,24c128"; - reg = <0x50>; - pagesize = <64>; - }; -}; - -&scif2 { - status = "okay"; -}; -- cgit v0.10.2 From 4a70e968893e887083b23b98961cb7b7c4c68d59 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 14 May 2014 23:31:50 +0200 Subject: ARM: add drivers for Colibri T30 to multi_v7_defconfig Toradex Colibri Evaluation Board uses the DS1307 RTC and the MCP251x CAN controller. The NVIDIA Tegra 3 based Colibri T30 module can be used on this carrier board, hence enable those drivers in tegra_defonfig and multi_v7_defconfig. Furthermore the NVIDIA Tegra 3 based Apalis T30 module too contains two MCP251x CAN controller. Signed-off-by: Stefan Agner Acked-by: Stephen Warren Signed-off-by: Olof Johansson diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 2fbafc5..86e01a8 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -97,6 +97,11 @@ CONFIG_INET6_IPCOMP=m CONFIG_IPV6_MIP6=m CONFIG_IPV6_TUNNEL=m CONFIG_IPV6_MULTIPLE_TABLES=y +CONFIG_CAN=y +CONFIG_CAN_RAW=y +CONFIG_CAN_BCM=y +CONFIG_CAN_DEV=y +CONFIG_CAN_MCP251X=y CONFIG_CFG80211=m CONFIG_MAC80211=m CONFIG_RFKILL=y @@ -291,6 +296,7 @@ CONFIG_EDAC_HIGHBANK_MC=y CONFIG_EDAC_HIGHBANK_L2=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_AS3722=y +CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_MAX8907=y CONFIG_RTC_DRV_PALMAS=y CONFIG_RTC_DRV_TWL4030=y -- cgit v0.10.2 From ea56785629494394b9e567c0a43690d6c972e137 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Thu, 15 May 2014 12:17:05 +0200 Subject: ARM: davinci: remove checks for CONFIG_USB_MUSB_PERIPHERAL The Kconfig symbol USB_MUSB_PERIPHERAL was removed in v3.1. The last two checks for its macro now always evaluate to false. So remove these checks. Signed-off-by: Paul Bolle [nsekhar@ti.com: also cleaned-up usage in defconfig file] Signed-off-by: Sekhar Nori diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig index 2a282c0..2f8ff65 100644 --- a/arch/arm/configs/davinci_all_defconfig +++ b/arch/arm/configs/davinci_all_defconfig @@ -160,7 +160,6 @@ CONFIG_USB=m CONFIG_USB_DEVICEFS=y CONFIG_USB_MON=m CONFIG_USB_MUSB_HDRC=m -CONFIG_USB_MUSB_PERIPHERAL=y CONFIG_USB_GADGET_MUSB_HDRC=y CONFIG_MUSB_PIO_ONLY=y CONFIG_USB_STORAGE=m diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index ecdc7d4..06d63d5 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c @@ -350,11 +350,7 @@ static struct davinci_mmc_config dm355evm_mmc_config = { * you have proper Mini-B or Mini-A cables (or Mini-A adapters) * the ID pin won't need any help. */ -#ifdef CONFIG_USB_MUSB_PERIPHERAL -#define USB_ID_VALUE 0 /* ID pulled high; *should* float */ -#else #define USB_ID_VALUE 1 /* ID pulled low */ -#endif static struct spi_eeprom at25640a = { .byte_len = SZ_64K / 8, diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c index 43bacbf..680a7a2 100644 --- a/arch/arm/mach-davinci/board-dm355-leopard.c +++ b/arch/arm/mach-davinci/board-dm355-leopard.c @@ -208,11 +208,7 @@ static struct davinci_mmc_config dm355leopard_mmc_config = { * you have proper Mini-B or Mini-A cables (or Mini-A adapters) * the ID pin won't need any help. */ -#ifdef CONFIG_USB_MUSB_PERIPHERAL -#define USB_ID_VALUE 0 /* ID pulled high; *should* float */ -#else #define USB_ID_VALUE 1 /* ID pulled low */ -#endif static struct spi_eeprom at25640a = { .byte_len = SZ_64K / 8, -- cgit v0.10.2