Skip to contentSkip to conversation

can: mcp251x: Convert driver to use common clk framework

PATCH In review Alexander Shiyan 3 participants 6 messages Nov 13, 2013 – Dec 14, 2013

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 can: mcp251x: Convert driver to use common clk framework

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

---
 arch/arm/mach-imx/mach-cpuimx51sd.c  | 18 ++++++++++----
 arch/arm/mach-pxa/icontrol.c         | 23 +++++++++++------
 arch/arm/mach-pxa/zeus.c             | 18 ++++++++++----
 drivers/net/can/mcp251x.c            | 48 ++++++++++++++++++------------------
 include/linux/can/platform/mcp251x.h | 21 ----------------
 5 files changed, 65 insertions(+), 63 deletions(-)
 delete mode 100644 include/linux/can/platform/mcp251x.h
arch/arm/mach-imx/mach-cpuimx51sd.c +13 -5
index 9b5ddf5..493c0fc 100644
@@ -24,7 +24,8 @@
 #include <linux/interrupt.h>
 #include <linux/i2c-gpio.h>
 #include <linux/spi/spi.h>
-#include <linux/can/platform/mcp251x.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -244,9 +245,14 @@ static struct platform_device hsi2c_gpio_device = {
 	.dev.platform_data	= &pdata,
 };
 
-static struct mcp251x_platform_data mcp251x_info = {
-	.oscillator_frequency = 24E6,
-};
+static void initialize_clocks(void)
+{
+	struct clk *clk24;
+
+	clk24 = clk_register_fixed_rate(NULL, "clk24", NULL,
+					CLK_IS_ROOT, 24000000);
+	clk_register_clkdev(clk24, NULL, "spi0.0");
+}
 
 static struct spi_board_info cpuimx51sd_spi_device[] = {
 	{
@@ -255,7 +261,6 @@ static struct spi_board_info cpuimx51sd_spi_device[] = {
 		.bus_num         = 0,
 		.mode		= SPI_MODE_0,
 		.chip_select     = 0,
-		.platform_data   = &mcp251x_info,
 		/* irq number is run-time assigned */
 	},
 };
@@ -302,6 +307,9 @@ static void __init eukrea_cpuimx51sd_init(void)
 	gpio_direction_output(CAN_RST, 0);
 	msleep(20);
 	gpio_set_value(CAN_RST, 1);
+
+	initialize_clocks();
+
 	imx51_add_ecspi(0, &cpuimx51sd_ecspi1_pdata);
 	cpuimx51sd_spi_device[0].irq = gpio_to_irq(CAN_IRQGPIO);
 	spi_register_board_info(cpuimx51sd_spi_device,
arch/arm/mach-pxa/icontrol.c +15 -8
index c98511c..ebf453e 100644
@@ -23,9 +23,10 @@
 #include <mach/pxa320.h>
 #include <mach/mxm8x10.h>
 
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/pxa2xx_spi.h>
-#include <linux/can/platform/mcp251x.h>
 
 #include "generic.h"
 
@@ -71,9 +72,17 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
 	.gpio_cs        = ICONTROL_MCP251x_nCS4
 };
 
-static struct mcp251x_platform_data mcp251x_info = {
-	.oscillator_frequency = 16E6,
-};
+static void initialize_clocks(void)
+{
+	struct clk *clk16;
+
+	clk16 = clk_register_fixed_rate(NULL, "clk16", NULL,
+					CLK_IS_ROOT, 16000000);
+	clk_register_clkdev(clk16, NULL, "spi3.0");
+	clk_register_clkdev(clk16, NULL, "spi3.1");
+	clk_register_clkdev(clk16, NULL, "spi4.0");
+	clk_register_clkdev(clk16, NULL, "spi4.1");
+}
 
 static struct spi_board_info mcp251x_board_info[] = {
 	{
@@ -81,7 +90,6 @@ static struct spi_board_info mcp251x_board_info[] = {
 		.max_speed_hz    = 6500000,
 		.bus_num         = 3,
 		.chip_select     = 0,
-		.platform_data   = &mcp251x_info,
 		.controller_data = &mcp251x_chip_info1,
 		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
 	},
@@ -90,7 +98,6 @@ static struct spi_board_info mcp251x_board_info[] = {
 		.max_speed_hz    = 6500000,
 		.bus_num         = 3,
 		.chip_select     = 1,
-		.platform_data   = &mcp251x_info,
 		.controller_data = &mcp251x_chip_info2,
 		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
 	},
@@ -99,7 +106,6 @@ static struct spi_board_info mcp251x_board_info[] = {
 		.max_speed_hz    = 6500000,
 		.bus_num         = 4,
 		.chip_select     = 0,
-		.platform_data   = &mcp251x_info,
 		.controller_data = &mcp251x_chip_info3,
 		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
 	},
@@ -108,7 +114,6 @@ static struct spi_board_info mcp251x_board_info[] = {
 		.max_speed_hz    = 6500000,
 		.bus_num         = 4,
 		.chip_select     = 1,
-		.platform_data   = &mcp251x_info,
 		.controller_data = &mcp251x_chip_info4,
 		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
 	}
@@ -173,6 +178,8 @@ static mfp_cfg_t mfp_can_cfg[] __initdata = {
 
 static void __init icontrol_can_init(void)
 {
+	initialize_clocks();
+
 	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
 	platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
 	spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
arch/arm/mach-pxa/zeus.c +13 -5
index b19d1c3..7009e6e 100644
@@ -28,7 +28,8 @@
 #include <linux/i2c/pxa-i2c.h>
 #include <linux/platform_data/pca953x.h>
 #include <linux/apm-emulation.h>
-#include <linux/can/platform/mcp251x.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 
@@ -419,14 +420,18 @@ static struct platform_device can_regulator_device = {
 	},
 };
 
-static struct mcp251x_platform_data zeus_mcp2515_pdata = {
-	.oscillator_frequency	= 16*1000*1000,
-};
+static void initialize_clocks(void)
+{
+	struct clk *clk16;
+
+	clk16 = clk_register_fixed_rate(NULL, "clk16", NULL,
+					CLK_IS_ROOT, 16000000);
+	clk_register_clkdev(clk16, NULL, "spi3.0");
+}
 
 static struct spi_board_info zeus_spi_board_info[] = {
 	[0] = {
 		.modalias	= "mcp2515",
-		.platform_data	= &zeus_mcp2515_pdata,
 		.irq		= PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO),
 		.max_speed_hz	= 1*1000*1000,
 		.bus_num	= 3,
@@ -859,6 +864,9 @@ static void __init zeus_init(void)
 	pxa_set_ac97_info(&zeus_ac97_info);
 	pxa_set_i2c_info(NULL);
 	i2c_register_board_info(0, ARRAY_AND_SIZE(zeus_i2c_devices));
+
+	initialize_clocks();
+
 	pxa2xx_set_spi_info(3, &pxa2xx_spi_ssp3_master_info);
 	spi_register_board_info(zeus_spi_board_info, ARRAY_SIZE(zeus_spi_board_info));
 }
drivers/net/can/mcp251x.c +24 -24

105 lines not on this page · raw message

include/linux/can/platform/mcp251x.h deleted +0 -21
deleted file mode 100644
index dc029db..0000000
@@ -1,21 +0,0 @@
-#ifndef __CAN_PLATFORM_MCP251X_H__
-#define __CAN_PLATFORM_MCP251X_H__
-
-/*
- *
- * CAN bus driver for Microchip 251x CAN Controller with SPI Interface
- *
- */
-
-#include <linux/spi/spi.h>
-
-/*
- * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data
- * @oscillator_frequency:       - oscillator frequency in Hz
- */
-
-struct mcp251x_platform_data {
-	unsigned long oscillator_frequency;
-};
-
-#endif /* __CAN_PLATFORM_MCP251X_H__ */
Signature · 1 line
1.8.1.5
maintainer Acked-by on v1 1/3
#1 lore raw

Hello,

as this series adds device tree bindings, please add devicetree at vger.kernel.org on Cc for the whole series.

Quoted 8 lines · Alexander Shiyan

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

Looks good from my point of view. I'll take the whole series via the linux-can tree, if there are no objections. I'd like to have the pxa and imx maintainer's Ack and an Ack from the DT list.

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131113/529c9290/attachment-0001.sig>
#2 lore raw
Quoted 11 lines · On Wed, 13 Nov 2013 10:04:39 +0100 Marc Kleine-Budde <[email protected]> wrote:

as this series adds device tree bindings, please add devicetree at vger.kernel.org on Cc for the whole series.

Quoted 7 lines · Alexander Shiyan

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

Quoted 7 lines
Quoted 1 line

Looks good from my point of view. I'll take the whole series via the linux-can tree, if there are no objections. I'd like to have the pxa and imx maintainer's Ack and an Ack from the DT list.

Ping. Resend?

Signature · 1 line
Alexander Shiyan <[email protected]>
#3 lore raw
Quoted 16 lines · Alexander Shiyan
Quoted 13 lines · On Wed, 13 Nov 2013 10:04:39 +0100 Marc Kleine-Budde <[email protected]> wrote:

as this series adds device tree bindings, please add devicetree at vger.kernel.org on Cc for the whole series.

Quoted 8 lines · Alexander Shiyan

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

Quoted 7 lines
Quoted 5 lines

Looks good from my point of view. I'll take the whole series via the linux-can tree, if there are no objections. I'd like to have the pxa and imx maintainer's Ack and an Ack from the DT list.

Ping. Resend?

Is Dmitry's comment still valid?

PXA does not employ COMMON_CLK yet (WIP locally, but it is not finished yet), so clk_register_fixed() will probably fail.

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131214/b659ef1e/attachment.sig>
#4 lore raw
Quoted 21 lines · Alexander Shiyan
Quoted 20 lines
Quoted 17 lines · On Wed, 13 Nov 2013 10:04:39 +0100 Marc Kleine-Budde <[email protected]> wrote:

as this series adds device tree bindings, please add devicetree at vger.kernel.org on Cc for the whole series.

Quoted 8 lines · Alexander Shiyan

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

Looks good from my point of view. I'll take the whole series via the linux-can tree, if there are no objections. I'd like to have the pxa and imx maintainer's Ack and an Ack from the DT list.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Ping. Resend?

Is Dmitry's comment still valid?

PXA does not employ COMMON_CLK yet (WIP locally, but it is not finished yet), so clk_register_fixed() will probably fail.

OK, I'll make another version then.

---

#5 lore raw
In reply to Alexander Shiyan
Quoted 6 lines · Alexander Shiyan

This patch converts mcp251x driver to using common clk framework for getting input frequency. The change was made for the preparation of the driver work with the devicetree. As a result private header for the driver is eliminated.
Additionally, all existing users of the driver was converted to use this feature.

PXA does not employ COMMON_CLK yet (WIP locally, but it is not finished yet), so clk_register_fixed() will probably fail.

Signature · 2 lines
With best wishes
Dmitry