Skip to contentSkip to conversation

powerpc: i2c-mpc: make I2C bus speed configurable

PATCH In review Wolfgang Grandegger 7 participants 27 messages Mar 31, 2009 – Apr 2, 2009 5 messages not in the archive

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

cover powerpc: i2c-mpc: make I2C bus speed configurable

Following (most of) Grant's suggestions to my RFC:

http://ozlabs.org/pipermail/linuxppc-dev/2009-March/069820.html

this new patch series now uses:

- the I2c node property "fsl,preserve-clocking" to overtake the clock settings from the boot loader. The first patch provides this feature and can be applied *without* delay. This rest will take more time and discussion, I'm afraid :-(.

- the OF match table to define the I2C clock properties, especially the source clock pre-scaler:

  static const struct of_device_id mpc_i2c_of_match[] = {
	{.compatible = "fsl,mpc5200b-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc5200-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc8313-i2c",
	 .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, },
	{.compatible = "fsl,mpc8543-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV2), },
	{.compatible = "fsl,mpc8544-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV23), },
	/* Backward compatibility */
	{.compatible = "fsl-i2c", },
	{},

};

The "data" field defines the relevant I2C flags.

- arch-specific tables and functions to get the proper Freqency Divider Register (fdr). I added them to sysdev/fsl_soc.c for the MPC8xxx and to platforms/52xx/mpc52xx_common.c for the MPC52xx. This also solves the problem with arch-specific functions, e.g. for getting the bus frequency.

- dev_dbg() and dev_info() to profit from a more descriptive output.

Hope this solution is OK now?

Thanks,

Wolfgang.

#1 lore raw

PATCH 3/4 powerpc/85xx: Move gianfar mdio nodes under the

Currently it doesn't matter where the mdio nodes are placed, but with power management support (i.e. when sleep = <> properties will take effect), mdio nodes placement will become important: mdio controller is a part of the ethernet block, so the mdio nodes should be placed correctly. Otherwise we may wrongly assume that MDIO controllers are available during sleep.

---
 arch/powerpc/boot/dts/ksi8560.dts              |   79 ++++++-----
 arch/powerpc/boot/dts/mpc8536ds.dts            |   78 ++++++-----
 arch/powerpc/boot/dts/mpc8540ads.dts           |  117 +++++++++--------
 arch/powerpc/boot/dts/mpc8541cds.dts           |   78 ++++++-----
 arch/powerpc/boot/dts/mpc8544ds.dts            |   81 ++++++------
 arch/powerpc/boot/dts/mpc8548cds.dts           |  156 ++++++++++++-----------
 arch/powerpc/boot/dts/mpc8555cds.dts           |   78 ++++++-----
 arch/powerpc/boot/dts/mpc8560ads.dts           |  102 ++++++++-------
 arch/powerpc/boot/dts/mpc8568mds.dts           |  102 ++++++++-------
 arch/powerpc/boot/dts/mpc8572ds.dts            |  150 ++++++++++++----------
 arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts |   39 +++--
 arch/powerpc/boot/dts/sbc8548.dts              |   78 ++++++-----
 arch/powerpc/boot/dts/sbc8560.dts              |  100 +++++++-------
 arch/powerpc/boot/dts/stx_gp3_8560.dts         |   78 ++++++-----
 arch/powerpc/boot/dts/tqm8540.dts              |  117 +++++++++--------
 arch/powerpc/boot/dts/tqm8541.dts              |   90 +++++++------
 arch/powerpc/boot/dts/tqm8548-bigflash.dts     |  168 +++++++++++++------------
 arch/powerpc/boot/dts/tqm8548.dts              |  168 +++++++++++++------------
 arch/powerpc/boot/dts/tqm8555.dts              |   90 +++++++------
 arch/powerpc/boot/dts/tqm8560.dts              |   90 +++++++------
 arch/powerpc/platforms/85xx/ksi8560.c          |    1 
 arch/powerpc/platforms/85xx/mpc8536_ds.c       |    1 
 arch/powerpc/platforms/85xx/mpc85xx_ads.c      |    1 
 arch/powerpc/platforms/85xx/mpc85xx_cds.c      |    1 
 arch/powerpc/platforms/85xx/mpc85xx_ds.c       |    1 
 arch/powerpc/platforms/85xx/mpc85xx_mds.c      |    1 
 arch/powerpc/platforms/85xx/sbc8548.c          |    1 
 arch/powerpc/platforms/85xx/sbc8560.c          |    1 
 arch/powerpc/platforms/85xx/stx_gp3.c          |    1 
 arch/powerpc/platforms/85xx/tqm85xx.c          |    1 
 30 files changed, 1102 insertions(+), 947 deletions(-)
arch/powerpc/boot/dts/ksi8560.dts +42 -37
Index: linux-2.6/arch/powerpc/boot/dts/ksi8560.dts
===================================================================
@@ -124,67 +124,72 @@
 			};
 		};
 
-		mdio@24520 {					/* For TSECs */
-			#address-cells = <1>;
-			#size-cells = <0>;
-			compatible = "fsl,gianfar-mdio";
-			reg = <0x24520 0x20>;
-
-			PHY1: ethernet-phy@1 {
-				interrupt-parent = <&mpic>;
-				reg = <0x1>;
-				device_type = "ethernet-phy";
-			};
-
-			PHY2: ethernet-phy@2 {
-				interrupt-parent = <&mpic>;
-				reg = <0x2>;
-				device_type = "ethernet-phy";
-			};
-
-			tbi0: tbi-phy@11 {
-				reg = <0x11>;
-				device_type = "tbi-phy";
-			};
-		};
-
-		mdio@25520 {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			compatible = "fsl,gianfar-tbi";
-			reg = <0x25520 0x20>;
-
-			tbi1: tbi-phy@11 {
-				reg = <0x11>;
-				device_type = "tbi-phy";
-			};
-		};
-
-
 		enet0: ethernet@24000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
 			device_type = "network";
 			model = "TSEC";
 			compatible = "gianfar";
 			reg = <0x24000 0x1000>;
+			ranges = <0x0 0x24000 0x1000>;
 			/* Mac address filled in by bootwrapper */
 			local-mac-address = [ 00 00 00 00 00 00 ];
 			interrupts = <0x1d 0x2 0x1e 0x2 0x22 0x2>;
 			interrupt-parent = <&mpic>;
 			tbi-handle = <&tbi0>;
 			phy-handle = <&PHY1>;
+
+			mdio@520 {					/* For TSECs */
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,gianfar-mdio";
+				reg = <0x520 0x20>;
+
+				PHY1: ethernet-phy@1 {
+					interrupt-parent = <&mpic>;
+					reg = <0x1>;
+					device_type = "ethernet-phy";
+				};
+
+				PHY2: ethernet-phy@2 {
+					interrupt-parent = <&mpic>;
+					reg = <0x2>;
+					device_type = "ethernet-phy";
+				};
+
+				tbi0: tbi-phy@11 {
+					reg = <0x11>;
+					device_type = "tbi-phy";
+				};
+			};
 		};
 
 		enet1: ethernet@25000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
 			device_type = "network";
 			model = "TSEC";
 			compatible = "gianfar";
 			reg = <0x25000 0x1000>;
+			ranges = <0x0 0x25000 0x1000>;
 			/* Mac address filled in by bootwrapper */
 			local-mac-address = [ 00 00 00 00 00 00 ];
 			interrupts = <0x23 0x2 0x24 0x2 0x28 0x2>;
 			interrupt-parent = <&mpic>;
 			tbi-handle = <&tbi1>;
 			phy-handle = <&PHY2>;
+
+			mdio@520 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,gianfar-tbi";
+				reg = <0x520 0x20>;
+
+				tbi1: tbi-phy@11 {
+					reg = <0x11>;
+					device_type = "tbi-phy";
+				};
+			};
 		};
 
 		mpic: pic@40000 {
arch/powerpc/boot/dts/mpc8536ds.dts +42 -36

115 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8540ads.dts +63 -54

160 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8541cds.dts +42 -36

108 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8544ds.dts +43 -38

118 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8548cds.dts +84 -72

213 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8555cds.dts +42 -36

108 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8560ads.dts +54 -48

132 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8568mds.dts +54 -48

132 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8572ds.dts +81 -69

210 lines not on this page · raw message

arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts +21 -18
Index: linux-2.6/arch/powerpc/boot/dts/mpc8572ds_camp_core0.dts
===================================================================
@@ -148,35 +148,38 @@
 			};
 		};
 
-		mdio@24520 {
-			#address-cells = <1>;
-			#size-cells = <0>;
-			compatible = "fsl,gianfar-mdio";
-			reg = <0x24520 0x20>;
-
-			phy0: ethernet-phy@0 {
-				interrupt-parent = <&mpic>;
-				interrupts = <10 1>;
-				reg = <0x0>;
-			};
-			phy1: ethernet-phy@1 {
-				interrupt-parent = <&mpic>;
-				interrupts = <10 1>;
-				reg = <0x1>;
-			};
-		};
-
 		enet0: ethernet@24000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
 			cell-index = <0>;
 			device_type = "network";
 			model = "eTSEC";
 			compatible = "gianfar";
 			reg = <0x24000 0x1000>;
