mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
Merge branch 'kirkwood/dt' of git://git.infradead.org/users/jcooper/linux into late/kirkwood
From Jason Cooper: New bindings: - iconnect nand and keys - mv_cesa - gpio-fan * 'kirkwood/dt' of git://git.infradead.org/users/jcooper/linux: ARM: kirkwood: Use devicetree to define DNS-32[05] fan hwmon: Add devicetree bindings to gpio-fan Crypto: CESA: Add support for DT based instantiation. ARM: Kirkwood: Describe iconnect nand in DT. ARM: Kirkwood: Describe iconnect keys in DT.
This commit is contained in:
commit
d6a93ceb3f
10 changed files with 251 additions and 79 deletions
20
Documentation/devicetree/bindings/crypto/mv_cesa.txt
Normal file
20
Documentation/devicetree/bindings/crypto/mv_cesa.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
Marvell Cryptographic Engines And Security Accelerator
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "marvell,orion-crypto"
|
||||
- reg : base physical address of the engine and length of memory mapped
|
||||
region, followed by base physical address of sram and its memory
|
||||
length
|
||||
- reg-names : "regs" , "sram";
|
||||
- interrupts : interrupt number
|
||||
|
||||
Examples:
|
||||
|
||||
crypto@30000 {
|
||||
compatible = "marvell,orion-crypto";
|
||||
reg = <0x30000 0x10000>,
|
||||
<0x4000000 0x800>;
|
||||
reg-names = "regs" , "sram";
|
||||
interrupts = <22>;
|
||||
status = "okay";
|
||||
};
|
25
Documentation/devicetree/bindings/gpio/gpio-fan.txt
Normal file
25
Documentation/devicetree/bindings/gpio/gpio-fan.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
Bindings for fan connected to GPIO lines
|
||||
|
||||
Required properties:
|
||||
- compatible : "gpio-fan"
|
||||
- gpios: Specifies the pins that map to bits in the control value,
|
||||
ordered MSB-->LSB.
|
||||
- gpio-fan,speed-map: A mapping of possible fan RPM speeds and the
|
||||
control value that should be set to achieve them. This array
|
||||
must have the RPM values in ascending order.
|
||||
|
||||
Optional properties:
|
||||
- alarm-gpios: This pin going active indicates something is wrong with
|
||||
the fan, and a udev event will be fired.
|
||||
|
||||
Examples:
|
||||
|
||||
gpio_fan {
|
||||
compatible = "gpio-fan";
|
||||
gpios = <&gpio1 14 1
|
||||
&gpio1 13 1>;
|
||||
gpio-fan,speed-map = <0 0
|
||||
3000 1
|
||||
6000 2>;
|
||||
alarm-gpios = <&gpio1 15 1>;
|
||||
};
|
|
@ -25,6 +25,16 @@ button@3 {
|
|||
};
|
||||
};
|
||||
|
||||
gpio_fan {
|
||||
/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */
|
||||
compatible = "gpio-fan";
|
||||
gpios = <&gpio1 14 1
|
||||
&gpio1 13 1>;
|
||||
gpio-fan,speed-map = <0 0
|
||||
3000 1
|
||||
6000 2>;
|
||||
};
|
||||
|
||||
ocp@f1000000 {
|
||||
sata@80000 {
|
||||
status = "okay";
|
||||
|
|
|
@ -12,7 +12,7 @@ memory {
|
|||
};
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyS0,115200n8 earlyprintk mtdparts=orion_nand:0xc0000@0x0(uboot),0x20000@0xa0000(env),0x300000@0x100000(zImage),0x300000@0x540000(initrd),0x1f400000@0x980000(boot)";
|
||||
bootargs = "console=ttyS0,115200n8 earlyprintk";
|
||||
linux,initrd-start = <0x4500040>;
|
||||
linux,initrd-end = <0x4800000>;
|
||||
};
|
||||
|
@ -30,7 +30,37 @@ serial@12000 {
|
|||
clock-frequency = <200000000>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
nand@3000000 {
|
||||
status = "okay";
|
||||
|
||||
partition@0 {
|
||||
label = "uboot";
|
||||
reg = <0x0000000 0xc0000>;
|
||||
};
|
||||
|
||||
partition@a0000 {
|
||||
label = "env";
|
||||
reg = <0xa0000 0x20000>;
|
||||
};
|
||||
|
||||
partition@100000 {
|
||||
label = "zImage";
|
||||
reg = <0x100000 0x300000>;
|
||||
};
|
||||
|
||||
partition@540000 {
|
||||
label = "initrd";
|
||||
reg = <0x540000 0x300000>;
|
||||
};
|
||||
|
||||
partition@980000 {
|
||||
label = "boot";
|
||||
reg = <0x980000 0x1f400000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gpio-leds {
|
||||
compatible = "gpio-leds";
|
||||
|
||||
|
@ -69,4 +99,22 @@ otb {
|
|||
gpios = <&gpio1 16 0>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
button@1 {
|
||||
label = "OTB Button";
|
||||
linux,code = <133>;
|
||||
gpios = <&gpio1 3 1>;
|
||||
debounce-interval = <100>;
|
||||
};
|
||||
button@2 {
|
||||
label = "Reset";
|
||||
linux,code = <0x198>;
|
||||
gpios = <&gpio0 12 1>;
|
||||
debounce-interval = <100>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -14,7 +14,8 @@ intc: interrupt-controller {
|
|||
|
||||
ocp@f1000000 {
|
||||
compatible = "simple-bus";
|
||||
ranges = <0 0xf1000000 0x4000000>;
|
||||
ranges = <0x00000000 0xf1000000 0x4000000
|
||||
0xf5000000 0xf5000000 0x0000400>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
|
@ -105,5 +106,14 @@ i2c@11000 {
|
|||
clock-frequency = <100000>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
crypto@30000 {
|
||||
compatible = "marvell,orion-crypto";
|
||||
reg = <0x30000 0x10000>,
|
||||
<0xf5000000 0x800>;
|
||||
reg-names = "regs", "sram";
|
||||
interrupts = <22>;
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <linux/of.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/gpio-fan.h>
|
||||
#include <linux/leds.h>
|
||||
#include <asm/mach-types.h>
|
||||
#include <asm/mach/arch.h>
|
||||
|
@ -67,29 +66,6 @@ static unsigned int dnskw_mpp_config[] __initdata = {
|
|||
0
|
||||
};
|
||||
|
||||
/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */
|
||||
static struct gpio_fan_speed dnskw_fan_speed[] = {
|
||||
{ 0, 0 },
|
||||
{ 3000, 1 },
|
||||
{ 6000, 2 },
|
||||
};
|
||||
static unsigned dnskw_fan_pins[] = {46, 45};
|
||||
|
||||
static struct gpio_fan_platform_data dnskw_fan_data = {
|
||||
.num_ctrl = ARRAY_SIZE(dnskw_fan_pins),
|
||||
.ctrl = dnskw_fan_pins,
|
||||
.num_speed = ARRAY_SIZE(dnskw_fan_speed),
|
||||
.speed = dnskw_fan_speed,
|
||||
};
|
||||
|
||||
static struct platform_device dnskw_fan_device = {
|
||||
.name = "gpio-fan",
|
||||
.id = -1,
|
||||
.dev = {
|
||||
.platform_data = &dnskw_fan_data,
|
||||
},
|
||||
};
|
||||
|
||||
static void dnskw_power_off(void)
|
||||
{
|
||||
gpio_set_value(36, 1);
|
||||
|
@ -114,8 +90,6 @@ void __init dnskw_init(void)
|
|||
kirkwood_ehci_init();
|
||||
kirkwood_ge00_init(&dnskw_ge00_data);
|
||||
|
||||
platform_device_register(&dnskw_fan_device);
|
||||
|
||||
/* Register power-off GPIO. */
|
||||
if (gpio_request(36, "dnskw:power:off") == 0
|
||||
&& gpio_direction_output(36, 0) == 0)
|
||||
|
|
|
@ -33,6 +33,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = {
|
|||
OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL),
|
||||
OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL),
|
||||
OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL),
|
||||
OF_DEV_AUXDATA("marvell,orion-crypto", 0xf1030000, "mv_crypto", NULL),
|
||||
{},
|
||||
};
|
||||
|
||||
|
@ -60,7 +61,6 @@ static void __init kirkwood_dt_init(void)
|
|||
/* internal devices that every board has */
|
||||
kirkwood_xor0_init();
|
||||
kirkwood_xor1_init();
|
||||
kirkwood_crypto_init();
|
||||
|
||||
#ifdef CONFIG_KEXEC
|
||||
kexec_reinit = kirkwood_enable_pcie;
|
||||
|
|
|
@ -16,11 +16,8 @@
|
|||
#include <linux/of_fdt.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
#include <linux/mv643xx_eth.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/gpio_keys.h>
|
||||
#include <asm/mach/arch.h>
|
||||
#include <mach/kirkwood.h>
|
||||
#include "common.h"
|
||||
|
@ -44,57 +41,12 @@ static unsigned int iconnect_mpp_config[] __initdata = {
|
|||
0
|
||||
};
|
||||
|
||||
static struct mtd_partition iconnect_nand_parts[] = {
|
||||
{
|
||||
.name = "flash",
|
||||
.offset = 0,
|
||||
.size = MTDPART_SIZ_FULL,
|
||||
},
|
||||
};
|
||||
|
||||
/* yikes... theses are the original input buttons */
|
||||
/* but I'm not convinced by the sw event choices */
|
||||
static struct gpio_keys_button iconnect_buttons[] = {
|
||||
{
|
||||
.type = EV_SW,
|
||||
.code = SW_LID,
|
||||
.gpio = 12,
|
||||
.desc = "Reset Button",
|
||||
.active_low = 1,
|
||||
.debounce_interval = 100,
|
||||
}, {
|
||||
.type = EV_SW,
|
||||
.code = SW_TABLET_MODE,
|
||||
.gpio = 35,
|
||||
.desc = "OTB Button",
|
||||
.active_low = 1,
|
||||
.debounce_interval = 100,
|
||||
},
|
||||
};
|
||||
|
||||
static struct gpio_keys_platform_data iconnect_button_data = {
|
||||
.buttons = iconnect_buttons,
|
||||
.nbuttons = ARRAY_SIZE(iconnect_buttons),
|
||||
};
|
||||
|
||||
static struct platform_device iconnect_button_device = {
|
||||
.name = "gpio-keys",
|
||||
.id = -1,
|
||||
.num_resources = 0,
|
||||
.dev = {
|
||||
.platform_data = &iconnect_button_data,
|
||||
},
|
||||
};
|
||||
|
||||
void __init iconnect_init(void)
|
||||
{
|
||||
kirkwood_mpp_conf(iconnect_mpp_config);
|
||||
kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25);
|
||||
|
||||
kirkwood_ehci_init();
|
||||
kirkwood_ge00_init(&iconnect_ge00_data);
|
||||
|
||||
platform_device_register(&iconnect_button_device);
|
||||
}
|
||||
|
||||
static int __init iconnect_pci_init(void)
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include <linux/clk.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <crypto/sha.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_irq.h>
|
||||
|
||||
#include "mv_cesa.h"
|
||||
|
||||
|
@ -1062,7 +1065,10 @@ static int mv_probe(struct platform_device *pdev)
|
|||
goto err_unmap_reg;
|
||||
}
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (pdev->dev.of_node)
|
||||
irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
|
||||
else
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0 || irq == NO_IRQ) {
|
||||
ret = irq;
|
||||
goto err_unmap_sram;
|
||||
|
@ -1170,12 +1176,19 @@ static int mv_remove(struct platform_device *pdev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id mv_cesa_of_match_table[] = {
|
||||
{ .compatible = "marvell,orion-crypto", },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
|
||||
|
||||
static struct platform_driver marvell_crypto = {
|
||||
.probe = mv_probe,
|
||||
.remove = mv_remove,
|
||||
.remove = __devexit_p(mv_remove),
|
||||
.driver = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "mv_crypto",
|
||||
.of_match_table = of_match_ptr(mv_cesa_of_match_table),
|
||||
},
|
||||
};
|
||||
MODULE_ALIAS("platform:mv_crypto");
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <linux/hwmon.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio-fan.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
struct gpio_fan_data {
|
||||
struct platform_device *pdev;
|
||||
|
@ -400,14 +402,131 @@ static ssize_t show_name(struct device *dev,
|
|||
|
||||
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
|
||||
|
||||
|
||||
#ifdef CONFIG_OF_GPIO
|
||||
/*
|
||||
* Translate OpenFirmware node properties into platform_data
|
||||
*/
|
||||
static int gpio_fan_get_of_pdata(struct device *dev,
|
||||
struct gpio_fan_platform_data *pdata)
|
||||
{
|
||||
struct device_node *node;
|
||||
struct gpio_fan_speed *speed;
|
||||
unsigned *ctrl;
|
||||
unsigned i;
|
||||
u32 u;
|
||||
struct property *prop;
|
||||
const __be32 *p;
|
||||
|
||||
node = dev->of_node;
|
||||
|
||||
/* Fill GPIO pin array */
|
||||
pdata->num_ctrl = of_gpio_count(node);
|
||||
if (!pdata->num_ctrl) {
|
||||
dev_err(dev, "gpios DT property empty / missing");
|
||||
return -ENODEV;
|
||||
}
|
||||
ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned),
|
||||
GFP_KERNEL);
|
||||
if (!ctrl)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < pdata->num_ctrl; i++) {
|
||||
int val;
|
||||
|
||||
val = of_get_gpio(node, i);
|
||||
if (val < 0)
|
||||
return val;
|
||||
ctrl[i] = val;
|
||||
}
|
||||
pdata->ctrl = ctrl;
|
||||
|
||||
/* Get number of RPM/ctrl_val pairs in speed map */
|
||||
prop = of_find_property(node, "gpio-fan,speed-map", &i);
|
||||
if (!prop) {
|
||||
dev_err(dev, "gpio-fan,speed-map DT property missing");
|
||||
return -ENODEV;
|
||||
}
|
||||
i = i / sizeof(u32);
|
||||
if (i == 0 || i & 1) {
|
||||
dev_err(dev, "gpio-fan,speed-map contains zero/odd number of entries");
|
||||
return -ENODEV;
|
||||
}
|
||||
pdata->num_speed = i / 2;
|
||||
|
||||
/*
|
||||
* Populate speed map
|
||||
* Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
|
||||
* this needs splitting into pairs to create gpio_fan_speed structs
|
||||
*/
|
||||
speed = devm_kzalloc(dev,
|
||||
pdata->num_speed * sizeof(struct gpio_fan_speed),
|
||||
GFP_KERNEL);
|
||||
if (!speed)
|
||||
return -ENOMEM;
|
||||
p = NULL;
|
||||
for (i = 0; i < pdata->num_speed; i++) {
|
||||
p = of_prop_next_u32(prop, p, &u);
|
||||
if (!p)
|
||||
return -ENODEV;
|
||||
speed[i].rpm = u;
|
||||
p = of_prop_next_u32(prop, p, &u);
|
||||
if (!p)
|
||||
return -ENODEV;
|
||||
speed[i].ctrl_val = u;
|
||||
}
|
||||
pdata->speed = speed;
|
||||
|
||||
/* Alarm GPIO if one exists */
|
||||
if (of_gpio_named_count(node, "alarm-gpios")) {
|
||||
struct gpio_fan_alarm *alarm;
|
||||
int val;
|
||||
enum of_gpio_flags flags;
|
||||
|
||||
alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm),
|
||||
GFP_KERNEL);
|
||||
if (!alarm)
|
||||
return -ENOMEM;
|
||||
|
||||
val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags);
|
||||
if (val < 0)
|
||||
return val;
|
||||
alarm->gpio = val;
|
||||
alarm->active_low = flags & OF_GPIO_ACTIVE_LOW;
|
||||
|
||||
pdata->alarm = alarm;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct of_device_id of_gpio_fan_match[] __devinitdata = {
|
||||
{ .compatible = "gpio-fan", },
|
||||
{},
|
||||
};
|
||||
#endif /* CONFIG_OF_GPIO */
|
||||
|
||||
static int __devinit gpio_fan_probe(struct platform_device *pdev)
|
||||
{
|
||||
int err;
|
||||
struct gpio_fan_data *fan_data;
|
||||
struct gpio_fan_platform_data *pdata = pdev->dev.platform_data;
|
||||
|
||||
#ifdef CONFIG_OF_GPIO
|
||||
if (!pdata) {
|
||||
pdata = devm_kzalloc(&pdev->dev,
|
||||
sizeof(struct gpio_fan_platform_data),
|
||||
GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return -ENOMEM;
|
||||
|
||||
err = gpio_fan_get_of_pdata(&pdev->dev, pdata);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
#else /* CONFIG_OF_GPIO */
|
||||
if (!pdata)
|
||||
return -EINVAL;
|
||||
#endif /* CONFIG_OF_GPIO */
|
||||
|
||||
fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data),
|
||||
GFP_KERNEL);
|
||||
|
@ -511,6 +630,7 @@ static struct platform_driver gpio_fan_driver = {
|
|||
.driver = {
|
||||
.name = "gpio-fan",
|
||||
.pm = GPIO_FAN_PM,
|
||||
.of_match_table = of_match_ptr(of_gpio_fan_match),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue