Commit b3cdda2b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux

Pull device tree changes from Grant Likely:
 "All around device tree changes destined for v3.8.  Aside from the
  documentation updates the highlights in this branch include:

   - Kbuild changes for using CPP with .dts files
   - locking fix from preempt_rt patchset
   - include DT alias names in device uevent
   - Selftest bugfixes and improvements
   - New function for counting phandles stanzas in a property
   - constify argument to of_node_full_name()
   - Various bug fixes

  This tree did also contain a commit to use platform_device_add instead
  of open-coding the device add code, but it caused problems with amba
  devices and needed to be reverted."

* tag 'dt-for-linus' of git://git.secretlab.ca/git/linux: (23 commits)
  Revert "of: use platform_device_add"
  kbuild: limit dtc+cpp include path
  gpio: Make of_count_named_gpios() use new of_count_phandle_with_args()
  of: Create function for counting number of phandles in a property
  of/base: Clean up exit paths for of_parse_phandle_with_args()
  of/selftest: Use selftest() macro throughout
  of/selftest: Fix GPIOs selftest to cover the 7th case
  of: fix recursive locking in of_get_next_available_child()
  documentation/devicetree: Fix a typo in exynos-dw-mshc.txt
  OF: convert devtree lock from rw_lock to raw spinlock
  of/exynos_g2d: Add Bindings for exynos G2D driver
  kbuild: create a rule to run the pre-processor on *.dts files
  input: Extend matrix-keypad device tree binding
  devicetree: Move NS2 LEDs binding into LEDs directory
  of: use platform_device_add
  powerpc/5200: Fix size to request_mem_region() call
  documentation/devicetree: Fix typos
  of: add 'const' to of_node_full_name parameter
  of: Output devicetree alias names in uevent
  DT: add vendor prefixes for Renesas and Toshiba
  ...