+			ranges = <0x0 0x24000 0x1000>;
 			local-mac-address = [ 00 00 00 00 00 00 ];
 			interrupts = <29 2 30 2 34 2>;
 			interrupt-parent = <&mpic>;
 			phy-handle = <&phy0>;
 			phy-connection-type = "rgmii-id";
+
+			mdio@520 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,gianfar-mdio";
+				reg = <0x520 0x20>;
+
+				phy0: ethernet-phy@0 {
+					interrupt-parent = <&mpic>;
+					interrupts = <10 1>;
+					reg = <0x0>;
+				};
+				phy1: ethernet-phy@1 {
+					interrupt-parent = <&mpic>;
+					interrupts = <10 1>;
+					reg = <0x1>;
+				};
+			};
 		};
 
 		enet1: ethernet@25000 {
arch/powerpc/boot/dts/sbc8548.dts +42 -36

108 lines not on this page · raw message

arch/powerpc/boot/dts/sbc8560.dts +53 -47

130 lines not on this page · raw message

arch/powerpc/boot/dts/stx_gp3_8560.dts +42 -36

108 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8540.dts +63 -54

157 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8541.dts +48 -42

120 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8548-bigflash.dts +90 -78

224 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8548.dts +90 -78

224 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8555.dts +48 -42

120 lines not on this page · raw message

arch/powerpc/boot/dts/tqm8560.dts +48 -42

120 lines not on this page · raw message

arch/powerpc/platforms/85xx/ksi8560.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/ksi8560.c
===================================================================
@@ -221,6 +221,7 @@ static struct of_device_id __initdata of
 	{ .type = "simple-bus", },
 	{ .name = "cpm", },
 	{ .name = "localbus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/mpc8536_ds.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/mpc8536_ds.c
===================================================================
@@ -92,6 +92,7 @@ static struct of_device_id __initdata mp
 	{ .type = "soc", },
 	{ .compatible = "soc", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/mpc85xx_ads.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/mpc85xx_ads.c
===================================================================
@@ -226,6 +226,7 @@ static struct of_device_id __initdata of
 	{ .name = "cpm", },
 	{ .name = "localbus", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/mpc85xx_cds.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/mpc85xx_cds.c
===================================================================
@@ -336,6 +336,7 @@ static struct of_device_id __initdata of
 	{ .type = "soc", },
 	{ .compatible = "soc", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/mpc85xx_ds.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/mpc85xx_ds.c
===================================================================
@@ -204,6 +204,7 @@ static struct of_device_id __initdata mp
 	{ .type = "soc", },
 	{ .compatible = "soc", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/mpc85xx_mds.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/mpc85xx_mds.c
===================================================================
@@ -265,6 +265,7 @@ static struct of_device_id mpc85xx_ids[]
 	{ .compatible = "simple-bus", },
 	{ .type = "qe", },
 	{ .compatible = "fsl,qe", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/sbc8548.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/sbc8548.c
===================================================================
@@ -154,6 +154,7 @@ static struct of_device_id __initdata of
 	{ .name = "soc", },
 	{ .type = "soc", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/sbc8560.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/sbc8560.c
===================================================================
@@ -213,6 +213,7 @@ static struct of_device_id __initdata of
 	{ .name = "cpm", },
 	{ .name = "localbus", },
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/stx_gp3.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/stx_gp3.c
===================================================================
@@ -145,6 +145,7 @@ static void stx_gp3_show_cpuinfo(struct 
 
 static struct of_device_id __initdata of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
 
arch/powerpc/platforms/85xx/tqm85xx.c +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/tqm85xx.c
===================================================================
@@ -153,6 +153,7 @@ static void tqm85xx_show_cpuinfo(struct 
 
 static struct of_device_id __initdata of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
+	{ .compatible = "gianfar", },
 	{},
 };
#2 lore raw

PATCH 1/28 RTC: Add support for RX8025 chip.

In reply to Wolfgang Grandegger

This patch adds support for the Epson RX-8025SA/NB RTC chips. It includes support for alarms update interrupts (1 Hz) and clock precision adjustment.

For clock precision adjustment, the SYSFS file "clock_adjust_ppb" gets created in "/sys/class/rtc/rtcX/device". It permits to set and get the clock adjustment in ppb (parts per billion), e.g.:

  # echo -183000 > /sys/class/rtc/rtc0/device/clock_adjust_ppb
  # cat /sys/class/rtc/rtc0/device/clock_adjust_ppb
  -183000

This allows to compensate temperature dependent clock drifts. According to the RX8025 SA/NB application manual the frequency and temperature charateristics can be approximated using the following equation:

df = a * (ut - t)**2

df: Frequency deviation in any temperature a : Coefficient = (-35 +-5) * 10**-9
ut: Ultimate temperature in degree = +25 +-5 degree t : Any temperature in degree

---
 drivers/rtc/Kconfig      |    9 
 drivers/rtc/Makefile     |    1 
 drivers/rtc/rtc-rx8025.c |  891 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 901 insertions(+)
 create mode 100644 drivers/rtc/rtc-rx8025.c
drivers/rtc/Kconfig +9 -0
Index: linux-2.6/drivers/rtc/Kconfig
===================================================================
@@ -295,6 +295,15 @@ config RTC_DRV_RX8581
 	  This driver can also be built as a module. If so the module
 	  will be called rtc-rx8581.
 
+config RTC_DRV_RX8025
+	tristate "Epson RX-8025SA/NB"
+	help
+	  If you say yes here you get support for the Epson
+	  RX-8025SA/NB RTC chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-rx8025.
+
 endif # I2C
 
 comment "SPI RTC drivers"
drivers/rtc/Makefile +1 -0
Index: linux-2.6/drivers/rtc/Makefile
===================================================================
@@ -62,6 +62,7 @@ obj-$(CONFIG_RTC_DRV_R9701)	+= rtc-r9701
 obj-$(CONFIG_RTC_DRV_RS5C313)	+= rtc-rs5c313.o
 obj-$(CONFIG_RTC_DRV_RS5C348)	+= rtc-rs5c348.o
 obj-$(CONFIG_RTC_DRV_RS5C372)	+= rtc-rs5c372.o
+obj-$(CONFIG_RTC_DRV_RX8025)	+= rtc-rx8025.o
 obj-$(CONFIG_RTC_DRV_RX8581)	+= rtc-rx8581.o
 obj-$(CONFIG_RTC_DRV_S35390A)	+= rtc-s35390a.o
 obj-$(CONFIG_RTC_DRV_S3C)	+= rtc-s3c.o
drivers/rtc/rtc-rx8025.c new file +891 -0

891 lines not on this page · raw message

#3 lore raw

PATCH 3/8 powerpc/85xx: Add support for the "socrates" board (MPC8544).

In reply to Wolfgang Grandegger

Supported are Ethernet, serial console, I2C, I2C-based RTC and temperature sensors, NOR and NAND flash, PCI, USB, CAN and Lime display controller.

The multiplexing of FPGA interrupts onto PowerPC interrupt lines is supported through our own fpga_pic interrupt controller driver.

For example the SJA1000 controller is level low sensitive connected to fpga_pic line 2 and is routed to the second (of three) irq lines to the CPU:

    can@3,100 {
            compatible = "philips,sja1000";
            reg = <3 0x100 0x80>;
            interrupts = <2 2>;
            interrupts = <2 8 1>;   // number, type, routing
            interrupt-parent = <&fpga_pic>;
    };
---
 arch/powerpc/boot/dts/socrates.dts              |  338 +++++
 arch/powerpc/configs/85xx/socrates_defconfig    | 1410 ++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/Kconfig             |    6 
 arch/powerpc/platforms/85xx/Makefile            |    1 
 arch/powerpc/platforms/85xx/socrates.c          |  133 ++
 arch/powerpc/platforms/85xx/socrates_fpga_pic.c |  327 +++++
 arch/powerpc/platforms/85xx/socrates_fpga_pic.h |   16 
 7 files changed, 2231 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/socrates.dts
 create mode 100644 arch/powerpc/configs/85xx/socrates_defconfig
 create mode 100644 arch/powerpc/platforms/85xx/socrates.c
 create mode 100644 arch/powerpc/platforms/85xx/socrates_fpga_pic.c
 create mode 100644 arch/powerpc/platforms/85xx/socrates_fpga_pic.h
 create mode 100644 drivers/mtd/nand/socrates_nand.c
arch/powerpc/boot/dts/socrates.dts new file +338 -0
Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================
@@ -0,0 +1,338 @@
+/*
+ * Device Tree Source for the Socrates board (MPC8544).
+ *
+ * Copyright (c) 2008 Emcraft Systems.
+ * Sergei Poselenov, <[email protected]>
+ *
+ * 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;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+/dts-v1/;
+
+/ {
+	model = "abb,socrates";
+	compatible = "abb,socrates";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	aliases {
+		ethernet0 = &enet0;
+		ethernet1 = &enet1;
+		serial0 = &serial0;
+		serial1 = &serial1;
+		pci0 = &pci0;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		PowerPC,8544@0 {
+			device_type = "cpu";
+			reg = <0>;
+			d-cache-line-size = <32>;
+			i-cache-line-size = <32>;
+			d-cache-size = <0x8000>;	// L1, 32K
+			i-cache-size = <0x8000>;	// L1, 32K
+			timebase-frequency = <0>;
+			bus-frequency = <0>;
+			clock-frequency = <0>;
+			next-level-cache = <&L2>;
+		};
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x00000000>;	// Filled in by U-Boot
+	};
+
+	soc8544@e0000000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		ranges = <0x00000000 0xe0000000 0x00100000>;
+		reg = <0xe0000000 0x00001000>;	// CCSRBAR 1M
+		bus-frequency = <0>;		// Filled in by U-Boot
+		compatible = "fsl,mpc8544-immr", "simple-bus";
+
+		memory-controller@2000 {
+			compatible = "fsl,mpc8544-memory-controller";
+			reg = <0x2000 0x1000>;
+			interrupt-parent = <&mpic>;
+			interrupts = <18 2>;
+		};
+
+		L2: l2-cache-controller@20000 {
+			compatible = "fsl,mpc8544-l2-cache-controller";
+			reg = <0x20000 0x1000>;
+			cache-line-size = <32>;
+			cache-size = <0x40000>;	// L2, 256K
+			interrupt-parent = <&mpic>;
+			interrupts = <16 2>;
+		};
+
+		i2c@3000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			cell-index = <0>;
+			compatible = "fsl-i2c";
+			reg = <0x3000 0x100>;
+			interrupts = <43 2>;
+			interrupt-parent = <&mpic>;
+			dfsrr;
+
+			dtt@28 {
+				compatible = "winbond,w83782d";
+				reg = <0x28>;
+			};
+			rtc@32 {
+				compatible = "epson,rx8025";
+				reg = <0x32>;
+				interrupts = <7 1>;
+				interrupt-parent = <&mpic>;
+			};
+			dtt@4c {
+				compatible = "dallas,ds75";
+				reg = <0x4c>;
+			};
+			ts@4a {
+				compatible = "ti,tsc2003";
+				reg = <0x4a>;
+				interrupt-parent = <&mpic>;
+				interrupts = <8 1>;
+			};
+		};
+
+		i2c@3100 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			cell-index = <1>;
+			compatible = "fsl-i2c";
+			reg = <0x3100 0x100>;
+			interrupts = <43 2>;
+			interrupt-parent = <&mpic>;
+			dfsrr;
+		};
+
+		enet0: ethernet@24000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			cell-index = <0>;
+			device_type = "network";
+			model = "eTSEC";
+			compatible = "gianfar";
+			reg = <0x24000 0x1000>;
+			ranges = <0x0 0x24000 0x1000>;
+			local-mac-address = [ 00 00 00 00 00 00 ];
+			interrupts = <29 2 30 2 34 2>;
+			interrupt-parent = <&mpic>;
+			phy-handle = <&phy0>;
+			tbi-handle = <&tbi0>;
+			phy-connection-type = "rgmii-id";
+
+			mdio@520 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,gianfar-mdio";
+				reg = <0x520 0x20>;
+
+				phy0: ethernet-phy@0 {
+					interrupt-parent = <&mpic>;
+					interrupts = <0 1>;
+					reg = <0>;
+				};
+				phy1: ethernet-phy@1 {
+					interrupt-parent = <&mpic>;
+					interrupts = <0 1>;
+					reg = <1>;
+				};
+				tbi0: tbi-phy@11 {
+					reg = <0x11>;
+				};
+			};
+		};
+
+		enet1: ethernet@26000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			cell-index = <1>;
+			device_type = "network";
+			model = "eTSEC";
+			compatible = "gianfar";
+			reg = <0x26000 0x1000>;
+			ranges = <0x0 0x26000 0x1000>;
+			local-mac-address = [ 00 00 00 00 00 00 ];
+			interrupts = <31 2 32 2 33 2>;
+			interrupt-parent = <&mpic>;
+			phy-handle = <&phy1>;
+			tbi-handle = <&tbi1>;
+			phy-connection-type = "rgmii-id";
+
+			mdio@520 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "fsl,gianfar-tbi";
+				reg = <0x520 0x20>;
+
+				tbi1: tbi-phy@11 {
+					reg = <0x11>;
+				};
+			};
+		};
+
+		serial0: serial@4500 {
+			cell-index = <0>;
+			device_type = "serial";
+			compatible = "ns16550";
+			reg = <0x4500 0x100>;
+			clock-frequency = <0>;
+			interrupts = <42 2>;
+			interrupt-parent = <&mpic>;
+		};
+
+		serial1: serial@4600 {
+			cell-index = <1>;
+			device_type = "serial";
+			compatible = "ns16550";
+			reg = <0x4600 0x100>;
+			clock-frequency = <0>;
+			interrupts = <42 2>;
+			interrupt-parent = <&mpic>;
+		};
+
+		global-utilities@e0000 {	//global utilities block
+			compatible = "fsl,mpc8548-guts";
+			reg = <0xe0000 0x1000>;
+			fsl,has-rstcr;
+		};
+
+		mpic: pic@40000 {
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			reg = <0x40000 0x40000>;
+			compatible = "chrp,open-pic";
+			device_type = "open-pic";
+		};
+	};
+
+
+	localbus {
+		compatible = "fsl,mpc8544-localbus",
+		             "fsl,pq3-localbus",
+			     "simple-bus";
+		#address-cells = <2>;
+		#size-cells = <1>;
+		reg = <0xe0005000 0x40>;
+
+		ranges = <0 0 0xfc000000 0x04000000
+			  2 0 0xc8000000 0x04000000
+			  3 0 0xc0000000 0x00100000
+			>; /* Overwritten by U-Boot */
+
+		nor_flash@0,0 {
+			compatible = "amd,s29gl256n", "cfi-flash";
+			bank-width = <2>;
+			reg = <0x0 0x000000 0x4000000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			partition@0 {
+				label = "kernel";
+				reg = <0x0 0x1e0000>;
+				read-only;
+			};
+			partition@1e0000 {
+				label = "dtb";
+				reg = <0x1e0000 0x20000>;
+			};
+			partition@200000 {
+				label = "root";
+				reg = <0x200000 0x200000>;
+			};
+			partition@400000 {
+				label = "user";
+				reg = <0x400000 0x3b80000>;
+			};
+			partition@3f80000 {
+				label = "env";
+				reg = <0x3f80000 0x40000>;
+				read-only;
+			};
+			partition@3fc0000 {
+				label = "u-boot";
+				reg = <0x3fc0000 0x40000>;
+				read-only;
+			};
+		};
+
+		display@2,0 {
+			compatible = "fujitsu,lime";
+			reg = <2 0x0 0x4000000>;
+			interrupt-parent = <&mpic>;
+			interrupts = <6 1>;
+		};
+
+		fpga_pic: fpga-pic@3,10 {
+			compatible = "abb,socrates-fpga-pic";
+			reg = <3 0x10 0x10>;
+			interrupt-controller;
+			/* IRQs 2, 10, 11, active low, level-sensitive */
+			interrupts = <2 1 10 1 11 1>;
+			interrupt-parent = <&mpic>;
+			#interrupt-cells = <3>;
+		};
+
+		spi@3,60 {
+			compatible = "abb,socrates-spi";
+			reg = <3 0x60 0x10>;
+			interrupts = <8 4 0>;	// number, type, routing
+			interrupt-parent = <&fpga_pic>;
+		};
+
+		nand@3,70 {
+			compatible = "abb,socrates-nand";
+			reg = <3 0x70 0x04>;
+			bank-width = <1>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			data@0 {
+				label = "data";
+				reg = <0x0 0x40000000>;
+			};
+		};
+
+		can@3,100 {
+			compatible = "philips,sja1000";
+			reg = <3 0x100 0x80>;
+			interrupts = <2 8 1>;	// number, type, routing
+			interrupt-parent = <&fpga_pic>;
+		};
+	};
+
+	pci0: pci@e0008000 {
+		cell-index = <0>;
+		#interrupt-cells = <1>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+		compatible = "fsl,mpc8540-pci";
+		device_type = "pci";
+		reg = <0xe0008000 0x1000>;
+		clock-frequency = <66666666>;
+
+		interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
+		interrupt-map = <
+				/* IDSEL 0x11 */
+				 0x8800 0x0 0x0 1 &mpic 5 1
+				/* IDSEL 0x12 */
+				 0x9000 0x0 0x0 1 &mpic 4 1>;
+		interrupt-parent = <&mpic>;
+		interrupts = <24 2>;
+		bus-range = <0x0 0x0>;
+		ranges = <0x02000000 0x0 0x80000000 0x80000000 0x0 0x20000000
+			  0x01000000 0x0 0x00000000 0xe2000000 0x0 0x01000000>;
+	};
+
+};
arch/powerpc/configs/85xx/socrates_defconfig new file +1410 -0

1,410 lines not on this page · raw message

arch/powerpc/platforms/85xx/Kconfig +6 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/Kconfig
===================================================================
@@ -51,6 +51,12 @@ config MPC85xx_DS
 	help
 	  This option enables support for the MPC85xx DS (MPC8544 DS) board
 
+config SOCRATES
+	bool "Socrates"
+	select DEFAULT_UIMAGE
+	help
+	  This option enables support for the Socrates board.
+
 config KSI8560
         bool "Emerson KSI8560"
         select DEFAULT_UIMAGE
arch/powerpc/platforms/85xx/Makefile +1 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/Makefile
===================================================================
@@ -13,4 +13,5 @@ obj-$(CONFIG_STX_GP3)	  += stx_gp3.o
 obj-$(CONFIG_TQM85xx)	  += tqm85xx.o
 obj-$(CONFIG_SBC8560)     += sbc8560.o
 obj-$(CONFIG_SBC8548)     += sbc8548.o
+obj-$(CONFIG_SOCRATES)    += socrates.o socrates_fpga_pic.o
 obj-$(CONFIG_KSI8560)	  += ksi8560.o
arch/powerpc/platforms/85xx/socrates.c new file +133 -0

133 lines not on this page · raw message

arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +327 -0

327 lines not on this page · raw message

arch/powerpc/platforms/85xx/socrates_fpga_pic.h new file +16 -0
Index: linux-2.6/arch/powerpc/platforms/85xx/socrates_fpga_pic.h
===================================================================
@@ -0,0 +1,16 @@
+/*
+ *  Copyright (C) 2008 Ilya Yanok, Emcraft Systems
+ *
+ *
+ * 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.
+ *
+ */
+
+#ifndef SOCRATES_FPGA_PIC_H
+#define SOCRATES_FPGA_PIC_H
+
+void socrates_fpga_pic_init(struct device_node *pic);
+
+#endif

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

#5 lore raw

Re: [PATCH 3/8] powerpc/85xx: Add support for the "socrates" board (MPC8544).

Quoted 25 lines · Wolfgang Grandegger

Supported are Ethernet, serial console, I2C, I2C-based RTC and temperature sensors, NOR and NAND flash, PCI, USB, CAN and Lime display controller.

The multiplexing of FPGA interrupts onto PowerPC interrupt lines is supported through our own fpga_pic interrupt controller driver.

For example the SJA1000 controller is level low sensitive connected to fpga_pic line 2 and is routed to the second (of three) irq lines to the CPU:

   can@3,100 {
           compatible = "philips,sja1000";
           reg = <3 0x100 0x80>;
           interrupts = <2 2>;
           interrupts = <2 8 1>;   // number, type, routing interrupt-parent = <&fpga_pic>;
   };

Quoted 3 lines

---
 arch/powerpc/boot/dts/socrates.dts              |  338 +++++ arch/powerpc/configs/85xx/socrates_defconfig    | 1410 ++++++++++++++++++++++++

I always ask this question: Do you really need a board specific defconfig file? We are multiplatform now.

Quoted 5 lines

 arch/powerpc/platforms/85xx/Kconfig             |    6 arch/powerpc/platforms/85xx/Makefile            |    1 arch/powerpc/platforms/85xx/socrates.c          |  133 ++ arch/powerpc/platforms/85xx/socrates_fpga_pic.c |  327 +++++ arch/powerpc/platforms/85xx/socrates_fpga_pic.h |   16

socrates_fpga_pic is only ever going to be used by socrates.c. I'd roll the two socrates.c files into one and eliminate the header file.

Quoted 4 lines

Index: linux-2.6/arch/powerpc/platforms/85xx/socrates_fpga_pic.c
===================================================================

arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +0 -0

[...]

Quoted 12 lines
arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +12 -0
+struct socrates_fpga_irq_info {
+       unsigned int irq_line;
+       int type;
+};
+
+/*
+ * Interrupt routing and type table
+ *
+ * IRQ_TYPE_NONE means the interrupt type is configurable,
+ * otherwise it's fixed to the specified value.
+ */
+static struct socrates_fpga_irq_info fpga_irqs[SOCRATES_FPGA_NUM_IRQS] = {

arch/powerpc/platforms/85xx/socrates_fpga_pic.c line 49

Quoted 10 lines
arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +10 -0
+       [0] = {0, IRQ_TYPE_NONE},
+       [1] = {0, IRQ_TYPE_LEVEL_HIGH},
+       [2] = {0, IRQ_TYPE_LEVEL_LOW},
+       [3] = {0, IRQ_TYPE_NONE},
+       [4] = {0, IRQ_TYPE_NONE},
+       [5] = {0, IRQ_TYPE_NONE},
+       [6] = {0, IRQ_TYPE_NONE},
+       [7] = {0, IRQ_TYPE_NONE},
+       [8] = {0, IRQ_TYPE_LEVEL_HIGH},
+};

It is good practice to use named elements in initializers: {.type = IRQ_TYPE_LEVEL_HIGH},

Static variables are initialized to zero. Everything that is 0 can be dropped from this initializer (lines 0 and 3-7, and the irq_line field).

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#6 lore raw

Re: [PATCH 3/8] powerpc/85xx: Add support for the "socrates" board (MPC8544).

Hi Grant,

Quoted 73 lines · Grant Likely
Quoted 25 lines · Wolfgang Grandegger

Supported are Ethernet, serial console, I2C, I2C-based RTC and temperature sensors, NOR and NAND flash, PCI, USB, CAN and Lime display controller.

The multiplexing of FPGA interrupts onto PowerPC interrupt lines is supported through our own fpga_pic interrupt controller driver.

For example the SJA1000 controller is level low sensitive connected to fpga_pic line 2 and is routed to the second (of three) irq lines to the CPU:

   can@3,100 {
           compatible = "philips,sja1000";
           reg = <3 0x100 0x80>;
           interrupts = <2 2>;
           interrupts = <2 8 1>;   // number, type, routing
           interrupt-parent = <&fpga_pic>;
   };
Quoted 3 lines
---
 arch/powerpc/boot/dts/socrates.dts              |  338 +++++
 arch/powerpc/configs/85xx/socrates_defconfig    | 1410 ++++++++++++++++++++++++

I always ask this question: Do you really need a board specific defconfig file? We are multiplatform now.

Quoted 5 lines
 arch/powerpc/platforms/85xx/Kconfig             |    6
 arch/powerpc/platforms/85xx/Makefile            |    1
 arch/powerpc/platforms/85xx/socrates.c          |  133 ++
 arch/powerpc/platforms/85xx/socrates_fpga_pic.c |  327 +++++
 arch/powerpc/platforms/85xx/socrates_fpga_pic.h |   16

socrates_fpga_pic is only ever going to be used by socrates.c. I'd roll the two socrates.c files into one and eliminate the header file.

Quoted 4 lines

Index: linux-2.6/arch/powerpc/platforms/85xx/socrates_fpga_pic.c
===================================================================

arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +0 -0

[...]

Quoted 12 lines
arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +12 -0
+struct socrates_fpga_irq_info {
+       unsigned int irq_line;
+       int type;
+};
+
+/*
+ * Interrupt routing and type table
+ *
+ * IRQ_TYPE_NONE means the interrupt type is configurable,
+ * otherwise it's fixed to the specified value.
+ */
+static struct socrates_fpga_irq_info fpga_irqs[SOCRATES_FPGA_NUM_IRQS] = {

arch/powerpc/platforms/85xx/socrates_fpga_pic.c line 49

Quoted 10 lines
arch/powerpc/platforms/85xx/socrates_fpga_pic.c new file +10 -0
+       [0] = {0, IRQ_TYPE_NONE},
+       [1] = {0, IRQ_TYPE_LEVEL_HIGH},
+       [2] = {0, IRQ_TYPE_LEVEL_LOW},
+       [3] = {0, IRQ_TYPE_NONE},
+       [4] = {0, IRQ_TYPE_NONE},
+       [5] = {0, IRQ_TYPE_NONE},
+       [6] = {0, IRQ_TYPE_NONE},
+       [7] = {0, IRQ_TYPE_NONE},
+       [8] = {0, IRQ_TYPE_LEVEL_HIGH},
+};

It is good practice to use named elements in initializers: {.type = IRQ_TYPE_LEVEL_HIGH},

Quoted 3 lines

Static variables are initialized to zero. Everything that is 0 can be dropped from this initializer (lines 0 and 3-7, and the irq_line field).

Right, missed that.

This is one of the patches I sent accidentally. I think Kumar already applied it to his tree.

Sorry for the noise.

Wolfgang.

#7 lore raw

PATCH 4/8 powerpc: i2c-mpc: preserve I2C clocking

In reply to Wolfgang Grandegger

The I2c node property "fsl,preserve-clocking" allows to overtake the clock settings from the boot loader and avoids the hard-coded setting.

---
 drivers/i2c/busses/i2c-mpc.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-mpc.c +16 -8
Index: linux-2.6/drivers/i2c/busses/i2c-mpc.c
===================================================================
@@ -318,17 +318,24 @@
 {
 	int result = 0;
 	struct mpc_i2c *i2c;
+	int set_clock;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
 		return -ENOMEM;
 
-	if (of_get_property(op->node, "dfsrr", NULL))
-		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-	if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
-			of_device_is_compatible(op->node, "mpc5200-i2c"))
-		i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
+	if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) {
+		set_clock = 0;
+	} else {
+		set_clock = 1;
+
+		if (of_get_property(op->node, "dfsrr", NULL))
+			i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
+
+		if (of_device_is_compatible(op->node, "fsl,mpc5200-i2c") ||
+		    of_device_is_compatible(op->node, "mpc5200-i2c"))
+			i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
+	}
 
 	init_waitqueue_head(&i2c->queue);
 
@@ -348,8 +355,9 @@
 			goto fail_request;
 		}
 	}
-	
-	mpc_i2c_setclock(i2c);
+
+	if (set_clock)
+		mpc_i2c_setclock(i2c);
 
 	dev_set_drvdata(&op->dev, i2c);
#8 lore raw

PATCH 5/8 powerpc: i2c-mpc: make I2C bus speed configurable

In reply to Wolfgang Grandegger

This patch makes the I2C bus speed configurable by using the I2C node property "clock-frequency". If the property is not defined, the old fixed clock settings will be used for backward comptibility.

The generic I2C clock properties, especially the CPU-specific source clock pre-scaler are defined via the OF match table:

  static const struct of_device_id mpc_i2c_of_match[] = {
	{.compatible = "fsl,mpc5200b-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc5200-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc8313-i2c",
	 .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, },
	{.compatible = "fsl,mpc8543-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV2), },
	{.compatible = "fsl,mpc8544-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV23), },
	/* Backward compatibility */
	{.compatible = "fsl-i2c", },
	{},

};

The "data" field defines the relevant I2C flags for the comptible CPU.

It used arch-specific tables and functions to determine the proper Freqency Divider Register (fdr).

Furthermore dev_dbg() and dev_info() are now used to profit from a more comprehensive output.

---
 arch/powerpc/platforms/52xx/mpc52xx_common.c |   48 ++++++++++++
 arch/powerpc/sysdev/fsl_soc.c                |   90 +++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c                 |  104 +++++++++++++++++++--------
 include/linux/fsl_devices.h                  |    6 +
 4 files changed, 221 insertions(+), 27 deletions(-)
drivers/i2c/busses/i2c-mpc.c +77 -27
Index: linux-2.6/drivers/i2c/busses/i2c-mpc.c
===================================================================
@@ -20,12 +20,14 @@
 #include <linux/of_platform.h>
 #include <linux/of_i2c.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/fsl_devices.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 
+#include <sysdev/fsl_soc.h>
+
 #define DRV_NAME "mpc-i2c"
 
 #define MPC_I2C_FDR 	0x04
@@ -50,6 +52,7 @@
 #define CSR_RXAK 0x01
 
 struct mpc_i2c {
+	struct device *dev;
 	void __iomem *base;
 	u32 interrupt;
 	wait_queue_head_t queue;
@@ -105,7 +108,7 @@
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
+				dev_dbg(i2c->dev, "timeout\n");
 				writeccr(i2c, 0);
 				result = -EIO;
 				break;
@@ -119,10 +122,10 @@
 			(i2c->interrupt & CSR_MIF), timeout * HZ);
 
 		if (unlikely(result < 0)) {
-			pr_debug("I2C: wait interrupted\n");
+			dev_dbg(i2c->dev, "wait interrupted\n");
 			writeccr(i2c, 0);
 		} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
-			pr_debug("I2C: wait timeout\n");
+			dev_dbg(i2c->dev, "wait timeout\n");
 			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
 		}
@@ -135,17 +138,17 @@
 		return result;
 
 	if (!(x & CSR_MCF)) {
-		pr_debug("I2C: unfinished\n");
+		dev_dbg(i2c->dev, "unfinished\n");
 		return -EIO;
 	}
 
 	if (x & CSR_MAL) {
-		pr_debug("I2C: MAL\n");
+		dev_dbg(i2c->dev, "MAL\n");
 		return -EIO;
 	}
 
 	if (writing && (x & CSR_RXAK)) {
-		pr_debug("I2C: No RXAK\n");
+		dev_dbg(i2c->dev, "No RXAK\n");
 		/* generate stop */
 		writeccr(i2c, CCR_MEN);
 		return -EIO;
@@ -153,17 +156,38 @@
 	return 0;
 }
 
-static void mpc_i2c_setclock(struct mpc_i2c *i2c)
+static void mpc_i2c_setclock(struct device_node *node,
+			     struct mpc_i2c *i2c, u32 clock)
 {
-	/* Set clock and filters */
-	if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
-		writeb(0x31, i2c->base + MPC_I2C_FDR);
-		writeb(0x10, i2c->base + MPC_I2C_DFSRR);
-	} else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
-		writeb(0x3f, i2c->base + MPC_I2C_FDR);
-	else
-		writel(0x1031, i2c->base + MPC_I2C_FDR);
-}
+	int fdr;
+
+	fdr = fsl_i2c_get_fdr(node, clock, i2c->flags);
+
+	if (i2c->flags & FSL_I2C_DEV_CLOCK_5200) {
+		pr_debug("I2C: old fdr=%d\n", readb(i2c->base + MPC_I2C_FDR));
+		if (fdr < 0)
+			fdr = 0x3f; /* backward compatibility */
+		writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+		dev_info("clock %d Hz (fdr=%d)\n", clock, fdr);
+	} else {
+		if (fdr < 0)
+			fdr = 0x1031; /* backward compatibility */
+		if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
+			pr_debug("I2C: old dfsrr=%d fdr=%d\n",
+			       readb(i2c->base + MPC_I2C_DFSRR),
+			       readb(i2c->base + MPC_I2C_FDR));
+			writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
+			writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
+			dev_info("clock %d Hz (dfsrr=%d fdr=%d)\n",
+			       clock, fdr >> 8, fdr & 0xff);
+		} else {
+			pr_debug("I2C: old fdr=%d\n",
+				 readl(i2c->base + MPC_I2C_FDR));
+			writel(fdr & 0xffff, i2c->base + MPC_I2C_FDR);
+			dev_info("clock %d Hz (fdr=%d)\n", clock, fdr);
+		}
+	}
+ }
 
 static void mpc_i2c_start(struct mpc_i2c *i2c)
 {
@@ -267,12 +291,12 @@
 	/* Allow bus up to 1s to become not busy */
 	while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
 		if (signal_pending(current)) {
-			pr_debug("I2C: Interrupted\n");
+			dev_dbg(i2c->dev, "interrupted\n");
 			writeccr(i2c, 0);
 			return -EINTR;
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {
-			pr_debug("I2C: timeout\n");
+			dev_dbg(i2c->dev, "timeout\n");
 			if (readb(i2c->base + MPC_I2C_SR) ==
 			    (CSR_MCF | CSR_MBB | CSR_RXAK))
 				mpc_i2c_fixup(i2c);
@@ -283,9 +307,10 @@
 
 	for (i = 0; ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
-		pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-			 pmsg->flags & I2C_M_RD ? "read" : "write",
-			 pmsg->len, pmsg->addr, i + 1, num);
+		dev_dbg(i2c->dev,
+			"doing %s %d bytes to 0x%02x - %d of %d messages\n",
+			pmsg->flags & I2C_M_RD ? "read" : "write",
+			pmsg->len, pmsg->addr, i + 1, num);
 		if (pmsg->flags & I2C_M_RD)
 			ret =
 			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
@@ -316,9 +341,12 @@
 
 static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
 {
-	int result = 0;
 	struct mpc_i2c *i2c;
+	const u32 *prop;
+	u32 clock = 0;
 	int set_clock;
+	int result = 0;
+	int plen;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
@@ -328,7 +356,11 @@
 		set_clock = 0;
 	} else {
 		set_clock = 1;
+		prop = of_get_property(op->node, "clock-frequency", &plen);
+		if (prop && plen == sizeof(u32))
+			clock = *prop;
 
+		/* Backwards compatibility */
 		if (of_get_property(op->node, "dfsrr", NULL))
 			i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
 
@@ -356,11 +388,15 @@
 		}
 	}
 
-	if (set_clock)
-		mpc_i2c_setclock(i2c);
+	if (set_clock) {
+		if (match->data)
+			i2c->flags = (u32)match->data;
+		mpc_i2c_setclock(op->node, i2c, clock);
+	}
 
 	dev_set_drvdata(&op->dev, i2c);
 
+	i2c->dev = &op->dev;
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = &op->dev;
@@ -402,9 +438,23 @@
 };
 
 static const struct of_device_id mpc_i2c_of_match[] = {
-	{.compatible = "fsl-i2c",},
+	{.compatible = "fsl,mpc5200b-i2c",
+	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
+	{.compatible = "fsl,mpc5200-i2c",
+	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
+	{.compatible = "fsl,mpc8313-i2c",
+	 .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, },
+	{.compatible = "fsl,mpc8543-i2c",
+	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
+			  FSL_I2C_DEV_CLOCK_DIV2), },
+	{.compatible = "fsl,mpc8544-i2c",
+	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
+			  FSL_I2C_DEV_CLOCK_DIV23), },
+	/* Backward compatibility */
+	{.compatible = "fsl-i2c", },
 	{},
 };
+
 MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
 
 
@@ -425,7 +475,7 @@
 
 	rv = of_register_platform_driver(&mpc_i2c_driver);
 	if (rv)
-		printk(KERN_ERR DRV_NAME 
+		printk(KERN_ERR DRV_NAME
 		       " of_register_platform_driver failed (%i)\n", rv);
 	return rv;
 }
arch/powerpc/sysdev/fsl_soc.c +90 -0

96 lines not on this page · raw message

include/linux/fsl_devices.h +6 -0
Index: linux-2.6/include/linux/fsl_devices.h
===================================================================
@@ -68,6 +68,12 @@
 /* Flags related to I2C device features */
 #define FSL_I2C_DEV_SEPARATE_DFSRR	0x00000001
 #define FSL_I2C_DEV_CLOCK_5200		0x00000002
+#define FSL_I2C_DEV_CLOCK_DIV2		0x00000004
+#define FSL_I2C_DEV_CLOCK_DIV3		0x00000008
+#define FSL_I2C_DEV_CLOCK_DIV23		0x00000010
+
+extern int fsl_i2c_get_fdr(struct device_node *node,
+			   u32 i2c_clock, u32 i2c_flags);
 
 enum fsl_usb2_operating_modes {
 	FSL_USB2_MPH_HOST,
arch/powerpc/platforms/52xx/mpc52xx_common.c +48 -0

51 lines not on this page · raw message

#9 lore raw
Quoted 16 lines · Wolfgang Grandegger

This patch makes the I2C bus speed configurable by using the I2C node property "clock-frequency". If the property is not defined, the old fixed clock settings will be used for backward comptibility.

The generic I2C clock properties, especially the CPU-specific source clock pre-scaler are defined via the OF match table:

 static const struct of_device_id mpc_i2c_of_match[] = { {.compatible = "fsl,mpc5200b-i2c",
        .data = (void *)FSL_I2C_DEV_CLOCK_5200, }, {.compatible = "fsl,mpc5200-i2c",
        .data = (void *)FSL_I2C_DEV_CLOCK_5200, }, {.compatible = "fsl,mpc8313-i2c",
        .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, }, {.compatible = "fsl,mpc8543-i2c",
        .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |

Quoted 8 lines

                         FSL_I2C_DEV_CLOCK_DIV2), }, {.compatible = "fsl,mpc8544-i2c", .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR | FSL_I2C_DEV_CLOCK_DIV23), }, /* Backward compatibility */ {.compatible = "fsl-i2c", },
       {},
 };

Instead passing in a flag (and using an ugly cast to do it) which is then checked inside the mpc_i2c_setclock(), you should do this instead:

struct fsl_i2c_match_data {
int static void *(setclock)(struct device_node *node, struct

mpc_i2c *i2c, u32 clock);
        int flags;
        /* Other stuff can go here */
};
static const struct of_device_id mpc_i2c_of_match[] = {
        {.compatible = "fsl,mpc5200b-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_mpc5200, },
        },
        {.compatible = "fsl,mpc5200-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_mpc5200, },
        },
        {.compatible = "fsl,mpc8313-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
        },
        {.compatible = "fsl,mpc8543-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
         .flags = FSL_I2C_DEV_CLOCK_DIV2,
        },
        {.compatible = "fsl,mpc8544-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
         .flags = FSL_I2C_DEV_CLOCK_DIV23,
        },
        /* Backward compatibility */
        {.compatible = "fsl-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock, },
        },
        {},

};

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code. It also adds lets the compiler do more type checking for you.

Also, this ...

arch/powerpc/sysdev/fsl_soc.c     2009-03-31 13:34:40.531721011 +0200

Quoted 7 lines
arch/powerpc/sysdev/fsl_soc.c     2009-03-31 13:34:40.531721011 +0200 renamed from arch/powerpc/sysdev/fsl_soc.c        2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

... and this ...

arch/powerpc/platforms/52xx/mpc52xx_common.c      2009-03-31 13:28:54.309718526 +0200

Quoted 7 lines
arch/powerpc/platforms/52xx/mpc52xx_common.c      2009-03-31 13:28:54.309718526 +0200 renamed from arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

does not work on a multiplatform kernel. Both 8xxx and 52xx support can be selected at the same time.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#10 lore raw
Quoted 67 lines · Grant Likely
Quoted 23 lines · Wolfgang Grandegger

This patch makes the I2C bus speed configurable by using the I2C node property "clock-frequency". If the property is not defined, the old fixed clock settings will be used for backward comptibility.

The generic I2C clock properties, especially the CPU-specific source clock pre-scaler are defined via the OF match table:

 static const struct of_device_id mpc_i2c_of_match[] = {
       {.compatible = "fsl,mpc5200b-i2c",
        .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
       {.compatible = "fsl,mpc5200-i2c",
        .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
       {.compatible = "fsl,mpc8313-i2c",
        .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, },
       {.compatible = "fsl,mpc8543-i2c",
        .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
                         FSL_I2C_DEV_CLOCK_DIV2), },
       {.compatible = "fsl,mpc8544-i2c",
        .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
                         FSL_I2C_DEV_CLOCK_DIV23), },
       /* Backward compatibility */
       {.compatible = "fsl-i2c", },
       {},
Quoted 1 line

};

Instead passing in a flag (and using an ugly cast to do it) which is then checked inside the mpc_i2c_setclock(), you should do this instead:

struct fsl_i2c_match_data {
int static void *(setclock)(struct device_node *node, struct

mpc_i2c *i2c, u32 clock);
        int flags;
        /* Other stuff can go here */
};
static const struct of_device_id mpc_i2c_of_match[] = {
        {.compatible = "fsl,mpc5200b-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_mpc5200, },
        },
        {.compatible = "fsl,mpc5200-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_mpc5200, },
        },
        {.compatible = "fsl,mpc8313-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
        },
        {.compatible = "fsl,mpc8543-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
         .flags = FSL_I2C_DEV_CLOCK_DIV2,
        },
        {.compatible = "fsl,mpc8544-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock_separate_dfsrr, },
         .flags = FSL_I2C_DEV_CLOCK_DIV23,
        },
        /* Backward compatibility */
        {.compatible = "fsl-i2c",
         .data = (struct fsl_i2c_match_data[]) { .setclock =
mpc_i2c_setclock, },
        },
        {},
Quoted 5 lines

};

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code. It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

Quoted 12 lines

Also, this ...

arch/powerpc/sysdev/fsl_soc.c 2009-03-31 13:34:40.531721011 +0200

Quoted 7 lines
arch/powerpc/sysdev/fsl_soc.c 2009-03-31 13:34:40.531721011 +0200 renamed from arch/powerpc/sysdev/fsl_soc.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

... and this ...

Quoted 10 lines

arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200

Quoted 7 lines
arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200 renamed from arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

does not work on a multiplatform kernel. Both 8xxx and 52xx support can be selected at the same time.

OK, then we need different functions including stubs.

Wolfgang.

#11 lore raw
Quoted 11 lines · Wolfgang Grandegger
Quoted 3 lines · Grant Likely

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code.  It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

I don't understand why you don't like it. It's an elegant solution and it simplifies the code somewhat. After grabbing the callback pointer the compatibility code can simply override it. But I won't belabor the point or oppose the patch if you stick with the flags pointer.

Quoted 11 lines
Quoted 10 lines

arch/powerpc/platforms/52xx/mpc52xx_common.c      2009-03-31 13:28:54.309718526 +0200

Quoted 7 lines
arch/powerpc/platforms/52xx/mpc52xx_common.c      2009-03-31 13:28:54.309718526 +0200 renamed from arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

does not work on a multiplatform kernel.  Both 8xxx and 52xx support can be selected at the same time.

Quoted 1 line

OK, then we need different functions including stubs.

I've been thinking about this more. These tables are only ever going to be used by the i2c_mpc driver and so really they are a part of the i2c_mpc driver itself. Putting them into common code doesn't make any sense because it is not common code. I will not merge a patch that puts them into mpc5200 common code.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): fa686aa40904010630l798528efh465a7543a15f50e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#13 lore raw
Quoted 12 lines · Grant Likely
Quoted 10 lines · Wolfgang Grandegger
Quoted 3 lines · Grant Likely

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code. It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

Quoted 5 lines

I don't understand why you don't like it. It's an elegant solution and it simplifies the code somewhat. After grabbing the callback pointer the compatibility code can simply override it. But I won't belabor the point or oppose the patch if you stick with the flags pointer.

I changed my mind ;-). Have a look to PATCH v2 I sent out a few minutes ago.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200

Quoted 7 lines
arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200 renamed from arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

does not work on a multiplatform kernel. Both 8xxx and 52xx support can be selected at the same time.

Quoted 7 lines
Quoted 1 line

OK, then we need different functions including stubs.

I've been thinking about this more. These tables are only ever going to be used by the i2c_mpc driver and so really they are a part of the i2c_mpc driver itself. Putting them into common code doesn't make any sense because it is not common code. I will not merge a patch that puts them into mpc5200 common code.

It's not common code, I agree. How about putting it into mpc52xx_i2c.c and use:

  $ cat Makefile
  obj-$(CONFIG_I2C_MPC) += mpc52xx_i2c.o

Or it could be moved back to the i2c_mpc driver and we add stubs for the functions to get the bus frequency, or use #ifdef's.

Wolfgang.

#14 lore raw
Quoted 36 lines · Wolfgang Grandegger
Quoted 11 lines · Grant Likely
Quoted 10 lines · Wolfgang Grandegger
Quoted 3 lines · Grant Likely

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code. It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

Quoted 5 lines

I don't understand why you don't like it. It's an elegant solution and it simplifies the code somewhat. After grabbing the callback pointer the compatibility code can simply override it. But I won't belabor the point or oppose the patch if you stick with the flags pointer.

I changed my mind ;-). Have a look to PATCH v2 I sent out a few minutes ago.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200

Quoted 7 lines
arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:28:54.309718526 +0200 renamed from arch/powerpc/platforms/52xx/mpc52xx_common.c 2009-03-31 13:25:08.000000000 +0200 +4 -0
+int fsl_i2c_get_fdr(struct device_node *node, u32 i2c_clock, u32 i2c_flags)
+{
[...]
+}
+EXPORT_SYMBOL(fsl_i2c_get_fdr);

does not work on a multiplatform kernel. Both 8xxx and 52xx support can be selected at the same time.

Quoted 6 lines
Quoted 1 line

OK, then we need different functions including stubs.

I've been thinking about this more. These tables are only ever going to be used by the i2c_mpc driver and so really they are a part of the i2c_mpc driver itself. Putting them into common code doesn't make any sense because it is not common code. I will not merge a patch that puts them into mpc5200 common code.

Quoted 5 lines

It's not common code, I agree. How about putting it into mpc52xx_i2c.c and use:

  $ cat Makefile
  obj-$(CONFIG_I2C_MPC) += mpc52xx_i2c.o

That not a good idea either. I just checked the I2C interface of the MPC512x and it can use the same table then the MPC5200B.

Wolfgang.

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

#16 lore raw
Quoted 13 lines · Wolfgang Grandegger
Quoted 12 lines · Grant Likely
Quoted 10 lines · Wolfgang Grandegger
Quoted 3 lines · Grant Likely

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code.  It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

Quoted 7 lines
Quoted 5 lines

I don't understand why you don't like it.  It's an elegant solution and it simplifies the code somewhat.  After grabbing the callback pointer the compatibility code can simply override it.  But I won't belabor the point or oppose the patch if you stick with the flags pointer.

I changed my mind ;-). Have a look to PATCH v2 I sent out a few minutes ago.

I saw and I like. :-)

Quoted 6 lines
Quoted 5 lines

I've been thinking about this more.  These tables are only ever going to be used by the i2c_mpc driver and so really they are a part of the i2c_mpc driver itself.  Putting them into common code doesn't make any sense because it is not common code.  I will not merge a patch that puts them into mpc5200 common code.

Quoted 8 lines

It's not common code, I agree. How about putting it into mpc52xx_i2c.c and use:

 $ cat Makefile
 obj-$(CONFIG_I2C_MPC) += mpc52xx_i2c.o

Or it could be moved back to the i2c_mpc driver and we add stubs for the functions to get the bus frequency, or use #ifdef's.

I'm happy with either as long as it lives in the same directory as the i2c_mpc driver, and as long as the i2c maintainers are okay with it. Oh, and if you use a separate file it should be statically linked into the i2c_mpc module using the i2c_mpc-$(CONFIG_WHATEVER) trick. No EXPORT_SYMBOLS should be needed.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

