Skip to contentSkip to conversation

MIPS: rb532: move dev3 init code to devices.c

PATCH In review Phil Sutter 1 participant 4 messages Jan 19, 2009 4 messages not in the archive MIPS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 3/5 MIPS: rb532: move dev3 init code to devices.c

This code doesn't belong to gpio.c, as it's completely unrelated to GPIO. As dev1 and dev2 init code is in devices.c, it seems to be a more adequate place.

---
 arch/mips/rb532/devices.c |   39 +++++++++++++++++++++++++++++++++++++++
 arch/mips/rb532/gpio.c    |   39 ---------------------------------------
 2 files changed, 39 insertions(+), 39 deletions(-)
arch/mips/rb532/devices.c +39 -0
index 3c74561..1a0209e 100644
@@ -42,6 +42,34 @@
 
 extern unsigned int idt_cpu_freq;
 
+static struct mpmc_device dev3;
+
+void set_latch_u5(unsigned char or_mask, unsigned char nand_mask)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&dev3.lock, flags);
+
+	dev3.state = (dev3.state | or_mask) & ~nand_mask;
+	writeb(dev3.state, dev3.base);
+
+	spin_unlock_irqrestore(&dev3.lock, flags);
+}
+EXPORT_SYMBOL(set_latch_u5);
+
+unsigned char get_latch_u5(void)
+{
+	return dev3.state;
+}
+EXPORT_SYMBOL(get_latch_u5);
+
+static struct resource rb532_dev3_ctl_res[] = {
+	{
+		.name	= "dev3_ctl",
+		.flags	= IORESOURCE_MEM,
+	}
+};
+
 static struct resource korina_dev0_res[] = {
 	{
 		.name = "korina_regs",
@@ -314,6 +342,17 @@ static int __init plat_setup_devices(void)
 	nand_slot0_res[0].start = readl(IDT434_REG_BASE + DEV2BASE);
 	nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000;
 
+	/* Read the third (multi purpose) resources from the DC */
+	rb532_dev3_ctl_res[0].start = readl(IDT434_REG_BASE + DEV3BASE);
+	rb532_dev3_ctl_res[0].end = rb532_dev3_ctl_res[0].start + 0x1000;
+
+	dev3.base = ioremap_nocache(rb532_dev3_ctl_res[0].start, 0x1000);
+
+	if (!dev3.base) {
+		printk(KERN_ERR "rb532: cannot remap device controller 3\n");
+		return -ENXIO;
+	}
+
 	/* Initialise the NAND device */
 	rb532_nand_setup();
 
arch/mips/rb532/gpio.c +0 -39
index 7e0cb4f..b9cb428 100644
@@ -41,8 +41,6 @@ struct rb532_gpio_chip {
 	void __iomem	 *regbase;
 };
 
-struct mpmc_device dev3;
-
 static struct resource rb532_gpio_reg0_res[] = {
 	{
 		.name 	= "gpio_reg0",
@@ -52,13 +50,6 @@ static struct resource rb532_gpio_reg0_res[] = {
 	}
 };
 
-static struct resource rb532_dev3_ctl_res[] = {
-	{
-		.name	= "dev3_ctl",
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
 void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val)
 {
 	unsigned long flags;
@@ -86,25 +77,6 @@ unsigned get_434_reg(unsigned reg_offs)
 }
 EXPORT_SYMBOL(get_434_reg);
 
-void set_latch_u5(unsigned char or_mask, unsigned char nand_mask)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&dev3.lock, flags);
-
-	dev3.state = (dev3.state | or_mask) & ~nand_mask;
-	writeb(dev3.state, dev3.base);
-
-	spin_unlock_irqrestore(&dev3.lock, flags);
-}
-EXPORT_SYMBOL(set_latch_u5);
-
-unsigned char get_latch_u5(void)
-{
-	return dev3.state;
-}
-EXPORT_SYMBOL(get_latch_u5);
-
 /* rb532_set_bit - sanely set a bit
  *
  * bitval: new value for the bit
@@ -241,17 +213,6 @@ int __init rb532_gpio_init(void)
 	/* Register our GPIO chip */
 	gpiochip_add(&rb532_gpio_chip->chip);
 
-	rb532_dev3_ctl_res[0].start = readl(IDT434_REG_BASE + DEV3BASE);
-	rb532_dev3_ctl_res[0].end = rb532_dev3_ctl_res[0].start + 0x1000;
-
-	r = rb532_dev3_ctl_res;
-	dev3.base = ioremap_nocache(r->start, r->end - r->start);
-
-	if (!dev3.base) {
-		printk(KERN_ERR "rb532: cannot remap device controller 3\n");
-		return -ENXIO;
-	}
-
 	return 0;
 }
 arch_initcall(rb532_gpio_init);
Signature · 1 line
1.5.6.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

PATCH 5/5 MIPS: rb532: simplify dev3 init

As rb532_dev3_ctl_res is not used by any platform device, it can be dropped when not used for holding the physical address of the device 3 controller.
Also a size of one byte should suffice when ioremapping the physical address mentioned above, as only a single byte is being read from and written to it.

---
 arch/mips/rb532/devices.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)