parents 3aad3f03 02bbde78
...@@ -4,7 +4,7 @@ Required properties: ...@@ -4,7 +4,7 @@ Required properties:
- compatible: Should be "atmel,<chip>-aic" - compatible: Should be "atmel,<chip>-aic"
- interrupt-controller: Identifies the node as an interrupt controller. - interrupt-controller: Identifies the node as an interrupt controller.
- interrupt-parent: For single AIC system, it is an empty property. - interrupt-parent: For single AIC system, it is an empty property.
- #interrupt-cells: The number of cells to define the interrupts. It sould be 3. - #interrupt-cells: The number of cells to define the interrupts. It should be 3.
The first cell is the IRQ number (aka "Peripheral IDentifier" on datasheet). The first cell is the IRQ number (aka "Peripheral IDentifier" on datasheet).
The second cell is used to specify flags: The second cell is used to specify flags:
bits[3:0] trigger type and level flags: bits[3:0] trigger type and level flags:
......
...@@ -42,7 +42,7 @@ Main node required properties: ...@@ -42,7 +42,7 @@ Main node required properties:
Optional Optional
- interrupts : Interrupt source of the parent interrupt controller on - interrupts : Interrupt source of the parent interrupt controller on
secondary GICs, or VGIC maintainance interrupt on primary GIC (see secondary GICs, or VGIC maintenance interrupt on primary GIC (see
below). below).
- cpu-offset : per-cpu offset within the distributor and cpu interface - cpu-offset : per-cpu offset within the distributor and cpu interface
...@@ -74,7 +74,7 @@ Required properties: ...@@ -74,7 +74,7 @@ Required properties:
virtual interface control register base and size. The 2nd additional virtual interface control register base and size. The 2nd additional
region is the GIC virtual cpu interface register base and size. region is the GIC virtual cpu interface register base and size.
- interrupts : VGIC maintainance interrupt. - interrupts : VGIC maintenance interrupt.
Example: Example:
......
...@@ -39,16 +39,16 @@ Boards: ...@@ -39,16 +39,16 @@ Boards:
- OMAP3 Tobi with Overo : Commercial expansion board with daughter board - OMAP3 Tobi with Overo : Commercial expansion board with daughter board
compatible = "ti,omap3-tobi", "ti,omap3-overo", "ti,omap3" compatible = "ti,omap3-tobi", "ti,omap3-overo", "ti,omap3"
- OMAP4 SDP : Software Developement Board - OMAP4 SDP : Software Development Board
compatible = "ti,omap4-sdp", "ti,omap4430" compatible = "ti,omap4-sdp", "ti,omap4430"
- OMAP4 PandaBoard : Low cost community board - OMAP4 PandaBoard : Low cost community board
compatible = "ti,omap4-panda", "ti,omap4430" compatible = "ti,omap4-panda", "ti,omap4430"
- OMAP3 EVM : Software Developement Board for OMAP35x, AM/DM37x - OMAP3 EVM : Software Development Board for OMAP35x, AM/DM37x
compatible = "ti,omap3-evm", "ti,omap3" compatible = "ti,omap3-evm", "ti,omap3"
- AM335X EVM : Software Developement Board for AM335x - AM335X EVM : Software Development Board for AM335x
compatible = "ti,am335x-evm", "ti,am33xx", "ti,omap3" compatible = "ti,am335x-evm", "ti,am33xx", "ti,omap3"
- AM335X Bone : Low cost community board - AM335X Bone : Low cost community board
......
Samsung 2D Graphic Accelerator using DRM frame work
Samsung FIMG2D is a graphics 2D accelerator which supports Bit Block Transfer.
We set the drawing-context registers for configuring rendering parameters and
then start rendering.
This driver is for SOCs which contain G2D IPs with version 4.1.
Required properties:
-compatible:
should be "samsung,exynos-g2d-41".
-reg:
physical base address of the controller and length
of memory mapped region.
-interrupts:
interrupt combiner values.
Example:
g2d {
compatible = "samsung,exynos-g2d-41";
reg = <0x10850000 0x1000>;
interrupts = <0 91 0>;
};
NXP LPC32xx Key Scan Interface NXP LPC32xx Key Scan Interface
This binding is based on the matrix-keymap binding with the following
changes:
Required Properties: Required Properties:
- compatible: Should be "nxp,lpc3220-key" - compatible: Should be "nxp,lpc3220-key"
- reg: Physical base address of the controller and length of memory mapped - reg: Physical base address of the controller and length of memory mapped
region. region.
- interrupts: The interrupt number to the cpu. - interrupts: The interrupt number to the cpu.
- keypad,num-rows: Number of rows and columns, e.g. 1: 1x1, 6: 6x6
- keypad,num-columns: Must be equal to keypad,num-rows since LPC32xx only
supports square matrices
- nxp,debounce-delay-ms: Debounce delay in ms - nxp,debounce-delay-ms: Debounce delay in ms
- nxp,scan-delay-ms: Repeated scan period in ms - nxp,scan-delay-ms: Repeated scan period in ms
- linux,keymap: the key-code to be reported when the key is pressed - linux,keymap: the key-code to be reported when the key is pressed
and released, see also and released, see also
Documentation/devicetree/bindings/input/matrix-keymap.txt Documentation/devicetree/bindings/input/matrix-keymap.txt
Note: keypad,num-rows and keypad,num-columns are required, and must be equal
since LPC32xx only supports square matrices
Example: Example:
key@40050000 { key@40050000 {
......
...@@ -9,6 +9,12 @@ Required properties: ...@@ -9,6 +9,12 @@ Required properties:
row << 24 | column << 16 | key-code row << 24 | column << 16 | key-code
Optional properties: Optional properties:
Properties for the number of rows and columns are optional because some
drivers will use fixed values for these.
- keypad,num-rows: Number of row lines connected to the keypad controller.
- keypad,num-columns: Number of column lines connected to the keypad
controller.
Some users of this binding might choose to specify secondary keymaps for Some users of this binding might choose to specify secondary keymaps for
cases where there is a modifier key such as a Fn key. Proposed names cases where there is a modifier key such as a Fn key. Proposed names
for said properties are "linux,fn-keymap" or with another descriptive for said properties are "linux,fn-keymap" or with another descriptive
...@@ -17,3 +23,5 @@ word for the modifier other from "Fn". ...@@ -17,3 +23,5 @@ word for the modifier other from "Fn".
Example: Example:
linux,keymap = < 0x00030012 linux,keymap = < 0x00030012
0x0102003a >; 0x0102003a >;
keypad,num-rows = <2>;
keypad,num-columns = <8>;
...@@ -6,19 +6,16 @@ A key can be placed at each intersection of a unique row and a unique column. ...@@ -6,19 +6,16 @@ A key can be placed at each intersection of a unique row and a unique column.
The keypad controller can sense a key-press and key-release and report the The keypad controller can sense a key-press and key-release and report the
event using a interrupt to the cpu. event using a interrupt to the cpu.
This binding is based on the matrix-keymap binding with the following
changes:
keypad,num-rows and keypad,num-columns are required.
Required SoC Specific Properties: Required SoC Specific Properties:
- compatible: should be one of the following - compatible: should be one of the following
- "ti,omap4-keypad": For controllers compatible with omap4 keypad - "ti,omap4-keypad": For controllers compatible with omap4 keypad
controller. controller.
Required Board Specific Properties, in addition to those specified by
the shared matrix-keyboard bindings:
- keypad,num-rows: Number of row lines connected to the keypad
controller.
- keypad,num-columns: Number of column lines connected to the
keypad controller.
Optional Properties specific to linux: Optional Properties specific to linux:
- linux,keypad-no-autorepeat: do no enable autorepeat feature. - linux,keypad-no-autorepeat: do no enable autorepeat feature.
......
This binding is based on the matrix-keymap binding with the following
changes:
keypad,num-rows and keypad,num-columns are required.
Required properties: Required properties:
- compatible: "ti,tca8418" - compatible: "ti,tca8418"
- reg: the I2C address - reg: the I2C address
- interrupts: IRQ line number, should trigger on falling edge - interrupts: IRQ line number, should trigger on falling edge
- keypad,num-rows: The number of rows
- keypad,num-columns: The number of columns
- linux,keymap: Keys definitions, see keypad-matrix. - linux,keymap: Keys definitions, see keypad-matrix.
* DMA Engine. * DMA Engine.
The Octeon DMA Engine transfers between the Boot Bus and main memory. The Octeon DMA Engine transfers between the Boot Bus and main memory.
The DMA Engine will be refered to by phandle by any device that is The DMA Engine will be referred to by phandle by any device that is
connected to it. connected to it.
Properties: Properties:
......
...@@ -4,18 +4,18 @@ ...@@ -4,18 +4,18 @@
The Synopsis designware mobile storage host controller is used to interface The Synopsis designware mobile storage host controller is used to interface
a SoC with storage medium such as eMMC or SD/MMC cards. This file documents a SoC with storage medium such as eMMC or SD/MMC cards. This file documents
differences between the core Synopsis dw mshc controller properties described differences between the core Synopsis dw mshc controller properties described
by synposis-dw-mshc.txt and the properties used by the Samsung Exynos specific by synopsis-dw-mshc.txt and the properties used by the Samsung Exynos specific
extensions to the Synopsis Designware Mobile Storage Host Controller. extensions to the Synopsis Designware Mobile Storage Host Controller.
Required Properties: Required Properties:
* compatible: should be * compatible: should be
- "samsung,exynos4210-dw-mshc": for controllers with Samsung Exynos4210 - "samsung,exynos4210-dw-mshc": for controllers with Samsung Exynos4210
specific extentions. specific extensions.
- "samsung,exynos4412-dw-mshc": for controllers with Samsung Exynos4412 - "samsung,exynos4412-dw-mshc": for controllers with Samsung Exynos4412
specific extentions. specific extensions.
- "samsung,exynos5250-dw-mshc": for controllers with Samsung Exynos5250 - "samsung,exynos5250-dw-mshc": for controllers with Samsung Exynos5250
specific extentions. specific extensions.
* samsung,dw-mshc-ciu-div: Specifies the divider value for the card interface * samsung,dw-mshc-ciu-div: Specifies the divider value for the card interface
unit (ciu) clock. This property is applicable only for Exynos5 SoC's and unit (ciu) clock. This property is applicable only for Exynos5 SoC's and
......
...@@ -55,5 +55,5 @@ Example: ...@@ -55,5 +55,5 @@ Example:
}; };
Note: This example shows both SoC specific and board specific properties Note: This example shows both SoC specific and board specific properties
in a single device node. The properties can be actually be seperated in a single device node. The properties can be actually be separated
into SoC specific node and board specific node. into SoC specific node and board specific node.
...@@ -8,9 +8,9 @@ Properties: ...@@ -8,9 +8,9 @@ Properties:
Definition: Must include "fsl,srio" for IP blocks with IP Block Definition: Must include "fsl,srio" for IP blocks with IP Block
Revision Register (SRIO IPBRR1) Major ID equal to 0x01c0. Revision Register (SRIO IPBRR1) Major ID equal to 0x01c0.
Optionally, a compatiable string of "fsl,srio-vX.Y" where X is Major Optionally, a compatible string of "fsl,srio-vX.Y" where X is Major
version in IP Block Revision Register and Y is Minor version. If this version in IP Block Revision Register and Y is Minor version. If this
compatiable is provided it should be ordered before "fsl,srio". compatible is provided it should be ordered before "fsl,srio".
- reg - reg
Usage: required Usage: required
......
...@@ -17,9 +17,9 @@ Optional properties: ...@@ -17,9 +17,9 @@ Optional properties:
- ti,vsel1-gpio: Gpio for controlling VSEL1 line. - ti,vsel1-gpio: Gpio for controlling VSEL1 line.
If this property is missing, then assume that there is no GPIO If this property is missing, then assume that there is no GPIO
for vsel1 control. for vsel1 control.
- ti,vsel0-state-high: Inital state of vsel0 input is high. - ti,vsel0-state-high: Initial state of vsel0 input is high.
If this property is missing, then assume the state as low (0). If this property is missing, then assume the state as low (0).
- ti,vsel1-state-high: Inital state of vsel1 input is high. - ti,vsel1-state-high: Initial state of vsel1 input is high.
If this property is missing, then assume the state as low (0). If this property is missing, then assume the state as low (0).
Any property defined as part of the core regulator binding, defined in Any property defined as part of the core regulator binding, defined in
......
...@@ -7,7 +7,7 @@ Required properties: ...@@ -7,7 +7,7 @@ Required properties:
- reg: physical base address of the controller and length of memory mapped - reg: physical base address of the controller and length of memory mapped
region. region.
- interrupts: Two interrupt numbers to the cpu should be specified. First - interrupts: Two interrupt numbers to the cpu should be specified. First
interrupt number is the rtc alarm interupt and second interrupt number interrupt number is the rtc alarm interrupt and second interrupt number
is the rtc tick interrupt. The number of cells representing a interrupt is the rtc tick interrupt. The number of cells representing a interrupt
depends on the parent interrupt controller. depends on the parent interrupt controller.
......
...@@ -14,6 +14,7 @@ bosch Bosch Sensortec GmbH ...@@ -14,6 +14,7 @@ bosch Bosch Sensortec GmbH
brcm Broadcom Corporation brcm Broadcom Corporation
cavium Cavium, Inc. cavium Cavium, Inc.
chrp Common Hardware Reference Platform chrp Common Hardware Reference Platform
cirrus Cirrus Logic, Inc.
cortina Cortina Systems, Inc. cortina Cortina Systems, Inc.
dallas Maxim Integrated Products (formerly Dallas Semiconductor) dallas Maxim Integrated Products (formerly Dallas Semiconductor)
denx Denx Software Engineering denx Denx Software Engineering
...@@ -42,6 +43,7 @@ powervr PowerVR (deprecated, use img) ...@@ -42,6 +43,7 @@ powervr PowerVR (deprecated, use img)
qcom Qualcomm, Inc. qcom Qualcomm, Inc.
ramtron Ramtron International ramtron Ramtron International
realtek Realtek Semiconductor Corp. realtek Realtek Semiconductor Corp.
renesas Renesas Electronics Corporation
samsung Samsung Semiconductor samsung Samsung Semiconductor
sbs Smart Battery System sbs Smart Battery System
schindler Schindler schindler Schindler
...@@ -53,6 +55,7 @@ st STMicroelectronics ...@@ -53,6 +55,7 @@ st STMicroelectronics
ste ST-Ericsson ste ST-Ericsson
stericsson ST-Ericsson stericsson ST-Ericsson
ti Texas Instruments ti Texas Instruments
toshiba Toshiba Corporation
via VIA Technologies, Inc. via VIA Technologies, Inc.
wlf Wolfson Microelectronics wlf Wolfson Microelectronics
wm Wondermedia Technologies, Inc. wm Wondermedia Technologies, Inc.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
The Samsung's Watchdog controller is used for resuming system operation The Samsung's Watchdog controller is used for resuming system operation
after a preset amount of time during which the WDT reset event has not after a preset amount of time during which the WDT reset event has not
occured. occurred.
Required properties: Required properties:
- compatible : should be "samsung,s3c2410-wdt" - compatible : should be "samsung,s3c2410-wdt"
......
...@@ -1186,6 +1186,29 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1186,6 +1186,29 @@ When kbuild executes, the following steps are followed (roughly):
clean-files += *.dtb clean-files += *.dtb
DTC_FLAGS ?= -p 1024 DTC_FLAGS ?= -p 1024
dtc_cpp
This is just like dtc as describe above, except that the C pre-
processor is invoked upon the .dtsp file before compiling the result
with dtc.
In order for build dependencies to work, all files compiled using
dtc_cpp must use the C pre-processor's #include functionality and not
dtc's /include/ functionality.
Using the C pre-processor allows use of #define to create named
constants. In turn, the #defines will typically appear in a header
file, which may be shared with regular C code. Since the dtc language
represents a data structure rather than code in C syntax, similar
restrictions are placed on a header file included by a device tree
file as for a header file included by an assembly language file.
In particular, the C pre-processor is passed -x assembler-with-cpp,
which sets macro __ASSEMBLY__. __DTS__ is also set. These allow header
files to restrict their content to that compatible with device tree
source.
A central rule exists to create $(obj)/%.dtb from $(src)/%.dtsp;
architecture Makefiles do no need to explicitly write out that rule.
--- 6.8 Custom kbuild commands --- 6.8 Custom kbuild commands
When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand
......
...@@ -414,7 +414,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op) ...@@ -414,7 +414,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op)
goto error_sramclean; goto error_sramclean;
} }
if (!request_mem_region(res_bcom.start, sizeof(struct mpc52xx_sdma), if (!request_mem_region(res_bcom.start, resource_size(&res_bcom),
DRIVER_NAME)) { DRIVER_NAME)) {
printk(KERN_ERR DRIVER_NAME ": " printk(KERN_ERR DRIVER_NAME ": "
"Can't request registers region\n"); "Can't request registers region\n");
......
...@@ -64,7 +64,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -64,7 +64,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
err = -ENODEV; err = -ENODEV;
mutex_lock(&of_set_property_mutex); mutex_lock(&of_set_property_mutex);
write_lock(&devtree_lock); raw_spin_lock(&devtree_lock);
prevp = &dp->properties; prevp = &dp->properties;
while (*prevp) { while (*prevp) {
struct property *prop = *prevp; struct property *prop = *prevp;
...@@ -91,7 +91,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -91,7 +91,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
} }
prevp = &(*prevp)->next; prevp = &(*prevp)->next;
} }
write_unlock(&devtree_lock); raw_spin_unlock(&devtree_lock);
mutex_unlock(&of_set_property_mutex); mutex_unlock(&of_set_property_mutex);
/* XXX Upate procfs if necessary... */ /* XXX Upate procfs if necessary... */
......
...@@ -88,41 +88,6 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname, ...@@ -88,41 +88,6 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname,
} }
EXPORT_SYMBOL(of_get_named_gpio_flags); EXPORT_SYMBOL(of_get_named_gpio_flags);
/**
* of_gpio_named_count - Count GPIOs for a device
* @np: device node to count GPIOs for
* @propname: property name containing gpio specifier(s)
*
* The function returns the count of GPIOs specified for a node.
*
* Note that the empty GPIO specifiers counts too. For example,
*
* gpios = <0
* &pio1 1 2
* 0
* &pio2 3 4>;
*
* defines four GPIOs (so this function will return 4), two of which
* are not specified.
*/
unsigned int of_gpio_named_count(struct device_node *np, const char* propname)
{
unsigned int cnt = 0;
do {
int ret;
ret = of_parse_phandle_with_args(np, propname, "#gpio-cells",
cnt, NULL);
/* A hole in the gpios = <> counts anyway. */
if (ret < 0 && ret != -EEXIST)
break;
} while (++cnt);
return cnt;
}
EXPORT_SYMBOL(of_gpio_named_count);
/** /**
* of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags
* @gc: pointer to the gpio_chip structure * @gc: pointer to the gpio_chip structure
......
...@@ -422,7 +422,7 @@ static int gpio_fan_get_of_pdata(struct device *dev, ...@@ -422,7 +422,7 @@ static int gpio_fan_get_of_pdata(struct device *dev,
/* Fill GPIO pin array */ /* Fill GPIO pin array */
pdata->num_ctrl = of_gpio_count(node); pdata->num_ctrl = of_gpio_count(node);
if (!pdata->num_ctrl) { if (pdata->num_ctrl <= 0) {
dev_err(dev, "gpios DT property empty / missing"); dev_err(dev, "gpios DT property empty / missing");
return -ENODEV; return -ENODEV;
} }
...@@ -477,7 +477,7 @@ static int gpio_fan_get_of_pdata(struct device *dev, ...@@ -477,7 +477,7 @@ static int gpio_fan_get_of_pdata(struct device *dev,
pdata->speed = speed; pdata->speed = speed;
/* Alarm GPIO if one exists */ /* Alarm GPIO if one exists */
if (of_gpio_named_count(node, "alarm-gpios")) { if (of_gpio_named_count(node, "alarm-gpios") > 0) {
struct gpio_fan_alarm *alarm; struct gpio_fan_alarm *alarm;
int val; int val;
enum of_gpio_flags flags; enum of_gpio_flags flags;
......
...@@ -403,7 +403,7 @@ matrix_keypad_parse_dt(struct device *dev) ...@@ -403,7 +403,7 @@ matrix_keypad_parse_dt(struct device *dev)
struct matrix_keypad_platform_data *pdata; struct matrix_keypad_platform_data *pdata;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
unsigned int *gpios; unsigned int *gpios;
int i; int i, nrow, ncol;
if (!np) { if (!np) {
dev_err(dev, "device lacks DT data\n"); dev_err(dev, "device lacks DT data\n");
...@@ -416,9 +416,9 @@ matrix_keypad_parse_dt(struct device *dev) ...@@ -416,9 +416,9 @@ matrix_keypad_parse_dt(struct device *dev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
pdata->num_row_gpios = of_gpio_named_count(np, "row-gpios"); pdata->num_row_gpios = nrow = of_gpio_named_count(np, "row-gpios");
pdata->num_col_gpios = of_gpio_named_count(np, "col-gpios"); pdata->num_col_gpios = ncol = of_gpio_named_count(np, "col-gpios");
if (!pdata->num_row_gpios || !pdata->num_col_gpios) { if (nrow <= 0 || ncol <= 0) {
dev_err(dev, "number of keypad rows/columns not specified\n"); dev_err(dev, "number of keypad rows/columns not specified\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
...@@ -53,7 +53,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) ...@@ -53,7 +53,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev)
{ {
enum of_gpio_flags f; enum of_gpio_flags f;
struct mdio_mux_gpio_state *s; struct mdio_mux_gpio_state *s;
unsigned int num_gpios; int num_gpios;
unsigned int n; unsigned int n;
int r; int r;
...@@ -61,7 +61,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) ...@@ -61,7 +61,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
num_gpios = of_gpio_count(pdev->dev.of_node); num_gpios = of_gpio_count(pdev->dev.of_node);
if (num_gpios == 0 || num_gpios > MDIO_MUX_GPIO_MAX_BITS) if (num_gpios <= 0 || num_gpios > MDIO_MUX_GPIO_MAX_BITS)
return -ENODEV; return -ENODEV;
s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL); s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL);
......
This diff is collapsed.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/errno.h> #include <asm/errno.h>
#include "of_private.h"
/** /**
* of_match_device - Tell if a struct device matches an of_device_id list * of_match_device - Tell if a struct device matches an of_device_id list
...@@ -131,6 +132,7 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) ...@@ -131,6 +132,7 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{ {
const char *compat; const char *compat;
struct alias_prop *app;
int seen = 0, cplen, sl; int seen = 0, cplen, sl;
if ((!dev) || (!dev->of_node)) if ((!dev) || (!dev->of_node))
...@@ -153,6 +155,17 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) ...@@ -153,6 +155,17 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
seen++; seen++;
} }
add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen); add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
seen = 0;
mutex_lock(&of_aliases_mutex);
list_for_each_entry(app, &aliases_lookup, link) {
if (dev->of_node == app->np) {
add_uevent_var(env, "OF_ALIAS_%d=%s", seen,
app->alias);
seen++;
}
}
mutex_unlock(&of_aliases_mutex);
} }
int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
......
#ifndef _LINUX_OF_PRIVATE_H
#define _LINUX_OF_PRIVATE_H
/*
* Private symbols used by OF support code
*
* Paul Mackerras August 1996.
* Copyright (C) 1996-2005 Paul Mackerras.
*
* 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.
*/
/**
* struct alias_prop - Alias property in 'aliases' node
* @link: List node to link the structure in aliases_lookup list
* @alias: Alias property name
* @np: Pointer to device_node that the alias stands for
* @id: Index value from end of alias name
* @stem: Alias string without the index
*
* The structure represents one alias property of 'aliases' node as
* an entry in aliases_lookup list.
*/
struct alias_prop {
struct list_head link;
const char *alias;
struct device_node *np;
int id;
char stem[0];
};
extern struct mutex of_aliases_mutex;
extern struct list_head aliases_lookup;
#endif /* _LINUX_OF_PRIVATE_H */
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Self tests for device tree subsystem * Self tests for device tree subsystem
*/ */
#define pr_fmt(fmt) "### %s(): " fmt, __func__ #define pr_fmt(fmt) "### dt-test ### " fmt
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -16,26 +16,30 @@ ...@@ -16,26 +16,30 @@
static bool selftest_passed = true; static bool selftest_passed = true;
#define selftest(result, fmt, ...) { \ #define selftest(result, fmt, ...) { \
selftest_passed &= (result); \ if (!(result)) { \
if (!(result)) \
pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ pr_err("FAIL %s:%i " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
selftest_passed = false; \
} else { \
pr_info("pass %s:%i\n", __FILE__, __LINE__); \
} \
} }
static void __init of_selftest_parse_phandle_with_args(void) static void __init of_selftest_parse_phandle_with_args(void)
{ {
struct device_node *np; struct device_node *np;
struct of_phandle_args args; struct of_phandle_args args;
int rc, i; int i, rc;
bool passed_all = true;
pr_info("start\n");
np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
if (!np) { if (!np) {
pr_err("missing testcase data\n"); pr_err("missing testcase data\n");
return; return;
} }
for (i = 0; i < 7; i++) { rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells");
selftest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc);
for (i = 0; i < 8; i++) {
bool passed = true; bool passed = true;
rc = of_parse_phandle_with_args(np, "phandle-list", rc = of_parse_phandle_with_args(np, "phandle-list",
"#phandle-cells", i, &args); "#phandle-cells", i, &args);
...@@ -79,45 +83,47 @@ static void __init of_selftest_parse_phandle_with_args(void) ...@@ -79,45 +83,47 @@ static void __init of_selftest_parse_phandle_with_args(void)
passed &= (args.args[0] == (i + 1)); passed &= (args.args[0] == (i + 1));
break; break;
case 7: case 7:
passed &= (rc == -EINVAL); passed &= (rc == -ENOENT);
break; break;
default: default:
passed = false; passed = false;
} }
if (!passed) { selftest(passed, "index %i - data error on node %s rc=%i\n",
int j; i, args.np->full_name, rc);
pr_err("index %i - data error on node %s rc=%i regs=[",
i, args.np->full_name, rc);
for (j = 0; j < args.args_count; j++)
printk(" %i", args.args[j]);
printk(" ]\n");
passed_all = false;
}
} }
/* Check for missing list property */ /* Check for missing list property */
rc = of_parse_phandle_with_args(np, "phandle-list-missing", rc = of_parse_phandle_with_args(np, "phandle-list-missing",
"#phandle-cells", 0, &args); "#phandle-cells", 0, &args);
passed_all &= (rc == -EINVAL); selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
rc = of_count_phandle_with_args(np, "phandle-list-missing",
"#phandle-cells");
selftest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
/* Check for missing cells property */ /* Check for missing cells property */
rc = of_parse_phandle_with_args(np, "phandle-list", rc = of_parse_phandle_with_args(np, "phandle-list",
"#phandle-cells-missing", 0, &args); "#phandle-cells-missing", 0, &args);
passed_all &= (rc == -EINVAL); selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
rc = of_count_phandle_with_args(np, "phandle-list",
"#phandle-cells-missing");
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
/* Check for bad phandle in list */ /* Check for bad phandle in list */
rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle", rc = of_parse_phandle_with_args(np, "phandle-list-bad-phandle",
"#phandle-cells", 0, &args); "#phandle-cells", 0, &args);
passed_all &= (rc == -EINVAL); selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
rc = of_count_phandle_with_args(np, "phandle-list-bad-phandle",
"#phandle-cells");
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
/* Check for incorrectly formed argument list */ /* Check for incorrectly formed argument list */
rc = of_parse_phandle_with_args(np, "phandle-list-bad-args", rc = of_parse_phandle_with_args(np, "phandle-list-bad-args",
"#phandle-cells", 1, &args); "#phandle-cells", 1, &args);
passed_all &= (rc == -EINVAL); selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
rc = of_count_phandle_with_args(np, "phandle-list-bad-args",
pr_info("end - %s\n", passed_all ? "PASS" : "FAIL"); "#phandle-cells");
selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
} }
static void __init of_selftest_property_match_string(void) static void __init of_selftest_property_match_string(void)
......
...@@ -947,12 +947,12 @@ static int of_fsl_spi_get_chipselects(struct device *dev) ...@@ -947,12 +947,12 @@ static int of_fsl_spi_get_chipselects(struct device *dev)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct fsl_spi_platform_data *pdata = dev->platform_data; struct fsl_spi_platform_data *pdata = dev->platform_data;
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
unsigned int ngpios; int ngpios;
int i = 0; int i = 0;
int ret; int ret;
ngpios = of_gpio_count(np); ngpios = of_gpio_count(np);
if (!ngpios) { if (ngpios <= 0) {
/* /*
* SPI w/o chip-select line. One SPI device is still permitted * SPI w/o chip-select line. One SPI device is still permitted
* though. * though.
......
...@@ -54,7 +54,7 @@ struct tiny_spi { ...@@ -54,7 +54,7 @@ struct tiny_spi {
unsigned int txc, rxc; unsigned int txc, rxc;
const u8 *txp; const u8 *txp;
u8 *rxp; u8 *rxp;
unsigned int gpio_cs_count; int gpio_cs_count;
int *gpio_cs; int *gpio_cs;
}; };
...@@ -74,7 +74,7 @@ static void tiny_spi_chipselect(struct spi_device *spi, int is_active) ...@@ -74,7 +74,7 @@ static void tiny_spi_chipselect(struct spi_device *spi, int is_active)
{ {
struct tiny_spi *hw = tiny_spi_to_hw(spi); struct tiny_spi *hw = tiny_spi_to_hw(spi);
if (hw->gpio_cs_count) { if (hw->gpio_cs_count > 0) {
gpio_set_value(hw->gpio_cs[spi->chip_select], gpio_set_value(hw->gpio_cs[spi->chip_select],
(spi->mode & SPI_CS_HIGH) ? is_active : !is_active); (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
} }
...@@ -254,7 +254,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev) ...@@ -254,7 +254,7 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
if (!np) if (!np)
return 0; return 0;
hw->gpio_cs_count = of_gpio_count(np); hw->gpio_cs_count = of_gpio_count(np);
if (hw->gpio_cs_count) { if (hw->gpio_cs_count > 0) {
hw->gpio_cs = devm_kzalloc(&pdev->dev, hw->gpio_cs = devm_kzalloc(&pdev->dev,
hw->gpio_cs_count * sizeof(unsigned int), hw->gpio_cs_count * sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
...@@ -352,7 +352,7 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -352,7 +352,7 @@ static int tiny_spi_probe(struct platform_device *pdev)
goto exit_gpio; goto exit_gpio;
gpio_direction_output(hw->gpio_cs[i], 1); gpio_direction_output(hw->gpio_cs[i], 1);
} }
hw->bitbang.master->num_chipselect = max(1U, hw->gpio_cs_count); hw->bitbang.master->num_chipselect = max(1, hw->gpio_cs_count);
/* register our spi controller */ /* register our spi controller */
err = spi_bitbang_start(&hw->bitbang); err = spi_bitbang_start(&hw->bitbang);
......
...@@ -419,7 +419,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op) ...@@ -419,7 +419,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
* This includes both "null" gpio's and real ones. * This includes both "null" gpio's and real ones.
*/ */
num_gpios = of_gpio_count(np); num_gpios = of_gpio_count(np);
if (num_gpios) { if (num_gpios > 0) {
int i; int i;
hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL); hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL);
...@@ -471,7 +471,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op) ...@@ -471,7 +471,7 @@ static int spi_ppc4xx_of_probe(struct platform_device *op)
SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST; SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | SPI_LSB_FIRST;
/* this many pins in all GPIO controllers */ /* this many pins in all GPIO controllers */
bbp->master->num_chipselect = num_gpios; bbp->master->num_chipselect = num_gpios > 0 ? num_gpios : 0;
/* Get the clock for the OPB */ /* Get the clock for the OPB */
opbnp = of_find_compatible_node(NULL, NULL, "ibm,opb"); opbnp = of_find_compatible_node(NULL, NULL, "ibm,opb");
......
...@@ -1059,15 +1059,14 @@ EXPORT_SYMBOL_GPL(spi_alloc_master); ...@@ -1059,15 +1059,14 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int of_spi_register_master(struct spi_master *master) static int of_spi_register_master(struct spi_master *master)
{ {
u16 nb; int nb, i, *cs;
int i, *cs;
struct device_node *np = master->dev.of_node; struct device_node *np = master->dev.of_node;
if (!np) if (!np)
return 0; return 0;
nb = of_gpio_named_count(np, "cs-gpios"); nb = of_gpio_named_count(np, "cs-gpios");
master->num_chipselect = max(nb, master->num_chipselect); master->num_chipselect = max(nb, (int)master->num_chipselect);
if (nb < 1) if (nb < 1)
return 0; return 0;
......
...@@ -92,7 +92,7 @@ static inline void of_node_put(struct device_node *node) { } ...@@ -92,7 +92,7 @@ static inline void of_node_put(struct device_node *node) { }
extern struct device_node *of_allnodes; extern struct device_node *of_allnodes;
extern struct device_node *of_chosen; extern struct device_node *of_chosen;
extern struct device_node *of_aliases; extern struct device_node *of_aliases;
extern rwlock_t devtree_lock; extern raw_spinlock_t devtree_lock;
static inline bool of_have_populated_dt(void) static inline bool of_have_populated_dt(void)
{ {
...@@ -160,7 +160,7 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) ...@@ -160,7 +160,7 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
#define OF_BAD_ADDR ((u64)-1) #define OF_BAD_ADDR ((u64)-1)
static inline const char* of_node_full_name(struct device_node *np) static inline const char *of_node_full_name(const struct device_node *np)
{ {
return np ? np->full_name : "<no-node>"; return np ? np->full_name : "<no-node>";
} }
...@@ -277,6 +277,8 @@ extern struct device_node *of_parse_phandle(const struct device_node *np, ...@@ -277,6 +277,8 @@ extern struct device_node *of_parse_phandle(const struct device_node *np,
extern int of_parse_phandle_with_args(const struct device_node *np, extern int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name, int index, const char *list_name, const char *cells_name, int index,
struct of_phandle_args *out_args); struct of_phandle_args *out_args);
extern int of_count_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name);
extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
extern int of_alias_get_id(struct device_node *np, const char *stem); extern int of_alias_get_id(struct device_node *np, const char *stem);
...@@ -467,6 +469,13 @@ static inline int of_parse_phandle_with_args(struct device_node *np, ...@@ -467,6 +469,13 @@ static inline int of_parse_phandle_with_args(struct device_node *np,
return -ENOSYS; return -ENOSYS;
} }
static inline int of_count_phandle_with_args(struct device_node *np,
const char *list_name,
const char *cells_name)
{
return -ENOSYS;
}
static inline int of_alias_get_id(struct device_node *np, const char *stem) static inline int of_alias_get_id(struct device_node *np, const char *stem)
{ {
return -ENOSYS; return -ENOSYS;
......
...@@ -50,9 +50,6 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) ...@@ -50,9 +50,6 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
extern int of_get_named_gpio_flags(struct device_node *np, extern int of_get_named_gpio_flags(struct device_node *np,
const char *list_name, int index, enum of_gpio_flags *flags); const char *list_name, int index, enum of_gpio_flags *flags);
extern unsigned int of_gpio_named_count(struct device_node *np,
const char* propname);
extern int of_mm_gpiochip_add(struct device_node *np, extern int of_mm_gpiochip_add(struct device_node *np,
struct of_mm_gpio_chip *mm_gc); struct of_mm_gpio_chip *mm_gc);
...@@ -71,12 +68,6 @@ static inline int of_get_named_gpio_flags(struct device_node *np, ...@@ -71,12 +68,6 @@ static inline int of_get_named_gpio_flags(struct device_node *np,
return -ENOSYS; return -ENOSYS;
} }
static inline unsigned int of_gpio_named_count(struct device_node *np,
const char* propname)
{
return 0;
}
static inline int of_gpio_simple_xlate(struct gpio_chip *gc, static inline int of_gpio_simple_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec, const struct of_phandle_args *gpiospec,
u32 *flags) u32 *flags)
...@@ -90,22 +81,37 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { } ...@@ -90,22 +81,37 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
#endif /* CONFIG_OF_GPIO */ #endif /* CONFIG_OF_GPIO */
/** /**
* of_gpio_count - Count GPIOs for a device * of_gpio_named_count() - Count GPIOs for a device
* @np: device node to count GPIOs for * @np: device node to count GPIOs for
* @propname: property name containing gpio specifier(s)
* *
* The function returns the count of GPIOs specified for a node. * The function returns the count of GPIOs specified for a node.
* Note that the empty GPIO specifiers count too. Returns either
* Number of gpios defined in property,
* -EINVAL for an incorrectly formed gpios property, or
* -ENOENT for a missing gpios property
* *
* Note that the empty GPIO specifiers counts too. For example, * Example:
*
* gpios = <0 * gpios = <0
* &pio1 1 2 * &gpio1 1 2
* 0 * 0
* &pio2 3 4>; * &gpio2 3 4>;
*
* The above example defines four GPIOs, two of which are not specified.
* This function will return '4'
*/
static inline int of_gpio_named_count(struct device_node *np, const char* propname)
{
return of_count_phandle_with_args(np, propname, "#gpio-cells");
}
/**
* of_gpio_count() - Count GPIOs for a device
* @np: device node to count GPIOs for
* *
* defines four GPIOs (so this function will return 4), two of which * Same as of_gpio_named_count, but hard coded to use the 'gpios' property
* are not specified.
*/ */
static inline unsigned int of_gpio_count(struct device_node *np) static inline int of_gpio_count(struct device_node *np)
{ {
return of_gpio_named_count(np, "gpios"); return of_gpio_named_count(np, "gpios");
} }
......
...@@ -156,6 +156,11 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ ...@@ -156,6 +156,11 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
ld_flags = $(LDFLAGS) $(ldflags-y) ld_flags = $(LDFLAGS) $(ldflags-y)
dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \
-I$(srctree)/arch/$(SRCARCH)/boot/dts \
-I$(srctree)/arch/$(SRCARCH)/include/dts \
-undef -D__DTS__
# Finds the multi-part object the current object will be linked into # Finds the multi-part object the current object will be linked into
modname-multi = $(sort $(foreach m,$(multi-used),\ modname-multi = $(sort $(foreach m,$(multi-used),\
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
...@@ -269,6 +274,15 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile ...@@ -269,6 +274,15 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile
$(obj)/%.dtb: $(src)/%.dts FORCE $(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc) $(call if_changed_dep,dtc)
dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
quiet_cmd_dtc_cpp = DTC+CPP $@
cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp)
$(obj)/%.dtb: $(src)/%.dtsp FORCE
$(call if_changed_dep,dtc_cpp)
# Bzip2 # Bzip2
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment