From 44ad56b7df54cbc8063b46883d183e4e2f09f831 Mon Sep 17 00:00:00 2001 From: David Daney Date: Wed, 14 Dec 2011 15:26:19 -0800 Subject: OF/device-tree: Add some entries to vendor-prefixes.txt We are currently using 'cavium', 'cortina' and 'st', add them to the list of known prefixes. Signed-off-by: David Daney Signed-off-by: Rob Herring --- Documentation/devicetree/bindings/vendor-prefixes.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 874921e97802..18626965159e 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -8,7 +8,9 @@ amcc Applied Micro Circuits Corporation (APM, formally AMCC) apm Applied Micro Circuits Corporation (APM) arm ARM Ltd. atmel Atmel Corporation +cavium Cavium, Inc. chrp Common Hardware Reference Platform +cortina Cortina Systems, Inc. dallas Maxim Integrated Products (formerly Dallas Semiconductor) denx Denx Software Engineering epson Seiko Epson Corp. @@ -36,6 +38,7 @@ schindler Schindler sil Silicon Image simtek sirf SiRF Technology, Inc. +st STMicroelectronics stericsson ST-Ericsson ti Texas Instruments xlnx Xilinx -- cgit v1.2.3 From 88af7f58c6f1fa28d617392c791f11317bcb590d Mon Sep 17 00:00:00 2001 From: Benoit Cousson Date: Mon, 5 Dec 2011 15:23:54 +0100 Subject: of/base: Take NULL string into account for property with multiple strings The current implementation just ignore any NULL string inserted in a multiple strings property. In some cases we can have a property with a fix number of strings but not necessarily used, like for example in a list of valid pinmux modes. prop = "uart_rx", "uart_tx", "", "", "safe_mode"; Do no skip NULL string and take them into account in of_property_read_string_index and of_property_count_strings. Reported-by: Tony Lindgren Signed-off-by: Benoit Cousson Cc: Grant Likely Signed-off-by: Rob Herring --- drivers/of/base.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 9b6588ef0673..b7072437eb8c 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -752,7 +752,7 @@ int of_property_read_string_index(struct device_node *np, const char *propname, for (i = 0; total < prop->length; total += l, p += l) { l = strlen(p) + 1; - if ((*p != 0) && (i++ == index)) { + if (i++ == index) { *output = p; return 0; } @@ -790,11 +790,9 @@ int of_property_count_strings(struct device_node *np, const char *propname) p = prop->value; - for (i = 0; total < prop->length; total += l, p += l) { + for (i = 0; total < prop->length; total += l, p += l, i++) l = strlen(p) + 1; - if (*p != 0) - i++; - } + return i; } EXPORT_SYMBOL_GPL(of_property_count_strings); -- cgit v1.2.3 From 7b482c8360d368fd495685a2c69ca4f1e7b29764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 20 Dec 2011 22:56:45 +0100 Subject: ARM/of: allow *machine_desc.dt_compat to be const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows dt_compat to point to a constant list of compatible strings. Signed-off-by: Uwe Kleine-König Signed-off-by: Rob Herring --- arch/arm/include/asm/mach/arch.h | 2 +- drivers/of/fdt.c | 4 ++-- include/linux/of_fdt.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 2b0efc3104ac..02a718adb598 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h @@ -19,7 +19,7 @@ struct machine_desc { unsigned int nr; /* architecture number */ const char *name; /* architecture name */ unsigned long atag_offset; /* tagged list (relative) */ - const char **dt_compat; /* array of device tree + const char *const *dt_compat; /* array of device tree * 'compatible' strings */ unsigned int nr_irqs; /* number of IRQs */ diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index fd85fa298e0f..7dc8e6da858d 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -107,7 +107,7 @@ int of_fdt_is_compatible(struct boot_param_header *blob, * of_fdt_match - Return true if node matches a list of compatible values */ int of_fdt_match(struct boot_param_header *blob, unsigned long node, - const char **compat) + const char *const *compat) { unsigned int tmp, score = 0; @@ -541,7 +541,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) /** * of_flat_dt_match - Return true if node matches a list of compatible values */ -int __init of_flat_dt_match(unsigned long node, const char **compat) +int __init of_flat_dt_match(unsigned long node, const char *const *compat) { return of_fdt_match(initial_boot_params, node, compat); } diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index c84d900fbbb3..ed136ad698ce 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -71,7 +71,7 @@ extern int of_fdt_is_compatible(struct boot_param_header *blob, unsigned long node, const char *compat); extern int of_fdt_match(struct boot_param_header *blob, unsigned long node, - const char **compat); + const char *const *compat); extern void of_fdt_unflatten_tree(unsigned long *blob, struct device_node **mynodes); @@ -88,7 +88,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, extern void *of_get_flat_dt_prop(unsigned long node, const char *name, unsigned long *size); extern int of_flat_dt_is_compatible(unsigned long node, const char *name); -extern int of_flat_dt_match(unsigned long node, const char **matches); +extern int of_flat_dt_match(unsigned long node, const char *const *matches); extern unsigned long of_get_flat_dt_root(void); extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, -- cgit v1.2.3 From 8af0da93da7c40526959ab5291964581c678d3e7 Mon Sep 17 00:00:00 2001 From: Dong Aisheng Date: Thu, 22 Dec 2011 20:19:24 +0800 Subject: dt: reform for_each_property to for_each_property_of_node Make this macro easier to use(do not need to pass properties, a node is enough), also change to a more sensible name as for_each_child_of_node. Signed-off-by: Dong Aisheng Cc: Grant Likely Signed-off-by: Rob Herring --- drivers/of/base.c | 2 +- include/linux/of.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index b7072437eb8c..0181eeb88c92 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1157,7 +1157,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) if (!of_aliases) return; - for_each_property(pp, of_aliases->properties) { + for_each_property_of_node(of_aliases, pp) { const char *start = pp->name; const char *end = start + strlen(start); struct device_node *np; diff --git a/include/linux/of.h b/include/linux/of.h index 4948552d60f5..f1a490c37e06 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -219,8 +219,8 @@ extern int of_device_is_available(const struct device_node *device); extern const void *of_get_property(const struct device_node *node, const char *name, int *lenp); -#define for_each_property(pp, properties) \ - for (pp = properties; pp != NULL; pp = pp->next) +#define for_each_property_of_node(dn, pp) \ + for (pp = dn->properties; pp != NULL; pp = pp->next) extern int of_n_addr_cells(struct device_node *np); extern int of_n_size_cells(struct device_node *np); -- cgit v1.2.3 From 02bca5ff270774d4b4929de8b62ab96708065386 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 27 Dec 2011 11:18:46 -0800 Subject: dt/i2c: Enumerate some of the known trivial i2c devices Based on recent discussions, we apparently want to do bindings even for trivial i2c devices, even though they have for years just been added. So start a table of the currently known ones for others to be added to over time. (I am intentionally letting lines go over 80 characters to make it easier to sort the file). Signed-off-by: Olof Johansson Signed-off-by: Rob Herring --- .../devicetree/bindings/i2c/trivial-devices.txt | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/trivial-devices.txt diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt new file mode 100644 index 000000000000..1a85f986961b --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt @@ -0,0 +1,58 @@ +This is a list of trivial i2c devices that have simple device tree +bindings, consisting only of a compatible field, an address and +possibly an interrupt line. + +If a device needs more specific bindings, such as properties to +describe some aspect of it, there needs to be a specific binding +document for it just like any other devices. + + +Compatible Vendor / Chip +========== ============= +ad,ad7414 SMBus/I2C Digital Temperature Sensor in 6-Pin SOT with SMBus Alert and Over Temperature Pin +ad,adm9240 ADM9240: Complete System Hardware Monitor for uProcessor-Based Systems +adi,adt7461 +/-1C TDM Extended Temp Range I.C +adt7461 +/-1C TDM Extended Temp Range I.C +at,24c08 i2c serial eeprom (24cxx) +atmel,24c02 i2c serial eeprom (24cxx) +catalyst,24c32 i2c serial eeprom +dallas,ds1307 64 x 8, Serial, I2C Real-Time Clock +dallas,ds1338 I2C RTC with 56-Byte NV RAM +dallas,ds1339 I2C Serial Real-Time Clock +dallas,ds1340 I2C RTC with Trickle Charger +dallas,ds1374 I2C, 32-Bit Binary Counter Watchdog RTC with Trickle Charger and Reset Input/Output +dallas,ds1631 High-Precision Digital Thermometer +dallas,ds1682 Total-Elapsed-Time Recorder with Alarm +dallas,ds1775 Tiny Digital Thermometer and Thermostat +dallas,ds3232 Extremely Accurate I²C RTC with Integrated Crystal and SRAM +dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O +dallas,ds75 Digital Thermometer and Thermostat +dialog,da9053 DA9053: flexible system level PMIC with multicore support +epson,rx8025 High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE +epson,rx8581 I2C-BUS INTERFACE REAL TIME CLOCK MODULE +fsl,mag3110 MAG3110: Xtrinsic High Accuracy, 3D Magnetometer +fsl,mc13892 MC13892: Power Management Integrated Circuit (PMIC) for i.MX35/51 +fsl,mma8450 MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer +fsl,mpr121 MPR121: Proximity Capacitive Touch Sensor Controller +fsl,sgtl5000 SGTL5000: Ultra Low-Power Audio Codec +maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator +maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs +maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface +mc,rv3029c2 Real Time Clock Module with I2C-Bus +national,lm75 I2C TEMP SENSOR +national,lm80 Serial Interface ACPI-Compatible Microprocessor System Hardware Monitor +national,lm92 ±0.33°C Accurate, 12-Bit + Sign Temperature Sensor and Thermal Window Comparator with Two-Wire Interface +nxp,pca9556 Octal SMBus and I2C registered interface +nxp,pca9557 8-bit I2C-bus and SMBus I/O port with reset +nxp,pcf8563 Real-time clock/calendar +ovti,ov5642 OV5642: Color CMOS QSXGA (5-megapixel) Image Sensor with OmniBSI and Embedded TrueFocus +pericom,pt7c4338 Real-time Clock Module +plx,pex8648 48-Lane, 12-Port PCI Express Gen 2 (5.0 GT/s) Switch +ramtron,24c64 i2c serial eeprom (24cxx) +ricoh,rs5c372a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC +samsung,24ad0xd1 S524AD0XF1 (128K/256K-bit Serial EEPROM for Low Power) +st-micro,24c256 i2c serial eeprom (24cxx) +stm,m41t00 Serial Access TIMEKEEPER +stm,m41t62 Serial real-time clock (RTC) with alarm +stm,m41t80 M41T80 - SERIAL ACCESS RTC WITH ALARMS +ti,tsc2003 I2C Touch-Screen Controller -- cgit v1.2.3 From af71100c7acf3ccaf95044cd5e9e866178e5f8a1 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 8 Nov 2011 14:43:47 -0600 Subject: i2c-designware: add OF binding support Add of_match_table and DT style i2c registration to designware i2c driver. Refactored for pci/plat split by Dirk Brandewie. Signed-off-by: Rob Herring Acked-by: Grant Likely Signed-off-by: Dirk Brandewie --- .../devicetree/bindings/i2c/i2c-designware.txt | 22 ++++++++++++++++++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-designware.txt diff --git a/Documentation/devicetree/bindings/i2c/i2c-designware.txt b/Documentation/devicetree/bindings/i2c/i2c-designware.txt new file mode 100644 index 000000000000..e42a2ee233e6 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-designware.txt @@ -0,0 +1,22 @@ +* Synopsys DesignWare I2C + +Required properties : + + - compatible : should be "snps,designware-i2c" + - reg : Offset and length of the register set for the device + - interrupts : where IRQ is the interrupt number. + +Recommended properties : + + - clock-frequency : desired I2C bus clock frequency in Hz. + +Example : + + i2c@f0000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,designware-i2c"; + reg = <0xf0000 0x1000>; + interrupts = <11>; + clock-frequency = <400000>; + }; diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 2d3657ab1258..5244c4724df7 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -137,6 +138,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) sizeof(adap->name)); adap->algo = &i2c_dw_algo; adap->dev.parent = &pdev->dev; + adap->dev.of_node = pdev->dev.of_node; adap->nr = pdev->id; r = i2c_add_numbered_adapter(adap); @@ -144,6 +146,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failure adding adapter\n"); goto err_free_irq; } + of_i2c_register_devices(adap); return 0; @@ -187,6 +190,14 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id dw_i2c_of_match[] = { + { .compatible = "snps,designware-i2c", }, + {}, +}; +MODULE_DEVICE_TABLE(of, dw_i2c_of_match); +#endif + /* work with hotplug and coldplug */ MODULE_ALIAS("platform:i2c_designware"); @@ -195,6 +206,7 @@ static struct platform_driver dw_i2c_driver = { .driver = { .name = "i2c_designware", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(dw_i2c_of_match), }, }; -- cgit v1.2.3 From 75c71848f22e6381f48614da23df2a43e374b498 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 27 Dec 2011 22:58:40 +0100 Subject: of/pdt: fix section mismatch warning Fix the following section mismatch warning - seen when building sparc32: WARNING: vmlinux.o(.text+0x1ff9c0): Section mismatch in reference from the function kernel_tree_alloc() to the function .init.text:prom_early_alloc() The function kernel_tree_alloc() references the function __init prom_early_alloc(). This is often because kernel_tree_alloc lacks a __init annotation or the annotation of prom_early_alloc is wrong. prom_early_alloc() is annotated __init, and users of kernel_tree_alloc() is also annotated __init. So simply match the annoation of these to fix the warning. Signed-off-by: Sam Ravnborg Cc: Grant Likely Acked-by: David S. Miller Signed-off-by: Rob Herring --- drivers/of/pdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index bc5b3990f6ed..07cc1d678e4d 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c @@ -229,7 +229,7 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent, return ret; } -static void *kernel_tree_alloc(u64 size, u64 align) +static void * __init kernel_tree_alloc(u64 size, u64 align) { return prom_early_alloc(size); } -- cgit v1.2.3 From 3ecdd0515287afbcde352077d59e4028dcfbb685 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 13 Dec 2011 09:13:54 -0600 Subject: dt: add empty of_get_node/of_put_node functions Add empty of_get_node/of_put_node functions for !CONFIG_OF builds. Signed-off-by: Rob Herring Acked-by: Grant Likely --- include/linux/of.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index f1a490c37e06..9abd3ec3c2ac 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -65,6 +65,20 @@ struct device_node { #endif }; +#if defined(CONFIG_SPARC) || !defined(CONFIG_OF) +/* Dummy ref counting routines - to be implemented later */ +static inline struct device_node *of_node_get(struct device_node *node) +{ + return node; +} +static inline void of_node_put(struct device_node *node) +{ +} +#else +extern struct device_node *of_node_get(struct device_node *node); +extern void of_node_put(struct device_node *node); +#endif + #ifdef CONFIG_OF /* Pointer for first entry in chain of all nodes. */ @@ -95,21 +109,6 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag) extern struct device_node *of_find_all_nodes(struct device_node *prev); -#if defined(CONFIG_SPARC) -/* Dummy ref counting routines - to be implemented later */ -static inline struct device_node *of_node_get(struct device_node *node) -{ - return node; -} -static inline void of_node_put(struct device_node *node) -{ -} - -#else -extern struct device_node *of_node_get(struct device_node *node); -extern void of_node_put(struct device_node *node); -#endif - /* * OF address retrieval & translation */ -- cgit v1.2.3 From 93797d87d63d36404907640e4e20bb976bff4744 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 12 Dec 2011 09:59:14 -0600 Subject: irq: check domain hwirq range for DT translate A DT node may have more than 1 domain associated with it, so make sure the hwirq number is within range when doing DT translation. Signed-off-by: Rob Herring Acked-by: Grant Likely Acked-by: Shawn Guo Cc: Thomas Gleixner --- kernel/irq/irqdomain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 200ce832c585..8bd7479b8390 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -135,6 +135,9 @@ int irq_domain_simple_dt_translate(struct irq_domain *d, return -EINVAL; if (intsize < 1) return -EINVAL; + if (d->nr_irq && ((intspec[0] < d->hwirq_base) || + (intspec[0] >= d->hwirq_base + d->nr_irq))) + return -EINVAL; *out_hwirq = intspec[0]; *out_type = IRQ_TYPE_NONE; -- cgit v1.2.3 From c89810acbcf48c7004e912b2b4b862480b2d00e1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 2 Jan 2012 14:19:03 -0200 Subject: ARM: prom.h: Fix build error by removing unneeded header file Fix the following build error: CC [M] fs/udf/balloc.o In file included from /home/fabio/next/linux-next/arch/arm/include/asm/prom.h:16, from include/linux/of.h:140, from include/asm-generic/gpio.h:7, from arch/arm/plat-mxc/include/mach/irqs.h:14, from /home/fabio/next/linux-next/arch/arm/include/asm/irq.h:4, from /home/fabio/next/linux-next/arch/arm/include/asm/hardirq.h:6, from include/linux/hardirq.h:7, from include/linux/highmem.h:8, from include/linux/pagemap.h:10, from include/linux/buffer_head.h:13, from fs/udf/udfdecl.h:11, from fs/udf/balloc.c:22: /home/fabio/next/linux-next/arch/arm/include/asm/setup.h:146: error: redefinition of 'struct tag' Signed-off-by: Fabio Estevam [grant.likely: fix build failure on drivers/of/fdt.c] Signed-off-by: Grant Likely --- arch/arm/include/asm/prom.h | 1 - drivers/of/fdt.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/include/asm/prom.h b/arch/arm/include/asm/prom.h index 6f65ca86a5ec..ee0363307918 100644 --- a/arch/arm/include/asm/prom.h +++ b/arch/arm/include/asm/prom.h @@ -13,7 +13,6 @@ #ifdef CONFIG_OF -#include #include extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys); diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 7dc8e6da858d..91a375fb6ae6 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -18,6 +18,7 @@ #include #include +#include /* for COMMAND_LINE_SIZE */ #ifdef CONFIG_PPC #include #endif /* CONFIG_PPC */ -- cgit v1.2.3