arch/mips/rb532/devices.c +2 -12
index 1a0209e..4a5f05b 100644
@@ -63,13 +63,6 @@ unsigned char get_latch_u5(void)
 }
 EXPORT_SYMBOL(get_latch_u5);
 
-static struct resource rb532_dev3_ctl_res[] = {
-	{
-		.name	= "dev3_ctl",
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
 static struct resource korina_dev0_res[] = {
 	{
 		.name = "korina_regs",
@@ -342,11 +335,8 @@ static int __init plat_setup_devices(void)
 	nand_slot0_res[0].start = readl(IDT434_REG_BASE + DEV2BASE);
 	nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000;
 
-	/* Read the third (multi purpose) resources from the DC */
-	rb532_dev3_ctl_res[0].start = readl(IDT434_REG_BASE + DEV3BASE);
-	rb532_dev3_ctl_res[0].end = rb532_dev3_ctl_res[0].start + 0x1000;
-
-	dev3.base = ioremap_nocache(rb532_dev3_ctl_res[0].start, 0x1000);
+	/* Read and map device controller 3 */
+	dev3.base = ioremap_nocache(readl(IDT434_REG_BASE + DEV3BASE), 1);
 
 	if (!dev3.base) {
 		printk(KERN_ERR "rb532: cannot remap device controller 3\n");
Signature · 1 line
1.5.6.4
#6 lore raw

PATCH 4/5 MIPS: rb532: remove {get,set}_434_reg()

In reply to a message not in the archive

These kernel symbols are unused. Also, since dev3 init has been moved to devices.c, set_434_reg() breaks compiling as it uses dev3.

---
 arch/mips/rb532/gpio.c |   27 ---------------------------
 1 files changed, 0 insertions(+), 27 deletions(-)
arch/mips/rb532/gpio.c +0 -27
index b9cb428..a916ac8 100644
@@ -50,33 +50,6 @@ static struct resource rb532_gpio_reg0_res[] = {
 	}
 };
 
-void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val)
-{
-	unsigned long flags;
-	unsigned data;
-	unsigned i = 0;
-
-	spin_lock_irqsave(&dev3.lock, flags);
-
-	data = readl(IDT434_REG_BASE + reg_offs);
-	for (i = 0; i != len; ++i) {
-		if (val & (1 << i))
-			data |= (1 << (i + bit));
-		else
-			data &= ~(1 << (i + bit));
-	}
-	writel(data, (IDT434_REG_BASE + reg_offs));
-
-	spin_unlock_irqrestore(&dev3.lock, flags);
-}
-EXPORT_SYMBOL(set_434_reg);
-
-unsigned get_434_reg(unsigned reg_offs)
-{
-	return readl(IDT434_REG_BASE + reg_offs);
-}
-EXPORT_SYMBOL(get_434_reg);
-
 /* rb532_set_bit - sanely set a bit
  *
  * bitval: new value for the bit
Signature · 1 line
1.5.6.4
#7 lore raw

PATCH 2/5 MIPS: rb532: fix set_latch_u5()

In reply to a message not in the archive

The data to be written is just a byte, so use writeb instead of writel. Also, dev3.base contains the address, not the data so referencing here is wrong.

---
 arch/mips/rb532/gpio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/rb532/gpio.c +1 -1
index 40deb11..7e0cb4f 100644
@@ -93,7 +93,7 @@ void set_latch_u5(unsigned char or_mask, unsigned char nand_mask)
 	spin_lock_irqsave(&dev3.lock, flags);
 
 	dev3.state = (dev3.state | or_mask) & ~nand_mask;
-	writel(dev3.state, &dev3.base);
+	writeb(dev3.state, dev3.base);
 
 	spin_unlock_irqrestore(&dev3.lock, flags);
 }
Signature · 1 line
1.5.6.4