A message that is not in the archive (sent off-list or not yet received): fa686aa40904010655i73819214m795939e784889267-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#18 lore raw
Quoted 30 lines · Grant Likely
Quoted 12 lines · Wolfgang Grandegger
Quoted 11 lines · Grant Likely
Quoted 10 lines · Wolfgang Grandegger
Quoted 3 lines · Grant Likely

The table definition is more verbose this way, but I think it results in more understandable and easier to extend code. It also adds lets the compiler do more type checking for you.

OK but I don't like the callback function to do the settings. We need backward compatibility with old DTS files including the ugly "dfsrr" property, right? Then it seems consequent to continue using i2c->flags for that purpose and not to introduce another method. If we don't need backward compatibility, we could drop the flags completely and just use callback functions.

Quoted 6 lines
Quoted 5 lines

I don't understand why you don't like it. It's an elegant solution and it simplifies the code somewhat. After grabbing the callback pointer the compatibility code can simply override it. But I won't belabor the point or oppose the patch if you stick with the flags pointer.

I changed my mind ;-). Have a look to PATCH v2 I sent out a few minutes ago.

I saw and I like. :-)

Quoted 8 lines
Quoted 5 lines

I've been thinking about this more. These tables are only ever going to be used by the i2c_mpc driver and so really they are a part of the i2c_mpc driver itself. Putting them into common code doesn't make any sense because it is not common code. I will not merge a patch that puts them into mpc5200 common code.

It's not common code, I agree. How about putting it into mpc52xx_i2c.c and use:

Quoted 8 lines
Quoted 5 lines
 $ cat Makefile
 obj-$(CONFIG_I2C_MPC) += mpc52xx_i2c.o

Or it could be moved back to the i2c_mpc driver and we add stubs for the functions to get the bus frequency, or use #ifdef's.

I'm happy with either as long as it lives in the same directory as the i2c_mpc driver, and as long as the i2c maintainers are okay with it.

Ben, any preference here? See also below.

Quoted 3 lines

Oh, and if you use a separate file it should be statically linked into the i2c_mpc module using the i2c_mpc-$(CONFIG_WHATEVER) trick. No EXPORT_SYMBOLS should be needed.

Yep, then we would have in "drivers/i2c/busses/Makefile"

  obj-$(CONFIG_I2C_MPC)           += i2c-mpc.o
    i2c-mpc-y = i2c-mpc.o
    i2c-mpc-$(CONFIG_FSL_SOC) += i2c-mpc-8xxx.o
    i2c-mpc-$(CONFIG_PPC_52xx) += i2c-mpc-52xx.o

And a common include file i2c-mpc.h including the stubs for the arch dependent functions. But we may get in trouble when we need support for the MPC512x. I currently tend to add the FDR related code to an extra file i2c-mpc-fdr.c, plus i2c-mpc.h and use the good old #ifdef's to select the relevant code.

Wolfgang.

#19 lore raw

PATCH 6/8 --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

In reply to Wolfgang Grandegger
arch/powerpc/boot/dts/socrates.dts +7 -2
Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";
 
 		ranges = <0x00000000 0xe0000000 0x00100000>;
 		reg = <0xe0000000 0x00001000>;	// CCSRBAR 1M
@@ -78,10 +79,11 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <0>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3000 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
+			clock-frequency = <103000>;
 			dfsrr;
 
 			dtt@28 {
@@ -110,10 +112,12 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 			cell-index = <1>;
-			compatible = "fsl-i2c";
+			compatible = "fsl,mpc8544-i2c", "fsl-i2c";
 			reg = <0x3100 0x100>;
 			interrupts = <43 2>;
 			interrupt-parent = <&mpic>;
+			fsl,preserve-clocking;
+			clock-frequency = <400000>;
 			dfsrr;
 		};
 
@@ -207,6 +211,7 @@
 			compatible = "fsl,mpc8548-guts";
 			reg = <0xe0000 0x1000>;
 			fsl,has-rstcr;
+			fsl,has-sec-cfg;
 		};
 
 		mpic: pic@40000 {
#20 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#21 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

Hi David,

this patch went out by mistake, sorry.

Quoted 14 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it. Removing it would also break U-Boot compatibility. Is it worth that? The issue is discussed on the thread
http://ozlabs.org/pipermail/linuxppc-dev/2009-April/070020.html.

Wolfgang.

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

#23 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

Quoted 20 lines · Wolfgang Grandegger

Hi David,

this patch went out by mistake, sorry.

Quoted 14 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

Quoted 2 lines

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it.

Um.. what? Some mpc85xx? This is the dts for *one specific board*, I don't see how something that affects "some mpc85xx" is relevant.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#24 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

Quoted 19 lines · David Gibson
Quoted 18 lines · Wolfgang Grandegger

Hi David,

this patch went out by mistake, sorry.

Quoted 13 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

Quoted 5 lines
Quoted 2 lines

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it.

Um.. what? Some mpc85xx? This is the dts for *one specific board*, I don't see how something that affects "some mpc85xx" is relevant.

Well, to be more precise, it affects all boards using CONFIG_FSL_SOC because they use functions searching for the device type "soc", e.g. fsl_get_sys_freq():

http://lxr.linux.no/linux+v2.6.29/arch/powerpc/sysdev/fsl_soc.c#L80

This needs to be fixed before the line 'device_type = "soc"' can be removed.

Wolfgang.

#25 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

Quoted 26 lines · Wolfgang Grandegger
Quoted 19 lines · David Gibson
Quoted 18 lines · Wolfgang Grandegger

Hi David,

this patch went out by mistake, sorry.

Quoted 13 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

Quoted 5 lines
Quoted 2 lines

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it.

Um.. what? Some mpc85xx? This is the dts for *one specific board*, I don't see how something that affects "some mpc85xx" is relevant.

Quoted 7 lines

Well, to be more precise, it affects all boards using CONFIG_FSL_SOC because they use functions searching for the device type "soc", e.g. fsl_get_sys_freq():

http://lxr.linux.no/linux+v2.6.29/arch/powerpc/sysdev/fsl_soc.c#L80

This needs to be fixed before the line 'device_type = "soc"' can be removed.

Gah. I had been under the impression that had been fixed already. Kumar! Get your house in order!

Ok, I guess it will have to stay for now, just as long as the new style marker in compatible is there as well.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#26 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

In reply to David Gibson
Quoted 21 lines · David Gibson
Quoted 20 lines · Wolfgang Grandegger

Hi David,

this patch went out by mistake, sorry.

Quoted 14 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

Quoted 5 lines
Quoted 2 lines

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it.

Um.. what? Some mpc85xx? This is the dts for *one specific board*, I don't see how something that affects "some mpc85xx" is relevant.

Not some, but *all* mpc85xx. The thing is that U-Boot is searching for device_type = "soc" to fixup some properties (for example, bus-frequency) for all mpc85xx parts, so you can't easily remove the device_type w/o breaking boot for firmwares that customers have pre-programmed in their products.

Note that upgrading firmware without JTAG is dangerous, so it's not an option to "force" everybody to upgrade their firmware just because we want to remove some cruft from the device tree.

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#27 lore raw

Re: [PATCH 6/8] --- arch/powerpc/boot/dts/socrates.dts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)

