linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: add DT support to the S3C SDI driver
@ 2011-04-13 17:25 Domenico Andreoli
  2011-04-13 17:33 ` Grant Likely
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Domenico Andreoli @ 2011-04-13 17:25 UTC (permalink / raw)
  To: linux-arm-kernel

From: Domenico Andreoli <cavokz@gmail.com>

This patch adds DeviceTree support to the S3C SDI driver.

It implements all the configurations of the platform driver except the
set_power() callback and the ocr_avail mask.

Signed-off-by: Domenico Andreoli <cavokz@gmail.com>

---

ocr_avail is a bit mask that could be easily ported to DT. If there
is not any better (or readable) way to render it in DT, I will
straightforwardly implement it.

set_power() instead deserves some more considerations. Current
implementations boil down to gpio on/off settings, its DT implementation
is again straightforward. Problem would arise if any board requires
some naive implementation, would it require a different of_device_id
with proper .data set?

cheers,
Domenico

---
 drivers/mmc/host/s3cmci.c |   83 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 5 deletions(-)

Index: b/drivers/mmc/host/s3cmci.c
===================================================================
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 #include <linux/mmc/host.h>
 #include <linux/platform_device.h>
 #include <linux/cpufreq.h>
@@ -22,6 +23,8 @@
 #include <linux/gpio.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #include <mach/dma.h>
 
@@ -1544,6 +1547,58 @@
 
 #endif /* CONFIG_DEBUG_FS */
 
+#ifdef CONFIG_OF
+
+enum of_s3cmci_flags {
+	OF_S3CMCI_USE_DMA = 1,
+};
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+	struct s3c24xx_mci_pdata *pdata;
+	const __be32 *spec;
+	enum of_gpio_flags gpio_flags;
+	int gpio;
+	u32 flags;
+
+	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+	if(!pdata) {
+		dev_err(dev, "%s: failed to allocate pdata\n", dev->of_node->full_name);
+		return NULL;
+	}
+
+	gpio = of_get_gpio_flags(dev->of_node, 0, &gpio_flags);
+	if (gpio < 0) {
+		pdata->no_detect = 1;
+	} else {
+		pdata->gpio_detect = gpio;
+		pdata->detect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+	}
+
+	gpio = of_get_gpio_flags(dev->of_node, 1, &gpio_flags);
+	if (gpio < 0) {
+		pdata->no_wprotect = 1;
+	} else {
+		pdata->gpio_wprotect = gpio;
+		pdata->wprotect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+	}
+
+	spec = of_get_property(dev->of_node, "flags", 0);
+	flags = spec ? be32_to_cpup(spec) : 0;
+	pdata->use_dma = flags | OF_S3CMCI_USE_DMA;
+
+	return pdata;
+}
+
+#else
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+	return NULL;
+}
+
+#endif /* CONFIG_OF */
+
 static int __devinit s3cmci_probe(struct platform_device *pdev)
 {
 	struct s3cmci_host *host;
@@ -1552,7 +1607,12 @@
 	int is2440;
 	int i;
 
-	is2440 = platform_get_device_id(pdev)->driver_data;
+	if (platform_get_device_id(pdev))
+		is2440 = platform_get_device_id(pdev)->driver_data;
+	else if (pdev->dev.of_match)
+		is2440 = (int) pdev->dev.of_match->data;
+	else
+		BUG();
 
 	mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev);
 	if (!mmc) {
@@ -1577,11 +1637,11 @@
 	host->pdev	= pdev;
 	host->is2440	= is2440;
 
-	host->pdata = pdev->dev.platform_data;
-	if (!host->pdata) {
+	if (!pdev->dev.platform_data && pdev->dev.of_node)
+		pdev->dev.platform_data = s3cmci_of_init(&pdev->dev);
+	if (!pdev->dev.platform_data)
 		pdev->dev.platform_data = &s3cmci_def_pdata;
-		host->pdata = &s3cmci_def_pdata;
-	}
+	host->pdata = pdev->dev.platform_data;
 
 	spin_lock_init(&host->complete_lock);
 	tasklet_init(&host->pio_tasklet, pio_tasklet, (unsigned long) host);
@@ -1901,12 +1961,25 @@
 #define s3cmci_pm_ops NULL
 #endif /* CONFIG_PM */
 
+#ifdef CONFIG_OF
+
+static const struct of_device_id s3cmci_of_match[] = {
+	{ .compatible = "samsung,s3c2410-sdi", .data = (void *) 0, },
+	{ .compatible = "samsung,s3c2412-sdi", .data = (void *) 1, },
+	{ .compatible = "samsung,s3c2440-sdi", .data = (void *) 1, },
+	{},
+};
+
+#else /* CONFIG_OF */
+#define s3cmci_of_match  NULL
+#endif /* CONFIG_OF */
 
 static struct platform_driver s3cmci_driver = {
 	.driver	= {
 		.name	= "s3c-sdi",
 		.owner	= THIS_MODULE,
 		.pm	= s3cmci_pm_ops,
+		.of_match_table = s3cmci_of_match,
 	},
 	.id_table	= s3cmci_driver_ids,
 	.probe		= s3cmci_probe,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-13 17:25 [PATCH] ARM: add DT support to the S3C SDI driver Domenico Andreoli
@ 2011-04-13 17:33 ` Grant Likely
  2011-04-13 17:35 ` Grant Likely
  2011-04-14  8:51 ` Vasily Khoruzhick
  2 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2011-04-13 17:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 13, 2011 at 07:25:47PM +0200, Domenico Andreoli wrote:
> From: Domenico Andreoli <cavokz@gmail.com>
> 
> This patch adds DeviceTree support to the S3C SDI driver.
> 
> It implements all the configurations of the platform driver except the
> set_power() callback and the ocr_avail mask.
> 
> Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
> 
> ---
> 
> ocr_avail is a bit mask that could be easily ported to DT. If there
> is not any better (or readable) way to render it in DT, I will
> straightforwardly implement it.
> 
> set_power() instead deserves some more considerations. Current
> implementations boil down to gpio on/off settings, its DT implementation
> is again straightforward. Problem would arise if any board requires
> some naive implementation, would it require a different of_device_id
> with proper .data set?
> 
> cheers,
> Domenico

Looks pretty good do me.  One minor comment below, but I think I can
pick this one up into the devicetree/test branch.

g.

> 
> ---
>  drivers/mmc/host/s3cmci.c |   83 +++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 5 deletions(-)
> 
> Index: b/drivers/mmc/host/s3cmci.c
> ===================================================================
> --- a/drivers/mmc/host/s3cmci.c
> +++ b/drivers/mmc/host/s3cmci.c
> @@ -14,6 +14,7 @@
>  #include <linux/module.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/clk.h>
> +#include <linux/slab.h>
>  #include <linux/mmc/host.h>
>  #include <linux/platform_device.h>
>  #include <linux/cpufreq.h>
> @@ -22,6 +23,8 @@
>  #include <linux/gpio.h>
>  #include <linux/irq.h>
>  #include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
>  
>  #include <mach/dma.h>
>  
> @@ -1544,6 +1547,58 @@
>  
>  #endif /* CONFIG_DEBUG_FS */
>  
> +#ifdef CONFIG_OF
> +
> +enum of_s3cmci_flags {
> +	OF_S3CMCI_USE_DMA = 1,
> +};
> +
> +static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
> +{
> +	struct s3c24xx_mci_pdata *pdata;
> +	const __be32 *spec;
> +	enum of_gpio_flags gpio_flags;
> +	int gpio;
> +	u32 flags;
> +
> +	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> +	if(!pdata) {
> +		dev_err(dev, "%s: failed to allocate pdata\n", dev->of_node->full_name);
> +		return NULL;
> +	}
> +
> +	gpio = of_get_gpio_flags(dev->of_node, 0, &gpio_flags);
> +	if (gpio < 0) {
> +		pdata->no_detect = 1;
> +	} else {
> +		pdata->gpio_detect = gpio;
> +		pdata->detect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
> +	}
> +
> +	gpio = of_get_gpio_flags(dev->of_node, 1, &gpio_flags);
> +	if (gpio < 0) {
> +		pdata->no_wprotect = 1;
> +	} else {
> +		pdata->gpio_wprotect = gpio;
> +		pdata->wprotect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
> +	}
> +
> +	spec = of_get_property(dev->of_node, "flags", 0);
> +	flags = spec ? be32_to_cpup(spec) : 0;
> +	pdata->use_dma = flags | OF_S3CMCI_USE_DMA;
> +
> +	return pdata;
> +}
> +
> +#else
> +
> +static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
> +{
> +	return NULL;
> +}
> +
> +#endif /* CONFIG_OF */
> +
>  static int __devinit s3cmci_probe(struct platform_device *pdev)
>  {
>  	struct s3cmci_host *host;
> @@ -1552,7 +1607,12 @@
>  	int is2440;
>  	int i;
>  
> -	is2440 = platform_get_device_id(pdev)->driver_data;
> +	if (platform_get_device_id(pdev))
> +		is2440 = platform_get_device_id(pdev)->driver_data;
> +	else if (pdev->dev.of_match)
> +		is2440 = (int) pdev->dev.of_match->data;
> +	else
> +		BUG();
>  
>  	mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev);
>  	if (!mmc) {
> @@ -1577,11 +1637,11 @@
>  	host->pdev	= pdev;
>  	host->is2440	= is2440;
>  
> -	host->pdata = pdev->dev.platform_data;
> -	if (!host->pdata) {
> +	if (!pdev->dev.platform_data && pdev->dev.of_node)
> +		pdev->dev.platform_data = s3cmci_of_init(&pdev->dev);
> +	if (!pdev->dev.platform_data)
>  		pdev->dev.platform_data = &s3cmci_def_pdata;
> -		host->pdata = &s3cmci_def_pdata;
> -	}
> +	host->pdata = pdev->dev.platform_data;
>  
>  	spin_lock_init(&host->complete_lock);
>  	tasklet_init(&host->pio_tasklet, pio_tasklet, (unsigned long) host);
> @@ -1901,12 +1961,25 @@
>  #define s3cmci_pm_ops NULL
>  #endif /* CONFIG_PM */
>  
> +#ifdef CONFIG_OF
> +
> +static const struct of_device_id s3cmci_of_match[] = {
> +	{ .compatible = "samsung,s3c2410-sdi", .data = (void *) 0, },
> +	{ .compatible = "samsung,s3c2412-sdi", .data = (void *) 1, },
> +	{ .compatible = "samsung,s3c2440-sdi", .data = (void *) 1, },

A little ugly.  I'd rather see a real structure being passed, even if
it is almost empty.  However, I see that the existing driver is
already using this pattern, so I won't make a big deal about it.

> +	{},
> +};
> +
> +#else /* CONFIG_OF */
> +#define s3cmci_of_match  NULL
> +#endif /* CONFIG_OF */
>  
>  static struct platform_driver s3cmci_driver = {
>  	.driver	= {
>  		.name	= "s3c-sdi",
>  		.owner	= THIS_MODULE,
>  		.pm	= s3cmci_pm_ops,
> +		.of_match_table = s3cmci_of_match,
>  	},
>  	.id_table	= s3cmci_driver_ids,
>  	.probe		= s3cmci_probe,
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-13 17:25 [PATCH] ARM: add DT support to the S3C SDI driver Domenico Andreoli
  2011-04-13 17:33 ` Grant Likely
@ 2011-04-13 17:35 ` Grant Likely
  2011-04-13 20:52   ` Domenico Andreoli
  2011-04-14  8:51 ` Vasily Khoruzhick
  2 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2011-04-13 17:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 13, 2011 at 07:25:47PM +0200, Domenico Andreoli wrote:
> From: Domenico Andreoli <cavokz@gmail.com>
> 
> This patch adds DeviceTree support to the S3C SDI driver.
> 
> It implements all the configurations of the platform driver except the
> set_power() callback and the ocr_avail mask.
> 
> Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
> 
> ---
> 
> ocr_avail is a bit mask that could be easily ported to DT. If there
> is not any better (or readable) way to render it in DT, I will
> straightforwardly implement it.
> 
> set_power() instead deserves some more considerations. Current
> implementations boil down to gpio on/off settings, its DT implementation
> is again straightforward. Problem would arise if any board requires
> some naive implementation, would it require a different of_device_id
> with proper .data set?

It would be better to think out the binding a bit more, but I'd need
to know more details about what is possible.

g.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-13 17:35 ` Grant Likely
@ 2011-04-13 20:52   ` Domenico Andreoli
  0 siblings, 0 replies; 7+ messages in thread
From: Domenico Andreoli @ 2011-04-13 20:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 13, 2011 at 11:35:58AM -0600, Grant Likely wrote:
> On Wed, Apr 13, 2011 at 07:25:47PM +0200, Domenico Andreoli wrote:
> >
> > set_power() instead deserves some more considerations. Current
> > implementations boil down to gpio on/off settings, its DT implementation
> > is again straightforward. Problem would arise if any board requires
> > some naive implementation, would it require a different of_device_id
> > with proper .data set?
>
> It would be better to think out the binding a bit more, but I'd need
> to know more details about what is possible.

I looked at the arm tree only, MMC/MCI/SDI area. There are some
.set_power ops also on the LCD side and who know what else with a
different ops name.

The most common case is no .set_power op.

Then we have quite a lot of GPIO cases like this:

static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
{
    switch (power_mode) {
    case MMC_POWER_OFF:
        gpio_set_value(H1940_LATCH_SD_POWER, 0);
        break;
    case MMC_POWER_UP:
    case MMC_POWER_ON:
        gpio_set_value(H1940_LATCH_SD_POWER, 1);
        break;
    default:
        break;
    };
}

and its derivative:

static int mmc_set_power(struct device *dev, int slot, int power_on, int vdd)
{
    gpio_set_value(H2_TPS_GPIO_MMC_PWR_EN, power_on);
    return 0;
}

then we have a bitwise case on some register (the fpga name is
misleading, they are just __raw_readb/__raw_writeb):

static int mmc_set_power(struct device *dev, int slot, int power_on, int vdd)
{
    if (power_on)
        fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3), OMAP1510_FPGA_POWER);
    else
        fpga_write(fpga_read(OMAP1510_FPGA_POWER) & ~(1 << 3), OMAP1510_FPGA_POWER);

    return 0;
}

