mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
f5919b65d4
Patch generation process: - rebase rpi/rpi-4.14.y on v4.14.89 from linux-stable - git format-patch v4.14.89 Patches skipped during rebase: - lan78xx: Read MAC address from DT if present - lan78xx: Enable LEDs and auto-negotiation - Revert "softirq: Let ksoftirqd do its job" - sc16is7xx: Fix for multi-channel stall - lan78xx: Ignore DT MAC address if already valid - lan78xx: Simple patch to prevent some crashes - tcp_write_queue_purge clears all the SKBs in the write queue - Revert "lan78xx: Simple patch to prevent some crashes" - lan78xx: Connect phy early - Arm: mm: ftrace: Only set text back to ro after kernel has been marked ro - Revert "Revert "softirq: Let ksoftirqd do its job"" - ASoC: cs4265: SOC_SINGLE register value error fix - Revert "ASoC: cs4265: SOC_SINGLE register value error fix" - Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends" - Revert "Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"" Patches dropped after rebase: - net: Add non-mainline source for rtl8192cu wlan - net: Fix rtl8192cu build errors on other platforms - brcm: adds support for BCM43341 wifi - brcmfmac: Mute expected startup 'errors' - ARM64: Fix build break for RTL8187/RTL8192CU wifi - ARM64: Enable RTL8187/RTL8192CU wifi in build config - This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator - brcmfmac: add CLM download support - brcmfmac: request_firmware_direct is quieter - Sets the BCDC priority to constant 0 - brcmfmac: Disable ARP offloading when promiscuous - brcmfmac: Avoid possible out-of-bounds read - brcmfmac: Delete redundant length check - net: rtl8192cu: Normalize indentation - net: rtl8192cu: Fix implicit fallthrough warnings - Revert "Sets the BCDC priority to constant 0" - media: cxd2880: Bump to match 4.18.y version - media: cxd2880-spi: Bump to match 4.18.y version - Revert "mm: alloc_contig: re-allow CMA to compact FS pages" - Revert "Revert "mm: alloc_contig: re-allow CMA to compact FS pages"" - cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT - 950-0421-HID-hid-bigbenff-driver-for-BigBen-Interactive-PS3OF.patch - 950-0453-Add-hid-bigbenff-to-list-of-have_special_driver-for-.patch Make I2C built-in instead of modular as in upstream defconfig; also the easiest way to get MFD_ARIZONA enabled, which is required by kmod-sound-soc-rpi-cirrus. Add missing compatible strings from 4.9/960-add-rasbperrypi-compatible.patch, using upstream names for compute modules. Add extra patch to enable the LEDs on lan78xx. Compile-tested: bcm2708, bcm2709, bcm2710 (with CONFIG_ALL_KMODS=y) Runtime-tested: bcm2708, bcm2710 Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
222 lines
6.9 KiB
Diff
222 lines
6.9 KiB
Diff
From dc2d8a486db8a21cd998b0bdb117d30b8034aceb Mon Sep 17 00:00:00 2001
|
|
From: popcornmix <popcornmix@gmail.com>
|
|
Date: Wed, 8 May 2013 11:46:50 +0100
|
|
Subject: [PATCH 058/454] enabling the realtime clock 1-wire chip DS1307 and
|
|
1-wire on GPIO4 (as a module)
|
|
|
|
1-wire: Add support for configuring pin for w1-gpio kernel module
|
|
See: https://github.com/raspberrypi/linux/pull/457
|
|
|
|
Add bitbanging pullups, use them for w1-gpio
|
|
|
|
Allows parasite power to work, uses module option pullup=1
|
|
|
|
bcm2708: Ensure 1-wire pullup is disabled by default, and expose as module parameter
|
|
|
|
Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>
|
|
|
|
w1-gpio: Add gpiopin module parameter and correctly free up gpio pull-up pin, if set
|
|
|
|
Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>
|
|
|
|
w1-gpio: Sort out the pullup/parasitic power tangle
|
|
---
|
|
drivers/w1/masters/w1-gpio.c | 69 ++++++++++++++++++++++++++++++++----
|
|
drivers/w1/w1_int.c | 14 ++++++++
|
|
drivers/w1/w1_io.c | 18 ++++++++--
|
|
include/linux/w1-gpio.h | 1 +
|
|
include/linux/w1.h | 6 ++++
|
|
5 files changed, 99 insertions(+), 9 deletions(-)
|
|
|
|
--- a/drivers/w1/masters/w1-gpio.c
|
|
+++ b/drivers/w1/masters/w1-gpio.c
|
|
@@ -22,6 +22,19 @@
|
|
|
|
#include <linux/w1.h>
|
|
|
|
+static int w1_gpio_pullup = 0;
|
|
+static int w1_gpio_pullup_orig = 0;
|
|
+module_param_named(pullup, w1_gpio_pullup, int, 0);
|
|
+MODULE_PARM_DESC(pullup, "Enable parasitic power (power on data) mode");
|
|
+static int w1_gpio_pullup_pin = -1;
|
|
+static int w1_gpio_pullup_pin_orig = -1;
|
|
+module_param_named(extpullup, w1_gpio_pullup_pin, int, 0);
|
|
+MODULE_PARM_DESC(extpullup, "GPIO external pullup pin number");
|
|
+static int w1_gpio_pin = -1;
|
|
+static int w1_gpio_pin_orig = -1;
|
|
+module_param_named(gpiopin, w1_gpio_pin, int, 0);
|
|
+MODULE_PARM_DESC(gpiopin, "GPIO pin number");
|
|
+
|
|
static u8 w1_gpio_set_pullup(void *data, int delay)
|
|
{
|
|
struct w1_gpio_platform_data *pdata = data;
|
|
@@ -66,6 +79,16 @@ static u8 w1_gpio_read_bit(void *data)
|
|
return gpio_get_value(pdata->pin) ? 1 : 0;
|
|
}
|
|
|
|
+static void w1_gpio_bitbang_pullup(void *data, u8 on)
|
|
+{
|
|
+ struct w1_gpio_platform_data *pdata = data;
|
|
+
|
|
+ if (on)
|
|
+ gpio_direction_output(pdata->pin, 1);
|
|
+ else
|
|
+ gpio_direction_input(pdata->pin);
|
|
+}
|
|
+
|
|
#if defined(CONFIG_OF)
|
|
static const struct of_device_id w1_gpio_dt_ids[] = {
|
|
{ .compatible = "w1-gpio" },
|
|
@@ -79,6 +102,7 @@ static int w1_gpio_probe_dt(struct platf
|
|
struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
|
|
struct device_node *np = pdev->dev.of_node;
|
|
int gpio;
|
|
+ u32 value;
|
|
|
|
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
|
if (!pdata)
|
|
@@ -87,6 +111,9 @@ static int w1_gpio_probe_dt(struct platf
|
|
if (of_get_property(np, "linux,open-drain", NULL))
|
|
pdata->is_open_drain = 1;
|
|
|
|
+ if (of_property_read_u32(np, "rpi,parasitic-power", &value) == 0)
|
|
+ pdata->parasitic_power = (value != 0);
|
|
+
|
|
gpio = of_get_gpio(np, 0);
|
|
if (gpio < 0) {
|
|
if (gpio != -EPROBE_DEFER)
|
|
@@ -102,7 +129,7 @@ static int w1_gpio_probe_dt(struct platf
|
|
if (gpio == -EPROBE_DEFER)
|
|
return gpio;
|
|
/* ignore other errors as the pullup gpio is optional */
|
|
- pdata->ext_pullup_enable_pin = gpio;
|
|
+ pdata->ext_pullup_enable_pin = (gpio >= 0) ? gpio : -1;
|
|
|
|
pdev->dev.platform_data = pdata;
|
|
|
|
@@ -134,6 +161,22 @@ static int w1_gpio_probe(struct platform
|
|
return -ENOMEM;
|
|
}
|
|
|
|
+ w1_gpio_pin_orig = pdata->pin;
|
|
+ w1_gpio_pullup_pin_orig = pdata->ext_pullup_enable_pin;
|
|
+ w1_gpio_pullup_orig = pdata->parasitic_power;
|
|
+
|
|
+ if(gpio_is_valid(w1_gpio_pin)) {
|
|
+ pdata->pin = w1_gpio_pin;
|
|
+ pdata->ext_pullup_enable_pin = -1;
|
|
+ pdata->parasitic_power = -1;
|
|
+ }
|
|
+ pdata->parasitic_power |= w1_gpio_pullup;
|
|
+ if(gpio_is_valid(w1_gpio_pullup_pin)) {
|
|
+ pdata->ext_pullup_enable_pin = w1_gpio_pullup_pin;
|
|
+ }
|
|
+
|
|
+ dev_info(&pdev->dev, "gpio pin %d, external pullup pin %d, parasitic power %d\n", pdata->pin, pdata->ext_pullup_enable_pin, pdata->parasitic_power);
|
|
+
|
|
err = devm_gpio_request(&pdev->dev, pdata->pin, "w1");
|
|
if (err) {
|
|
dev_err(&pdev->dev, "gpio_request (pin) failed\n");
|
|
@@ -163,6 +206,14 @@ static int w1_gpio_probe(struct platform
|
|
master->set_pullup = w1_gpio_set_pullup;
|
|
}
|
|
|
|
+ if (pdata->parasitic_power) {
|
|
+ if (pdata->is_open_drain)
|
|
+ printk(KERN_ERR "w1-gpio 'pullup'(parasitic power) "
|
|
+ "option doesn't work with open drain GPIO\n");
|
|
+ else
|
|
+ master->bitbang_pullup = w1_gpio_bitbang_pullup;
|
|
+ }
|
|
+
|
|
err = w1_add_master_device(master);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "w1_add_master device failed\n");
|
|
@@ -193,6 +244,10 @@ static int w1_gpio_remove(struct platfor
|
|
|
|
w1_remove_master_device(master);
|
|
|
|
+ pdata->pin = w1_gpio_pin_orig;
|
|
+ pdata->ext_pullup_enable_pin = w1_gpio_pullup_pin_orig;
|
|
+ pdata->parasitic_power = w1_gpio_pullup_orig;
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
--- a/drivers/w1/w1_int.c
|
|
+++ b/drivers/w1/w1_int.c
|
|
@@ -114,6 +114,20 @@ int w1_add_master_device(struct w1_bus_m
|
|
return(-EINVAL);
|
|
}
|
|
|
|
+ /* bitbanging hardware uses bitbang_pullup, other hardware uses set_pullup
|
|
+ * and takes care of timing itself */
|
|
+ if (!master->write_byte && !master->touch_bit && master->set_pullup) {
|
|
+ printk(KERN_ERR "w1_add_master_device: set_pullup requires "
|
|
+ "write_byte or touch_bit, disabling\n");
|
|
+ master->set_pullup = NULL;
|
|
+ }
|
|
+
|
|
+ if (master->set_pullup && master->bitbang_pullup) {
|
|
+ printk(KERN_ERR "w1_add_master_device: set_pullup should not "
|
|
+ "be set when bitbang_pullup is used, disabling\n");
|
|
+ master->set_pullup = NULL;
|
|
+ }
|
|
+
|
|
/* Lock until the device is added (or not) to w1_masters. */
|
|
mutex_lock(&w1_mlock);
|
|
/* Search for the first available id (starting at 1). */
|
|
--- a/drivers/w1/w1_io.c
|
|
+++ b/drivers/w1/w1_io.c
|
|
@@ -126,10 +126,22 @@ static void w1_pre_write(struct w1_maste
|
|
static void w1_post_write(struct w1_master *dev)
|
|
{
|
|
if (dev->pullup_duration) {
|
|
- if (dev->enable_pullup && dev->bus_master->set_pullup)
|
|
- dev->bus_master->set_pullup(dev->bus_master->data, 0);
|
|
- else
|
|
+ if (dev->enable_pullup) {
|
|
+ if (dev->bus_master->set_pullup) {
|
|
+ dev->bus_master->set_pullup(dev->
|
|
+ bus_master->data,
|
|
+ 0);
|
|
+ } else if (dev->bus_master->bitbang_pullup) {
|
|
+ dev->bus_master->
|
|
+ bitbang_pullup(dev->bus_master->data, 1);
|
|
msleep(dev->pullup_duration);
|
|
+ dev->bus_master->
|
|
+ bitbang_pullup(dev->bus_master->data, 0);
|
|
+ }
|
|
+ } else {
|
|
+ msleep(dev->pullup_duration);
|
|
+ }
|
|
+
|
|
dev->pullup_duration = 0;
|
|
}
|
|
}
|
|
--- a/include/linux/w1-gpio.h
|
|
+++ b/include/linux/w1-gpio.h
|
|
@@ -18,6 +18,7 @@
|
|
struct w1_gpio_platform_data {
|
|
unsigned int pin;
|
|
unsigned int is_open_drain:1;
|
|
+ unsigned int parasitic_power:1;
|
|
void (*enable_external_pullup)(int enable);
|
|
unsigned int ext_pullup_enable_pin;
|
|
unsigned int pullup_duration;
|
|
--- a/include/linux/w1.h
|
|
+++ b/include/linux/w1.h
|
|
@@ -157,6 +157,12 @@ struct w1_bus_master {
|
|
|
|
u8 (*set_pullup)(void *, int);
|
|
|
|
+ /**
|
|
+ * Turns the pullup on/off in bitbanging mode, takes an on/off argument.
|
|
+ * @return -1=Error, 0=completed
|
|
+ */
|
|
+ void (*bitbang_pullup) (void *, u8);
|
|
+
|
|
void (*search)(void *, struct w1_master *,
|
|
u8, w1_slave_found_callback);
|
|
};
|