Quoted 25 lines · Anton Vorontsov
Quoted 24 lines · David Gibson
Quoted 22 lines · Wolfgang Grandegger

Hi David,

this patch went out by mistake, sorry.

Quoted 14 lines · David Gibson

arch/powerpc/boot/dts/socrates.dts line 55

Quoted 9 lines · Wolfgang Grandegger

Index: linux-2.6/arch/powerpc/boot/dts/socrates.dts
===================================================================

arch/powerpc/boot/dts/socrates.dts +1 -0
@@ -52,6 +52,7 @@
 	soc8544@e0000000 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		device_type = "soc";

You should not be adding device_type to a new board's dts. You *especially* shouldn't be doing that with no patch comment explaining why.

In the final patch I have removed the device_type = "soc", but it makes trouble as some mpc85xx rely on it.

Quoted 8 lines
Quoted 2 lines

Um.. what? Some mpc85xx? This is the dts for *one specific board*, I don't see how something that affects "some mpc85xx" is relevant.

Not some, but *all* mpc85xx. The thing is that U-Boot is searching for device_type = "soc" to fixup some properties (for example, bus-frequency) for all mpc85xx parts, so you can't easily remove the device_type w/o breaking boot for firmwares that customers have pre-programmed in their products.

I thought that was fixed in current u-boot versions.

Quoted 3 lines

Note that upgrading firmware without JTAG is dangerous, so it's not an option to "force" everybody to upgrade their firmware just because we want to remove some cruft from the device tree.

I realise that, but again this is a *new board*, which presumably can use an up-to-date u-boot version.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#28 lore raw

[PATCH 7/8] Re: [PATCH 1/2] NAND: Add support for oob size 128

In reply to Wolfgang Grandegger
Quoted 2 lines · * Wolfgang Grandegger | 2009-03-25 11:48:37 [+0100]:

You seem to forgot a few bits (subpage_sft & max page size). I had this patch in my tree like for ever and forgot post it here. I did however merge the mtd-utils bits allready :)

From: Thomas Gleixner <[email protected]>
Date: Wed, 12 Dec 2007 17:27:03 +0100
Subject: [PATCH 7/8] [PATCH] [MTD] Add support for 4k pages.

---
 drivers/mtd/nand/nand_base.c |   18 ++++++++++++++++++
 include/linux/mtd/nand.h     |    4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_base.c +18 -0
Index: linux-2.6/drivers/mtd/nand/nand_base.c
===================================================================
@@ -82,6 +82,20 @@
 		 .length = 38}}
 };
 
+static struct nand_ecclayout nand_oob_128 = {
+	.eccbytes = 48,
+	.eccpos = {
+		   80, 81, 82, 83, 84, 85, 86, 87,
+		   88, 89, 90, 91, 92, 93, 94, 95,
+		   96, 97, 98, 99, 100, 101, 102, 103,
+		   104, 105, 106, 107, 108, 109, 110, 111,
+		   112, 113, 114, 115, 116, 117, 118, 119,
+		   120, 121, 122, 123, 124, 125, 126, 127},
+	.oobfree = {
+		{.offset = 2,
+		 .length = 78}}
+};
+
 static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
 			   int new_state);
 
@@ -2555,6 +2569,9 @@
 		case 64:
 			chip->ecc.layout = &nand_oob_64;
 			break;
+		case 128:
+			chip->ecc.layout = &nand_oob_128;
+			break;
 		default:
 			printk(KERN_WARNING "No oob scheme defined for "
 			       "oobsize %d\n", mtd->oobsize);
@@ -2676,6 +2693,7 @@
 			break;
 		case 4:
 		case 8:
+		case 16:
 			mtd->subpage_sft = 2;
 			break;
 		}
include/linux/mtd/nand.h +2 -2
Index: linux-2.6/include/linux/mtd/nand.h
===================================================================
@@ -43,8 +43,8 @@
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE	64
-#define NAND_MAX_PAGESIZE	2048
+#define NAND_MAX_OOBSIZE	128
+#define NAND_MAX_PAGESIZE	4096
 
 /*
  * Constants for hardware specific CLE/ALE/NCE function
#29 lore raw

PATCH 8/8 NAND: Add support for NAND on the Socrates board

In reply to Wolfgang Grandegger
---
 drivers/mtd/nand/Kconfig         |    6 
 drivers/mtd/nand/Makefile        |    1 
 drivers/mtd/nand/socrates_nand.c |  324 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 331 insertions(+)
drivers/mtd/nand/Kconfig +6 -0
Index: linux-2.6/drivers/mtd/nand/Kconfig
===================================================================
@@ -427,4 +427,10 @@
 	  Several Renesas SuperH CPU has FLCTL. This option enables support
 	  for NAND Flash using FLCTL. This driver support SH7723.
 
+config MTD_NAND_SOCRATES
+	tristate "Support for NAND on Socrates board"
+	depends on MTD_NAND && SOCRATES
+	help
+	  Enables support for NAND Flash chips wired onto Socrates board.
+
 endif # MTD_NAND
drivers/mtd/nand/Makefile +1 -0
Index: linux-2.6/drivers/mtd/nand/Makefile
===================================================================
@@ -36,5 +36,6 @@
 obj-$(CONFIG_MTD_NAND_FSL_UPM)		+= fsl_upm.o
 obj-$(CONFIG_MTD_NAND_SH_FLCTL)		+= sh_flctl.o
 obj-$(CONFIG_MTD_NAND_MXC)		+= mxc_nand.o
+obj-$(CONFIG_MTD_NAND_SOCRATES)		+= socrates_nand.o
 
 nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/socrates_nand.c new file +324 -0

324 lines not on this page · raw message

#30 lore raw
In reply to Wolfgang Grandegger

Please *FORGET* this series of patches. Only the I2C related patches are relevant but I accidentally sent out the complete patch stack :-(. I will resent them in a second.

Sorry for any inconvenience this has caused.

Wolfgang.

Quoted 55 lines · Wolfgang Grandegger

Following (most of) Grant's suggestions to my RFC:

http://ozlabs.org/pipermail/linuxppc-dev/2009-March/069820.html

this new patch series now uses:

- the I2c node property "fsl,preserve-clocking" to overtake the clock settings from the boot loader. The first patch provides this feature and can be applied *without* delay. This rest will take more time and discussion, I'm afraid :-(.

- the OF match table to define the I2C clock properties, especially the source clock pre-scaler:

  static const struct of_device_id mpc_i2c_of_match[] = {
	{.compatible = "fsl,mpc5200b-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc5200-i2c",
	 .data = (void *)FSL_I2C_DEV_CLOCK_5200, },
	{.compatible = "fsl,mpc8313-i2c",
	 .data = (void *)FSL_I2C_DEV_SEPARATE_DFSRR, },
	{.compatible = "fsl,mpc8543-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV2), },
	{.compatible = "fsl,mpc8544-i2c",
	 .data = (void *)(FSL_I2C_DEV_SEPARATE_DFSRR |
			  FSL_I2C_DEV_CLOCK_DIV23), },
	/* Backward compatibility */
	{.compatible = "fsl-i2c", },
	{},

};

The "data" field defines the relevant I2C flags.

- arch-specific tables and functions to get the proper Freqency Divider Register (fdr). I added them to sysdev/fsl_soc.c for the MPC8xxx and to platforms/52xx/mpc52xx_common.c for the MPC52xx. This also solves the problem with arch-specific functions, e.g. for getting the bus frequency.

- dev_dbg() and dev_info() to profit from a more descriptive output.

Hope this solution is OK now?

Thanks,

Wolfgang.

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#31 lore raw
Quoted 5 lines · Wolfgang Grandegger

Please *FORGET* this series of patches. Only the I2C related patches are relevant but I accidentally sent out the complete patch stack :-(. I will resent them in a second.

Sorry for any inconvenience this has caused.

Heh, no worries. At least this way you get a bonus round of review. :-)

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.