linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: michael@walle.cc (Michael Walle)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5 v2] ARM: kirkwood: covert orion-spi to fdt.
Date: Sun, 4 Mar 2012 19:12:20 +0100	[thread overview]
Message-ID: <201203041912.21137.michael@walle.cc> (raw)
In-Reply-To: <a3c65ac8146eab1796dec771c1ddfe403d1471a9.1330709314.git.jason@lakedaemon.net>

Am Freitag 02 M?rz 2012, 18:50:18 schrieb Jason Cooper:
> On the Globalscale Dreamplug (Marvell Kirkwood Development Platform),
> 2MB of NOR flash are used to hold the bootloader, bootloader
> environment, and devicetree blob.  It is connected via spi.
> 
> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
> ---
> 
> Changes from v1:
> 
>     - used of_match_ptr() as suggested by Grant Likely
> 
>  arch/arm/boot/dts/kirkwood-dreamplug.dts |   34 +++++++++++++++++++++++++
>  arch/arm/mach-kirkwood/board-dt.c        |   40
> ------------------------------ arch/arm/mach-kirkwood/common.c          | 
>  11 ++++++++
>  drivers/spi/spi-orion.c                  |   37
> ++++++++++++++++++++++++--- 4 files changed, 78 insertions(+), 44
> deletions(-)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts
> b/arch/arm/boot/dts/kirkwood-dreamplug.dts index 8a5dff8..bdf2ddc 100644
> --- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
> +++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
> @@ -22,4 +22,38 @@
>  		interrupts = <33>;
>  		clock-frequency = <200000000>;
>  	};
> +
> +	spi at f1010600 {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		compatible = "marvell,orion-spi";
> +		reg = <0xf1010600 0x1ff>;
> +		clock-frequency = <200000000>;
> +
> +		flash at 0 {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +
> +			compatible = "macronix,mx25l1606e", "jedec-flash";
> +
> +			spi-max-frequency = <50000000>;
> +			reg = <0>;
> +
> +			partition at 0 {
> +				label = "U-Boot";
> +				reg = <0x0 0x100000>;
> +			};
> +
> +			partition at 100000 {
> +				label = "U-Boot Environment";
> +				reg = <0x100000 0x080000>;
> +			};
> +
> +			partition at 180000 {
> +				label = "Flattened Device Tree";
> +				reg = <0x180000 0x080000>;
> +			};
> +		};
> +	};
>  };
> diff --git a/arch/arm/mach-kirkwood/board-dt.c
> b/arch/arm/mach-kirkwood/board-dt.c index fbe6405..4960e63 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -39,42 +39,6 @@ static struct of_device_id kirkwood_dt_match_table[]
> __initdata = { { }
>  };
> 
> -struct mtd_partition dreamplug_partitions[] = {
> -	{
> -		.name	= "u-boot",
> -		.size	= SZ_512K,
> -		.offset = 0,
> -	},
> -	{
> -		.name	= "u-boot env",
> -		.size	= SZ_64K,
> -		.offset = SZ_512K + SZ_512K,
> -	},
> -	{
> -		.name	= "dtb",
> -		.size	= SZ_64K,
> -		.offset = SZ_512K + SZ_512K + SZ_512K,
> -	},
> -};
> -
> -static const struct flash_platform_data dreamplug_spi_slave_data = {
> -	.type		= "mx25l1606e",
> -	.name		= "spi_flash",
> -	.parts		= dreamplug_partitions,
> -	.nr_parts	= ARRAY_SIZE(dreamplug_partitions),
> -};
> -
> -static struct spi_board_info __initdata dreamplug_spi_slave_info[] = {
> -	{
> -		.modalias	= "m25p80",
> -		.platform_data	= &dreamplug_spi_slave_data,
> -		.irq		= -1,
> -		.max_speed_hz	= 50000000,
> -		.bus_num	= 0,
> -		.chip_select	= 0,
> -	},
> -};
> -
>  static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
>  	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
>  };
> @@ -140,10 +104,6 @@ static void __init dreamplug_init(void)
>  	 */
>  	kirkwood_mpp_conf(dreamplug_mpp_config);
> 
> -	spi_register_board_info(dreamplug_spi_slave_info,
> -				ARRAY_SIZE(dreamplug_spi_slave_info));
> -	kirkwood_spi_init();
> -
>  	kirkwood_ehci_init();
>  	kirkwood_ge00_init(&dreamplug_ge00_data);
>  	kirkwood_ge01_init(&dreamplug_ge01_data);
> diff --git a/arch/arm/mach-kirkwood/common.c
> b/arch/arm/mach-kirkwood/common.c index cc15426..357fcde 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -15,6 +15,7 @@
>  #include <linux/ata_platform.h>
>  #include <linux/mtd/nand.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/of.h>
>  #include <net/dsa.h>
>  #include <asm/page.h>
>  #include <asm/timex.h>
> @@ -481,6 +482,9 @@ static int __init kirkwood_clock_gate(void)
>  {
>  	unsigned int curr = readl(CLOCK_GATING_CTRL);
>  	u32 dev, rev;
> +#ifdef CONFIG_OF
> +	struct device_node *dp;
> +#endif
> 
>  	kirkwood_pcie_id(&dev, &rev);
>  	printk(KERN_DEBUG "Gating clock of unused units\n");
> @@ -524,6 +528,13 @@ static int __init kirkwood_clock_gate(void)
>  	} else  /* keep this bit set for devices that don't have PCIe1 */
>  		kirkwood_clk_ctrl |= CGC_PEX1;
> 
> +#ifdef CONFIG_OF
> +	dp = of_find_node_by_path("/");
> +	if (dp && of_device_is_available(of_find_compatible_node(dp, NULL,
> +							  "marvell,orion-
spi")))
> +		kirkwood_clk_ctrl |= CGC_RUNIT;
> +#endif
> +
>  	/* Now gate clock the required units */
>  	writel(kirkwood_clk_ctrl, CLOCK_GATING_CTRL);
>  	printk(KERN_DEBUG " after: 0x%08x\n", readl(CLOCK_GATING_CTRL));
> diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
> index 13448c8..acfb240 100644
> --- a/drivers/spi/spi-orion.c
> +++ b/drivers/spi/spi-orion.c
> @@ -18,6 +18,7 @@
>  #include <linux/spi/spi.h>
>  #include <linux/spi/orion_spi.h>
>  #include <linux/module.h>
> +#include <linux/of_device.h>
>  #include <asm/unaligned.h>
> 
>  #define DRIVER_NAME			"orion_spi"
> @@ -45,6 +46,8 @@ struct orion_spi {
>  	void __iomem		*base;
>  	unsigned int		max_speed;
>  	unsigned int		min_speed;
> +	unsigned int		tclk;
> +	unsigned int		clock_fix;
>  	struct orion_spi_info	*spi_info;
>  };
> 
> @@ -104,7 +107,7 @@ static int orion_spi_baudrate_set(struct spi_device
> *spi, unsigned int speed)
> 
>  	orion_spi = spi_master_get_devdata(spi->master);
> 
> -	tclk_hz = orion_spi->spi_info->tclk;
> +	tclk_hz = orion_spi->tclk;
> 
>  	/*
>  	 * the supported rates are: 4,6,8...30
> @@ -360,7 +363,7 @@ static int orion_spi_setup(struct spi_device *spi)
>  	orion_spi = spi_master_get_devdata(spi->master);
> 
>  	/* Fix ac timing if required.   */
> -	if (orion_spi->spi_info->enable_clock_fix)
> +	if (orion_spi->clock_fix)
>  		orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG,
>  				  (1 << 14));
> 
> @@ -474,6 +477,7 @@ static int __init orion_spi_probe(struct
> platform_device *pdev) master->setup = orion_spi_setup;
>  	master->transfer = orion_spi_transfer;
>  	master->num_chipselect = ORION_NUM_CHIPSELECTS;
> +	master->dev.of_node = pdev->dev.of_node;
> 
>  	dev_set_drvdata(&pdev->dev, master);
> 
> @@ -481,8 +485,26 @@ static int __init orion_spi_probe(struct
> platform_device *pdev) spi->master = master;
>  	spi->spi_info = spi_info;
> 
> -	spi->max_speed = DIV_ROUND_UP(spi_info->tclk, 4);
> -	spi->min_speed = DIV_ROUND_UP(spi_info->tclk, 30);
> +	if (spi_info)
> +		spi->tclk = spi_info->tclk;
> +
> +	of_property_read_u32(master->dev.of_node,
> +				"clock-frequency", &spi->tclk);
> +
> +	if (!spi->tclk) {
> +		dev_err(&pdev->dev, "cannot set clock rate\n");
shouldn't you check the return value of of_property_read_u32 instead? and 
report a more meaningful error message, eg no valid clock-frequency property 
in the OF case?

> +		status = -EINVAL;
> +		goto out;
> +	}
> +
> +	spi->max_speed = DIV_ROUND_UP(spi->tclk, 4);
> +	spi->min_speed = DIV_ROUND_UP(spi->tclk, 30);
> +
> +	if (spi_info)
> +		spi->clock_fix = spi_info->enable_clock_fix;
> +
> +	if (of_find_property(master->dev.of_node, "spi-clock-fix", NULL))
> +		spi->clock_fix = 1;
> 
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (r == NULL) {
> @@ -541,10 +563,17 @@ static int __exit orion_spi_remove(struct
> platform_device *pdev)
> 
>  MODULE_ALIAS("platform:" DRIVER_NAME);
> 

#ifdef CONFIG_OF
> +static struct of_device_id spi_orion_of_match_table[] __devinitdata = {
> +	{ .compatible = "marvell,orion-spi", },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, spi_orion_of_match_table);
#endif

>  static struct platform_driver orion_spi_driver = {
>  	.driver = {
>  		.name	= DRIVER_NAME,
>  		.owner	= THIS_MODULE,
> +		.of_match_table = of_match_ptr(spi_orion_of_match_table),
>  	},
>  	.remove		= __exit_p(orion_spi_remove),
>  };


-- 
Michael

  reply	other threads:[~2012-03-04 18:12 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01 18:20 [PATCH 0/4] ARM: kirkwood: fdt: convert kirkwood init funcs to fdt Jason Cooper
2012-03-01 18:20 ` [PATCH 1/4] ARM: kirkwood: move var setting to correct location Jason Cooper
2012-03-01 18:20 ` [PATCH 2/4] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-02  7:09   ` Grant Likely
2012-03-01 18:20 ` [PATCH 3/4] ARM: kirkwood: convert rtc-mv to fdt Jason Cooper
2012-03-01 19:35   ` Arnd Bergmann
2012-03-01 21:26     ` Jason
2012-03-02  7:19   ` Grant Likely
2012-03-02  9:48     ` Arnd Bergmann
2012-03-02 16:27     ` Jason
2012-03-04 14:59   ` Michael Walle
2012-03-04 16:48     ` Arnd Bergmann
2012-03-04 22:27       ` Jason
2012-03-04 23:22         ` Michael Walle
2012-03-01 18:20 ` [PATCH 4/4] ARM: kirkwood: convert orion-wdt " Jason Cooper
2012-03-01 19:48   ` Arnd Bergmann
2012-03-02  7:22   ` Grant Likely
2012-03-02  9:15   ` Simon Guinot
2012-03-02 14:15     ` Jason
2012-03-02 14:56       ` Arnd Bergmann
2012-03-02 15:36         ` Jason
2012-03-02 16:48           ` Arnd Bergmann
2012-03-02 17:02             ` Jason
2012-03-02 22:36               ` Andrew Lunn
2012-03-03 22:54                 ` Jason
2012-03-01 19:50 ` [PATCH 0/4] ARM: kirkwood: fdt: convert kirkwood init funcs " Arnd Bergmann
2012-03-01 20:01   ` Jason
2012-03-01 20:28     ` Arnd Bergmann
2012-03-01 21:23       ` Jason
2012-03-01 22:14         ` Arnd Bergmann
2012-03-02 16:31           ` Jason
2012-03-02 16:58             ` Arnd Bergmann
2012-03-02 17:04               ` Jason
2012-03-02 17:50 ` [PATCH 0/5 v2] " Jason Cooper
2012-03-02 17:50   ` [PATCH 1/5 v2] ARM: kirkwood: covert orion-spi " Jason Cooper
2012-03-04 18:12     ` Michael Walle [this message]
2012-03-04 20:29       ` Arnd Bergmann
2012-03-02 17:50   ` [PATCH 2/5] ARM: kirkwood: move var setting to correct location Jason Cooper
2012-03-02 17:50   ` [PATCH 3/5 v2] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-02 17:50   ` [PATCH 4/5 v2] ARM: kirkwood: convert rtc-mv to fdt Jason Cooper
2012-03-04 15:12     ` Michael Walle
2012-03-04 16:50       ` Arnd Bergmann
2012-03-05  0:17         ` Jason
2012-03-02 17:50   ` [PATCH 5/5 v2] ARM: kirkwood: convert orion-wdt " Jason Cooper
2012-03-02 18:32     ` Arnd Bergmann
2012-03-02 19:57       ` Jason
2012-03-02 20:02         ` Arnd Bergmann
     [not found]       ` <20120302200034.GQ11986@titan.lakedaemon.net>
2012-03-02 20:35         ` [PULL REQUEST v2] ARM: kirkwood: fdt: convert kirkwood init funcs " Arnd Bergmann
2012-03-02 21:18           ` Arnd Bergmann
2012-03-05 18:49             ` Nicolas Pitre
2012-03-05 19:15               ` Jason
2012-03-05 20:16                 ` Arnd Bergmann
2012-03-05 20:29                   ` Jason
2012-03-05 20:43                     ` Nicolas Pitre
2012-03-05 21:17                       ` Jason
2012-03-05 21:27                         ` Nicolas Pitre
2012-03-06 14:29                           ` Jason
2012-03-03 10:08       ` [PATCH 5/5 v2] ARM: kirkwood: convert orion-wdt " Russell King - ARM Linux
2012-03-03 23:05         ` Jason
2012-03-02 17:52   ` [PULL REQUEST] ARM: kirkwood: fdt: convert kirkwood init funcs " Jason
2012-03-02 17:56     ` Jason
2012-03-07  3:44 ` [PATCH 0/14 v3] ARM: kirkwood: fdt: convert kirkwood " Jason Cooper
2012-03-07  3:44   ` [PATCH 01/14] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-09  4:33     ` Grant Likely
2012-03-07  3:44   ` [PATCH 02/14] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-07  3:44   ` [PATCH 03/14] ARM: kirkwood: add dreamplug (fdt) support Jason Cooper
2012-03-07  3:44   ` [PATCH 04/14] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-07  3:44   ` [PATCH 05/14] ARM: kirkwood: add interrupt controller to devicetree Jason Cooper
2012-03-07  3:44   ` [PATCH 06/14] ARM: kirkwood: convert uart0 " Jason Cooper
2012-03-07 18:31     ` Arnd Bergmann
2012-03-07 18:37       ` Jason
2012-03-07 19:27       ` Jason
2012-03-07 20:05         ` Andrew Lunn
2012-03-07 20:55           ` Jason
2012-03-07 21:13         ` Arnd Bergmann
2012-03-07 21:29           ` Jason
2012-03-08 16:25           ` Jason
2012-03-08 17:01             ` Arnd Bergmann
2012-03-08 17:41               ` Arnd Bergmann
2012-03-08 19:27               ` Thomas Gleixner
2012-03-08 19:47                 ` Jason
2012-03-08 21:32                   ` Grant Likely
2012-03-08 21:50                     ` Jason
2012-03-08 22:22                       ` Rob Herring
2012-03-08 21:27           ` Grant Likely
2012-03-08 23:14             ` Arnd Bergmann
2012-03-07 21:47         ` Michael Walle
2012-03-08 21:31         ` Grant Likely
2012-03-08 21:55           ` Jason
2012-03-07  3:44   ` [PATCH 07/14] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-07  3:44   ` [PATCH 08/14] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-07 18:32     ` Arnd Bergmann
2012-03-07  3:44   ` [PATCH 09/14] ARM: kirkwood: mv_cesa devicetree bindings Jason Cooper
2012-03-07  3:44   ` [PATCH 10/14] ARM: kirkwood: mv_cesa devicetree support Jason Cooper
2012-03-07  3:44   ` [PATCH 11/14] ARM: kirkwood: ehci-orion: add device tree binding Jason Cooper
2012-03-07  3:44   ` [PATCH 12/14] ARM: kirkwood: use devicetree for orion-ehci Jason Cooper
2012-03-07  3:44   ` [PATCH 13/14] ARM: kirkwood: sata_mv: add device tree binding Jason Cooper
2012-03-07  3:44   ` [PATCH 14/14] ARM: kirkwood: use devicetree to init sata_mv Jason Cooper
2012-03-07 18:40     ` Arnd Bergmann
2012-03-07 18:52       ` Jason
2012-03-07 19:00         ` Arnd Bergmann
2012-03-13  1:57 ` [PATCH 0/7 v4] ARM: kirkwood: fdt: convert kirkwood to fdt Jason Cooper
2012-03-13  1:57   ` [PATCH 1/7] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-13  1:57   ` [PATCH 2/7] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-13  1:57   ` [PATCH 3/7 v2] ARM: orion: wdt: use resource vice direct access Jason Cooper
2012-03-13  9:54     ` Arnd Bergmann
2012-03-13  1:57   ` [PATCH 4/7 v4] ARM: kirkwood: add dreamplug (fdt) support Jason Cooper
2012-03-13 10:10     ` Arnd Bergmann
2012-03-13 13:12       ` Jason Cooper
2012-04-05 22:07     ` Ian Campbell
2012-04-05 22:41       ` Jason Cooper
2012-04-06  8:52         ` Ian Campbell
     [not found]         ` <384286E8-E5C8-4069-9702-8A24C70D799C@gmail.com>
2012-04-16 13:27           ` dreamplug kernel and uboot code and apparent dreamplug board design change Jason Cooper
2012-03-13  1:57   ` [PATCH 5/7 v2] ARM: kirkwood: convert uart0 to devicetree Jason Cooper
2012-03-13 13:18     ` Jason Cooper
2012-03-13  1:57   ` [PATCH 6/7] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-13  9:57     ` Arnd Bergmann
2012-03-13 10:03     ` Uwe Kleine-König
2012-03-13  1:57   ` [PATCH 7/7] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-13  9:58     ` Arnd Bergmann
2012-03-13 13:22       ` Jason Cooper
2012-03-13 13:44         ` Arnd Bergmann
2012-03-16  4:21 ` [PATCH 0/9 v5] ARM: kirkwood: fdt: convert kirkwood to fdt Jason Cooper
2012-03-16  4:21   ` [PATCH 1/9] ARM: orion: spi: remove enable_clock_fix which is not used Jason Cooper
2012-03-16  4:21   ` [PATCH 2/9] ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data Jason Cooper
2012-03-16  4:21   ` [PATCH 3/9 v3] ARM: orion: wdt: use resource vice direct access Jason Cooper
2012-03-16  4:21   ` [PATCH 4/9] ARM: kirkwood: fdt: use mrvl ticker symbol Jason Cooper
2012-03-16  4:21   ` [PATCH 5/9] ARM: kirkwood: fdt: absorb kirkwood_init() Jason Cooper
2012-03-16  4:21   ` [PATCH 6/9 v2] ARM: kirkwood: fdt: facilitate new boards during fdt migration Jason Cooper
2012-03-16  4:21   ` [PATCH 7/9] ARM: kirkwood: fdt: define uart[01] as disabled, enable uart0 Jason Cooper
2012-03-16  4:21   ` [PATCH 8/9 v2] ARM: kirkwood: rtc-mv devicetree bindings Jason Cooper
2012-03-16  4:21   ` [PATCH 9/9] ARM: kirkwood: use devicetree for rtc-mv Jason Cooper
2012-03-16 20:18   ` [PATCH 0/9 v5] ARM: kirkwood: fdt: convert kirkwood to fdt Arnd Bergmann
2012-03-16 20:28     ` Jason Cooper
2012-03-16 20:41       ` Arnd Bergmann
2012-03-16 21:02         ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201203041912.21137.michael@walle.cc \
    --to=michael@walle.cc \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).