a i2c bitwise case:

static int mmc_set_power(struct device *dev, int slot, int power_on, int vdd)
{
    int err;
    u8 dat = 0;

    err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
    if (err < 0)
        return err;

    if (power_on)
        dat |= SOFIA_MMC_POWER;
    else
        dat &= ~SOFIA_MMC_POWER;

    return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
}

and some other very special cases such as:

static int n8x0_mmc_set_power(struct device *dev, int slot, int power_on, int vdd)
{
    if (machine_is_nokia_n800() || slot == 0)
        return n8x0_mmc_set_power_menelaus(dev, slot, power_on, vdd);

    n810_set_power_emmc(dev, power_on);

    return 0;
}

static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot, int power_on, int vdd)
{
    int mV; 

#ifdef CONFIG_MMC_DEBUG
    dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
        power_on ? "on" : "off", vdd);
#endif
    if (slot == 0) {
        if (!power_on)
            return menelaus_set_vmmc(0);
        switch (1 << vdd) {
        case MMC_VDD_33_34:
        case MMC_VDD_32_33:
        case MMC_VDD_31_32:
            mV = 3100;
            break;
        case MMC_VDD_30_31:
            mV = 3000;
            break;
        case MMC_VDD_28_29:
            mV = 2800;
            break;
        case MMC_VDD_165_195:
            mV = 1850;
            break;
        default:
            BUG();
        }   
        return menelaus_set_vmmc(mV);
    } else {
        if (!power_on)
            return menelaus_set_vdcdc(3, 0); 
        switch (1 << vdd) {
        case MMC_VDD_33_34:
        case MMC_VDD_32_33:
            mV = 3300;
            break;
        case MMC_VDD_30_31:
        case MMC_VDD_29_30:
            mV = 3000;
            break;
        case MMC_VDD_28_29:
        case MMC_VDD_27_28:
            mV = 2800;
            break;
        case MMC_VDD_24_25:
        case MMC_VDD_23_24:
            mV = 2400;
            break;
        case MMC_VDD_22_23:
        case MMC_VDD_21_22:
            mV = 2200;
            break;
        case MMC_VDD_20_21:
            mV = 2000;
            break;
        case MMC_VDD_165_195:
            mV = 1800;
            break;
        default:
            BUG();
        }   
        return menelaus_set_vdcdc(3, mV);
    }   
    return 0;
}

