Skip to content

Commit 885e2ae

Browse files
Ecce_Liscorpiochang
authored andcommitted
Modify w1-gpio driver and build it as builtin mode
Change-Id: I8b9005105c671d207b0b2cbc844e693a408f92b1 Reviewed-on: https://tp-biosrd-v02/gerrit/81065 Reviewed-by: Scorpio Chang(張志賢) <Scorpio_Chang@asus.com> Tested-by: Scorpio Chang(張志賢) <Scorpio_Chang@asus.com>
1 parent a8a9c43 commit 885e2ae

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

arch/arm/configs/miniarm-rk3288_defconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,5 +778,5 @@ CONFIG_TEXTSEARCH_BM=y
778778
CONFIG_TEXTSEARCH_FSM=y
779779
CONFIG_PPS_CLIENT_GPIO=y
780780
CONFIG_POSIX_MQUEUE=y
781-
CONFIG_W1=m
782-
CONFIG_W1_GPIO=m
781+
CONFIG_W1=y
782+
CONFIG_W1_MASTER_GPIO=y

drivers/w1/masters/w1-gpio.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222

2323
#include "../w1.h"
2424
#include "../w1_int.h"
25+
static int w1_gpio_pullup_pin = -1;
26+
static int w1_gpio_pullup_pin_orig = -1;
27+
module_param_named(extpullup, w1_gpio_pullup_pin, int, 0);
28+
MODULE_PARM_DESC(extpullup, "GPIO external pullup pin number");
29+
static int w1_gpio_pin = -1;
30+
static int w1_gpio_pin_orig = -1;
31+
module_param_named(gpiopin, w1_gpio_pin, int, 0);
32+
MODULE_PARM_DESC(gpiopin, "GPIO pin number");
2533

2634
static u8 w1_gpio_set_pullup(void *data, int delay)
2735
{
@@ -103,7 +111,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
103111
if (gpio == -EPROBE_DEFER)
104112
return gpio;
105113
/* ignore other errors as the pullup gpio is optional */
106-
pdata->ext_pullup_enable_pin = gpio;
114+
pdata->ext_pullup_enable_pin = (gpio >= 0) ? gpio : -1;
107115

108116
pdev->dev.platform_data = pdata;
109117

@@ -113,13 +121,15 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
113121
static int w1_gpio_probe(struct platform_device *pdev)
114122
{
115123
struct w1_bus_master *master;
116-
struct w1_gpio_platform_data *pdata;
124+
struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
117125
int err;
118126

119-
if (of_have_populated_dt()) {
120-
err = w1_gpio_probe_dt(pdev);
121-
if (err < 0)
122-
return err;
127+
if(pdata == NULL) {
128+
if (of_have_populated_dt()) {
129+
err = w1_gpio_probe_dt(pdev);
130+
if (err < 0)
131+
return err;
132+
}
123133
}
124134

125135
pdata = dev_get_platdata(&pdev->dev);
@@ -136,6 +146,19 @@ static int w1_gpio_probe(struct platform_device *pdev)
136146
return -ENOMEM;
137147
}
138148

149+
w1_gpio_pin_orig = pdata->pin;
150+
w1_gpio_pullup_pin_orig = pdata->ext_pullup_enable_pin;
151+
152+
if(gpio_is_valid(w1_gpio_pin)) {
153+
pdata->pin = w1_gpio_pin;
154+
pdata->ext_pullup_enable_pin = -1;
155+
}
156+
if(gpio_is_valid(w1_gpio_pullup_pin)) {
157+
pdata->ext_pullup_enable_pin = w1_gpio_pullup_pin;
158+
}
159+
160+
dev_info(&pdev->dev, "gpio pin %d, external pullup pin %d\n", pdata->pin, pdata->ext_pullup_enable_pin);
161+
139162
err = devm_gpio_request(&pdev->dev, pdata->pin, "w1");
140163
if (err) {
141164
dev_err(&pdev->dev, "gpio_request (pin) failed\n");
@@ -195,6 +218,9 @@ static int w1_gpio_remove(struct platform_device *pdev)
195218

196219
w1_remove_master_device(master);
197220

221+
pdata->pin = w1_gpio_pin_orig;
222+
pdata->ext_pullup_enable_pin = w1_gpio_pullup_pin_orig;
223+
198224
return 0;
199225
}
200226

0 commit comments

Comments
 (0)