static void n810_set_power_emmc(struct device *dev, int power_on)
{
    dev_dbg(dev, "Set EMMC power %s\n", power_on ? "on" : "off");

    if (power_on) {
        gpio_set_value(N810_EMMC_VSD_GPIO, 1);
        msleep(1);
        gpio_set_value(N810_EMMC_VIO_GPIO, 1);
        msleep(1);
    } else {
        gpio_set_value(N810_EMMC_VIO_GPIO, 0);
        msleep(50);
        gpio_set_value(N810_EMMC_VSD_GPIO, 0);
        msleep(50);
    }
}

the first three are straightforward, the i2c could be tricky but very
nicely expressed in the DT world, the others are so specific that I
doubt they could be re-used on any other board, so I don't see the gain
to port them to DT.

When I say port, I mean "import the interface" concept, of course :)

my two cents....

cheers,
Domenico

-----[ Domenico Andreoli, aka cavok
 --[ http://www.dandreoli.com/gpgkey.asc
   ---[ 3A0F 2F80 F79C 678A 8936  4FEE 0677 9033 A20E BC50

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-13 17:25 [PATCH] ARM: add DT support to the S3C SDI driver Domenico Andreoli
  2011-04-13 17:33 ` Grant Likely
  2011-04-13 17:35 ` Grant Likely
@ 2011-04-14  8:51 ` Vasily Khoruzhick
  2011-04-14  9:37   ` Domenico Andreoli
  2011-05-04  1:04   ` Grant Likely
  2 siblings, 2 replies; 7+ messages in thread
From: Vasily Khoruzhick @ 2011-04-14  8:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 13 April 2011 20:25:47 Domenico Andreoli wrote:
> From: Domenico Andreoli <cavokz@gmail.com>
> 
> This patch adds DeviceTree support to the S3C SDI driver.
> 
> It implements all the configurations of the platform driver except the
> set_power() callback and the ocr_avail mask.
> 
> Signed-off-by: Domenico Andreoli <cavokz@gmail.com>

Hm, but is there any bootloader with dt support for s3c24xx?

Regards
Vasily

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-14  8:51 ` Vasily Khoruzhick
@ 2011-04-14  9:37   ` Domenico Andreoli
  2011-05-04  1:04   ` Grant Likely
  1 sibling, 0 replies; 7+ messages in thread
From: Domenico Andreoli @ 2011-04-14  9:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 14, 2011 at 11:51:50AM +0300, Vasily Khoruzhick wrote:
> On Wednesday 13 April 2011 20:25:47 Domenico Andreoli wrote:
> > From: Domenico Andreoli <cavokz@gmail.com>
> > 
> > This patch adds DeviceTree support to the S3C SDI driver.
> > 
> > It implements all the configurations of the platform driver except the
> > set_power() callback and the ocr_avail mask.
> > 
> > Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
> 
> Hm, but is there any bootloader with dt support for s3c24xx?

I don't know, probably no - I don't care. IMHO main gain doesn't come
from the bootloader.

I use this patch by Jeremy Kerr to bundle dtb with the kernel. Another
solution has been proposed [0] but has some issue. More will come,
maybe allowing the bundle of multiple dtbs.

cheers,
Domenico

[0] http://article.gmane.org/gmane.linux.drivers.devicetree/5068


Index: arm-2.6.git/arch/arm/Kconfig
===================================================================
--- arm-2.6.git.orig/arch/arm/Kconfig	2011-04-05 16:06:26.000000000 +0200
+++ arm-2.6.git/arch/arm/Kconfig	2011-04-05 16:06:54.000000000 +0200
@@ -1694,6 +1694,10 @@
 	help
 	  Include support for flattened device tree machine descriptions.
 
+config ARM_EMBEDDED_DTB
+	string "Embedded device tree blob" if OF
+	default ""
+
 # Compressed boot loader in ROM.  Yes, we really want to ask about
 # TEXT and BSS so we preserve their values in the config files.
 config ZBOOT_ROM_TEXT
Index: arm-2.6.git/arch/arm/Makefile
===================================================================
--- arm-2.6.git.orig/arch/arm/Makefile	2011-04-05 16:06:26.000000000 +0200
+++ arm-2.6.git/arch/arm/Makefile	2011-04-05 16:06:54.000000000 +0200
@@ -281,7 +281,7 @@
 # Convert bzImage to zImage
 bzImage: zImage
 
-zImage Image xipImage bootpImage uImage: vmlinux
+zImage Image xipImage bootpImage uImage dtbImage: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
 
 zinstall uinstall install: vmlinux
Index: arm-2.6.git/arch/arm/boot/Makefile
===================================================================
--- arm-2.6.git.orig/arch/arm/boot/Makefile	2011-04-05 16:06:26.000000000 +0200
+++ arm-2.6.git/arch/arm/boot/Makefile	2011-04-05 16:06:54.000000000 +0200
@@ -27,7 +27,7 @@
 
 export ZRELADDR INITRD_PHYS PARAMS_PHYS
 
-targets := Image zImage xipImage bootpImage uImage
+targets := Image zImage xipImage bootpImage uImage dtbImage
 
 ifeq ($(CONFIG_XIP_KERNEL),y)
 
@@ -90,6 +90,14 @@
 	$(call if_changed,objcopy)
 	@echo '  Kernel: $@ is ready'
 
+$(obj)/dt/dtb: $(obj)/zImage FORCE
+	$(Q)$(MAKE) $(build)=$(obj)/dt $@
+	@:
+
+$(obj)/dtbImage: $(obj)/dt/dtb FORCE
+	$(call if_changed,objcopy)
+	@echo '  Kernel: $@ is ready'
+
 PHONY += initrd FORCE
 initrd:
 	@test "$(INITRD_PHYS)" != "" || \
Index: arm-2.6.git/arch/arm/boot/dt/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ arm-2.6.git/arch/arm/boot/dt/Makefile	2011-04-05 16:06:54.000000000 +0200
@@ -0,0 +1,15 @@
+#
+# linux/arch/arm/dt/Makefile
+#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
+
+LDFLAGS_dtb	:=-p --no-undefined -X -T
+
+targets	:= dtb dtb.o
+
+$(obj)/dtb:	$(src)/dtb.lds $(src)/dtb.o FORCE
+	$(call if_changed,ld)
+
+$(obj)/dtb.o: arch/arm/boot/zImage FORCE
Index: arm-2.6.git/arch/arm/boot/dt/dtb.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ arm-2.6.git/arch/arm/boot/dt/dtb.S	2011-04-05 16:06:54.000000000 +0200
@@ -0,0 +1,52 @@
+/*
+ * If we have an embedded dtb (_dtb_start < _dtb_end), then add a pointer
+ * to it in r2, as per the DT-on-ARM boot interface.
+ *
+ * r2-r14 overwritten
+ */
+
+#define DTB_ADDR		0x00001000
+
+	.globl start
+start:
+setup_dtb:
+	ldr	r4, =dtb_start
+	ldr	r5, =dtb_end
+
+	cmp	r4, r5		/* skip the init if there's no DTB */
+	beq	zimage_start
+
+	/* Find our offset from the link address, and update dtb start
+	 * and end pointers. */
+	bl	1f
+1:	sub	r6, lr, #(1b)
+	add	r4, r4, r6
+	add	r5, r5, r6
+
+	/* calculate final DTB address into r2 */
+	ldr	r7, =0xfff00000
+	and	r2, r6, r7
+	add	r2, r2, #DTB_ADDR
+
+	/* copy dtb to final address */
+	mov	r3, r2
+2:	ldmia	r4!, {r7-r14}
+	stmia	r3!, {r7-r14}
+	cmp	r4, r5
+	blo	2b
+
+	b	zimage_start
+
+	.ltorg
+
+	.align 4
+	.section .dtb,"a"
+dtb_start:
+	.incbin CONFIG_ARM_EMBEDDED_DTB
+dtb_end:
+	.align 4
+
+	.section .zimage,"ax"
+zimage_start:
+	.incbin "arch/arm/boot/zImage"
+
Index: arm-2.6.git/arch/arm/boot/dt/dtb.lds
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ arm-2.6.git/arch/arm/boot/dt/dtb.lds	2011-04-05 16:06:54.000000000 +0200
@@ -0,0 +1,25 @@
+/*
+ *  linux/arch/arm/boot/dt/dtb.lds
+ *
+ *  Copyright (C) 2009-2010 Jeremy Kerr <jeremy.kerr@canonical.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+OUTPUT_ARCH(arm)
+ENTRY(start)
+SECTIONS
+{
+	.text : {
+		*(.text)
+	}
+
+	.dtb : {
+		*(.dtb)
+	}
+
+	.zimage : {
+		*(.zimage)
+	}
+}

-----[ Domenico Andreoli, aka cavok
 --[ http://www.dandreoli.com/gpgkey.asc
   ---[ 3A0F 2F80 F79C 678A 8936  4FEE 0677 9033 A20E BC50

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ARM: add DT support to the S3C SDI driver
  2011-04-14  8:51 ` Vasily Khoruzhick
  2011-04-14  9:37   ` Domenico Andreoli
@ 2011-05-04  1:04   ` Grant Likely
  1 sibling, 0 replies; 7+ messages in thread
From: Grant Likely @ 2011-05-04  1:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 14, 2011 at 11:51:50AM +0300, Vasily Khoruzhick wrote:
> On Wednesday 13 April 2011 20:25:47 Domenico Andreoli wrote:
> > From: Domenico Andreoli <cavokz@gmail.com>
> > 
> > This patch adds DeviceTree support to the S3C SDI driver.
> > 
> > It implements all the configurations of the platform driver except the
> > set_power() callback and the ocr_avail mask.
> > 
> > Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
> 
> Hm, but is there any bootloader with dt support for s3c24xx?

On current u-boot mainline, all arm platforms can now add devicetree
support by enabling CONFIG_OF_LIBFDT.

g.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-05-04  1:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 17:25 [PATCH] ARM: add DT support to the S3C SDI driver Domenico Andreoli
2011-04-13 17:33 ` Grant Likely
2011-04-13 17:35 ` Grant Likely
2011-04-13 20:52   ` Domenico Andreoli
2011-04-14  8:51 ` Vasily Khoruzhick
2011-04-14  9:37   ` Domenico Andreoli
2011-05-04  1:04   ` Grant Likely

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).