diff options
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/masters/ds1wm.c | 58 | ||||
-rw-r--r-- | drivers/w1/masters/mxc_w1.c | 2 | ||||
-rw-r--r-- | drivers/w1/masters/omap_hdq.c | 4 | ||||
-rw-r--r-- | drivers/w1/masters/w1-gpio.c | 2 | ||||
-rw-r--r-- | drivers/w1/slaves/Kconfig | 6 | ||||
-rw-r--r-- | drivers/w1/slaves/Makefile | 1 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2433.c | 7 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_therm.c | 2 | ||||
-rw-r--r-- | drivers/w1/w1_io.c | 16 |
9 files changed, 53 insertions, 45 deletions
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c index 29e144f81cbe..37f08c850608 100644 --- a/drivers/w1/masters/ds1wm.c +++ b/drivers/w1/masters/ds1wm.c | |||
@@ -16,10 +16,10 @@ | |||
16 | #include <linux/irq.h> | 16 | #include <linux/irq.h> |
17 | #include <linux/pm.h> | 17 | #include <linux/pm.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/clk.h> | ||
20 | #include <linux/err.h> | 19 | #include <linux/err.h> |
21 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
22 | #include <linux/ds1wm.h> | 21 | #include <linux/mfd/core.h> |
22 | #include <linux/mfd/ds1wm.h> | ||
23 | 23 | ||
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | 25 | ||
@@ -89,10 +89,9 @@ struct ds1wm_data { | |||
89 | void __iomem *map; | 89 | void __iomem *map; |
90 | int bus_shift; /* # of shifts to calc register offsets */ | 90 | int bus_shift; /* # of shifts to calc register offsets */ |
91 | struct platform_device *pdev; | 91 | struct platform_device *pdev; |
92 | struct ds1wm_platform_data *pdata; | 92 | struct mfd_cell *cell; |
93 | int irq; | 93 | int irq; |
94 | int active_high; | 94 | int active_high; |
95 | struct clk *clk; | ||
96 | int slave_present; | 95 | int slave_present; |
97 | void *reset_complete; | 96 | void *reset_complete; |
98 | void *read_complete; | 97 | void *read_complete; |
@@ -215,17 +214,17 @@ static int ds1wm_find_divisor(int gclk) | |||
215 | 214 | ||
216 | static void ds1wm_up(struct ds1wm_data *ds1wm_data) | 215 | static void ds1wm_up(struct ds1wm_data *ds1wm_data) |
217 | { | 216 | { |
218 | int gclk, divisor; | 217 | int divisor; |
218 | struct ds1wm_driver_data *plat = ds1wm_data->cell->driver_data; | ||
219 | 219 | ||
220 | if (ds1wm_data->pdata->enable) | 220 | if (ds1wm_data->cell->enable) |
221 | ds1wm_data->pdata->enable(ds1wm_data->pdev); | 221 | ds1wm_data->cell->enable(ds1wm_data->pdev); |
222 | 222 | ||
223 | gclk = clk_get_rate(ds1wm_data->clk); | 223 | divisor = ds1wm_find_divisor(plat->clock_rate); |
224 | clk_enable(ds1wm_data->clk); | ||
225 | divisor = ds1wm_find_divisor(gclk); | ||
226 | if (divisor == 0) { | 224 | if (divisor == 0) { |
227 | dev_err(&ds1wm_data->pdev->dev, | 225 | dev_err(&ds1wm_data->pdev->dev, |
228 | "no suitable divisor for %dHz clock\n", gclk); | 226 | "no suitable divisor for %dHz clock\n", |
227 | plat->clock_rate); | ||
229 | return; | 228 | return; |
230 | } | 229 | } |
231 | ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor); | 230 | ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor); |
@@ -244,10 +243,8 @@ static void ds1wm_down(struct ds1wm_data *ds1wm_data) | |||
244 | ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, | 243 | ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, |
245 | ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0); | 244 | ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0); |
246 | 245 | ||
247 | if (ds1wm_data->pdata->disable) | 246 | if (ds1wm_data->cell->disable) |
248 | ds1wm_data->pdata->disable(ds1wm_data->pdev); | 247 | ds1wm_data->cell->disable(ds1wm_data->pdev); |
249 | |||
250 | clk_disable(ds1wm_data->clk); | ||
251 | } | 248 | } |
252 | 249 | ||
253 | /* --------------------------------------------------------------------- */ | 250 | /* --------------------------------------------------------------------- */ |
@@ -330,13 +327,18 @@ static struct w1_bus_master ds1wm_master = { | |||
330 | static int ds1wm_probe(struct platform_device *pdev) | 327 | static int ds1wm_probe(struct platform_device *pdev) |
331 | { | 328 | { |
332 | struct ds1wm_data *ds1wm_data; | 329 | struct ds1wm_data *ds1wm_data; |
333 | struct ds1wm_platform_data *plat; | 330 | struct ds1wm_driver_data *plat; |
334 | struct resource *res; | 331 | struct resource *res; |
332 | struct mfd_cell *cell; | ||
335 | int ret; | 333 | int ret; |
336 | 334 | ||
337 | if (!pdev) | 335 | if (!pdev) |
338 | return -ENODEV; | 336 | return -ENODEV; |
339 | 337 | ||
338 | cell = pdev->dev.platform_data; | ||
339 | if (!cell) | ||
340 | return -ENODEV; | ||
341 | |||
340 | ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL); | 342 | ds1wm_data = kzalloc(sizeof(*ds1wm_data), GFP_KERNEL); |
341 | if (!ds1wm_data) | 343 | if (!ds1wm_data) |
342 | return -ENOMEM; | 344 | return -ENOMEM; |
@@ -348,15 +350,18 @@ static int ds1wm_probe(struct platform_device *pdev) | |||
348 | ret = -ENXIO; | 350 | ret = -ENXIO; |
349 | goto err0; | 351 | goto err0; |
350 | } | 352 | } |
351 | ds1wm_data->map = ioremap(res->start, res->end - res->start + 1); | 353 | ds1wm_data->map = ioremap(res->start, resource_size(res)); |
352 | if (!ds1wm_data->map) { | 354 | if (!ds1wm_data->map) { |
353 | ret = -ENOMEM; | 355 | ret = -ENOMEM; |
354 | goto err0; | 356 | goto err0; |
355 | } | 357 | } |
356 | plat = pdev->dev.platform_data; | 358 | plat = cell->driver_data; |
357 | ds1wm_data->bus_shift = plat->bus_shift; | 359 | |
360 | /* calculate bus shift from mem resource */ | ||
361 | ds1wm_data->bus_shift = resource_size(res) >> 3; | ||
362 | |||
358 | ds1wm_data->pdev = pdev; | 363 | ds1wm_data->pdev = pdev; |
359 | ds1wm_data->pdata = plat; | 364 | ds1wm_data->cell = cell; |
360 | 365 | ||
361 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 366 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
362 | if (!res) { | 367 | if (!res) { |
@@ -376,26 +381,18 @@ static int ds1wm_probe(struct platform_device *pdev) | |||
376 | if (ret) | 381 | if (ret) |
377 | goto err1; | 382 | goto err1; |
378 | 383 | ||
379 | ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm"); | ||
380 | if (IS_ERR(ds1wm_data->clk)) { | ||
381 | ret = PTR_ERR(ds1wm_data->clk); | ||
382 | goto err2; | ||
383 | } | ||
384 | |||
385 | ds1wm_up(ds1wm_data); | 384 | ds1wm_up(ds1wm_data); |
386 | 385 | ||
387 | ds1wm_master.data = (void *)ds1wm_data; | 386 | ds1wm_master.data = (void *)ds1wm_data; |
388 | 387 | ||
389 | ret = w1_add_master_device(&ds1wm_master); | 388 | ret = w1_add_master_device(&ds1wm_master); |
390 | if (ret) | 389 | if (ret) |
391 | goto err3; | 390 | goto err2; |
392 | 391 | ||
393 | return 0; | 392 | return 0; |
394 | 393 | ||
395 | err3: | ||
396 | ds1wm_down(ds1wm_data); | ||
397 | clk_put(ds1wm_data->clk); | ||
398 | err2: | 394 | err2: |
395 | ds1wm_down(ds1wm_data); | ||
399 | free_irq(ds1wm_data->irq, ds1wm_data); | 396 | free_irq(ds1wm_data->irq, ds1wm_data); |
400 | err1: | 397 | err1: |
401 | iounmap(ds1wm_data->map); | 398 | iounmap(ds1wm_data->map); |
@@ -434,7 +431,6 @@ static int ds1wm_remove(struct platform_device *pdev) | |||
434 | 431 | ||
435 | w1_remove_master_device(&ds1wm_master); | 432 | w1_remove_master_device(&ds1wm_master); |
436 | ds1wm_down(ds1wm_data); | 433 | ds1wm_down(ds1wm_data); |
437 | clk_put(ds1wm_data->clk); | ||
438 | free_irq(ds1wm_data->irq, ds1wm_data); | 434 | free_irq(ds1wm_data->irq, ds1wm_data); |
439 | iounmap(ds1wm_data->map); | 435 | iounmap(ds1wm_data->map); |
440 | kfree(ds1wm_data); | 436 | kfree(ds1wm_data); |
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c index b9d74d0b353e..65244c02551b 100644 --- a/drivers/w1/masters/mxc_w1.c +++ b/drivers/w1/masters/mxc_w1.c | |||
@@ -116,7 +116,7 @@ static int __init mxc_w1_probe(struct platform_device *pdev) | |||
116 | if (!mdev) | 116 | if (!mdev) |
117 | return -ENOMEM; | 117 | return -ENOMEM; |
118 | 118 | ||
119 | mdev->clk = clk_get(&pdev->dev, "owire_clk"); | 119 | mdev->clk = clk_get(&pdev->dev, "owire"); |
120 | if (!mdev->clk) { | 120 | if (!mdev->clk) { |
121 | err = -ENODEV; | 121 | err = -ENODEV; |
122 | goto failed_clk; | 122 | goto failed_clk; |
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index c973889110c8..a7e3b706b9d3 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -590,8 +590,8 @@ static int __init omap_hdq_probe(struct platform_device *pdev) | |||
590 | } | 590 | } |
591 | 591 | ||
592 | /* get interface & functional clock objects */ | 592 | /* get interface & functional clock objects */ |
593 | hdq_data->hdq_ick = clk_get(&pdev->dev, "hdq_ick"); | 593 | hdq_data->hdq_ick = clk_get(&pdev->dev, "ick"); |
594 | hdq_data->hdq_fck = clk_get(&pdev->dev, "hdq_fck"); | 594 | hdq_data->hdq_fck = clk_get(&pdev->dev, "fck"); |
595 | 595 | ||
596 | if (IS_ERR(hdq_data->hdq_ick) || IS_ERR(hdq_data->hdq_fck)) { | 596 | if (IS_ERR(hdq_data->hdq_ick) || IS_ERR(hdq_data->hdq_fck)) { |
597 | dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n"); | 597 | dev_dbg(&pdev->dev, "Can't get HDQ clock objects\n"); |
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index 9e1138a75e8b..a411702413d6 100644 --- a/drivers/w1/masters/w1-gpio.c +++ b/drivers/w1/masters/w1-gpio.c | |||
@@ -39,7 +39,7 @@ static u8 w1_gpio_read_bit(void *data) | |||
39 | { | 39 | { |
40 | struct w1_gpio_platform_data *pdata = data; | 40 | struct w1_gpio_platform_data *pdata = data; |
41 | 41 | ||
42 | return gpio_get_value(pdata->pin); | 42 | return gpio_get_value(pdata->pin) ? 1 : 0; |
43 | } | 43 | } |
44 | 44 | ||
45 | static int __init w1_gpio_probe(struct platform_device *pdev) | 45 | static int __init w1_gpio_probe(struct platform_device *pdev) |
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 8d0b1fb1e52e..1f51366417b9 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig | |||
@@ -16,6 +16,12 @@ config W1_SLAVE_SMEM | |||
16 | Say Y here if you want to connect 1-wire | 16 | Say Y here if you want to connect 1-wire |
17 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire. | 17 | simple 64bit memory rom(ds2401/ds2411/ds1990*) to your wire. |
18 | 18 | ||
19 | config W1_SLAVE_DS2431 | ||
20 | tristate "1kb EEPROM family support (DS2431)" | ||
21 | help | ||
22 | Say Y here if you want to use a 1-wire | ||
23 | 1kb EEPROM family device (DS2431) | ||
24 | |||
19 | config W1_SLAVE_DS2433 | 25 | config W1_SLAVE_DS2433 |
20 | tristate "4kb EEPROM family support (DS2433)" | 26 | tristate "4kb EEPROM family support (DS2433)" |
21 | help | 27 | help |
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile index 990f400b6d22..f1f51f19b129 100644 --- a/drivers/w1/slaves/Makefile +++ b/drivers/w1/slaves/Makefile | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o | 5 | obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o |
6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o | 6 | obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o |
7 | obj-$(CONFIG_W1_SLAVE_DS2431) += w1_ds2431.o | ||
7 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o | 8 | obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o |
8 | obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o | 9 | obj-$(CONFIG_W1_SLAVE_DS2760) += w1_ds2760.o |
9 | obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o | 10 | obj-$(CONFIG_W1_SLAVE_BQ27000) += w1_bq27000.o |
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index 858c16a544c2..139447148822 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c | |||
@@ -156,6 +156,9 @@ out_up: | |||
156 | */ | 156 | */ |
157 | static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) | 157 | static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) |
158 | { | 158 | { |
159 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC | ||
160 | struct w1_f23_data *f23 = sl->family_data; | ||
161 | #endif | ||
159 | u8 wrbuf[4]; | 162 | u8 wrbuf[4]; |
160 | u8 rdbuf[W1_PAGE_SIZE + 3]; | 163 | u8 rdbuf[W1_PAGE_SIZE + 3]; |
161 | u8 es = (addr + len - 1) & 0x1f; | 164 | u8 es = (addr + len - 1) & 0x1f; |
@@ -196,7 +199,9 @@ static int w1_f23_write(struct w1_slave *sl, int addr, int len, const u8 *data) | |||
196 | 199 | ||
197 | /* Reset the bus to wake up the EEPROM (this may not be needed) */ | 200 | /* Reset the bus to wake up the EEPROM (this may not be needed) */ |
198 | w1_reset_bus(sl->master); | 201 | w1_reset_bus(sl->master); |
199 | 202 | #ifdef CONFIG_W1_SLAVE_DS2433_CRC | |
203 | f23->validcrc &= ~(1 << (addr >> W1_PAGE_BITS)); | ||
204 | #endif | ||
200 | return 0; | 205 | return 0; |
201 | } | 206 | } |
202 | 207 | ||
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 2c8dff9f77da..1ed3d554e372 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c | |||
@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = { | |||
115 | 115 | ||
116 | static inline int w1_DS18B20_convert_temp(u8 rom[9]) | 116 | static inline int w1_DS18B20_convert_temp(u8 rom[9]) |
117 | { | 117 | { |
118 | s16 t = (rom[1] << 8) | rom[0]; | 118 | int t = ((s16)rom[1] << 8) | rom[0]; |
119 | t = t*1000/16; | 119 | t = t*1000/16; |
120 | return t; | 120 | return t; |
121 | } | 121 | } |
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index 442bd8bbd4a5..3ebe9726a9e5 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c | |||
@@ -69,7 +69,7 @@ static u8 w1_touch_bit(struct w1_master *dev, int bit) | |||
69 | return w1_read_bit(dev); | 69 | return w1_read_bit(dev); |
70 | else { | 70 | else { |
71 | w1_write_bit(dev, 0); | 71 | w1_write_bit(dev, 0); |
72 | return(0); | 72 | return 0; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
@@ -184,17 +184,17 @@ static u8 w1_read_bit(struct w1_master *dev) | |||
184 | */ | 184 | */ |
185 | u8 w1_triplet(struct w1_master *dev, int bdir) | 185 | u8 w1_triplet(struct w1_master *dev, int bdir) |
186 | { | 186 | { |
187 | if ( dev->bus_master->triplet ) | 187 | if (dev->bus_master->triplet) |
188 | return(dev->bus_master->triplet(dev->bus_master->data, bdir)); | 188 | return dev->bus_master->triplet(dev->bus_master->data, bdir); |
189 | else { | 189 | else { |
190 | u8 id_bit = w1_touch_bit(dev, 1); | 190 | u8 id_bit = w1_touch_bit(dev, 1); |
191 | u8 comp_bit = w1_touch_bit(dev, 1); | 191 | u8 comp_bit = w1_touch_bit(dev, 1); |
192 | u8 retval; | 192 | u8 retval; |
193 | 193 | ||
194 | if ( id_bit && comp_bit ) | 194 | if (id_bit && comp_bit) |
195 | return(0x03); /* error */ | 195 | return 0x03; /* error */ |
196 | 196 | ||
197 | if ( !id_bit && !comp_bit ) { | 197 | if (!id_bit && !comp_bit) { |
198 | /* Both bits are valid, take the direction given */ | 198 | /* Both bits are valid, take the direction given */ |
199 | retval = bdir ? 0x04 : 0; | 199 | retval = bdir ? 0x04 : 0; |
200 | } else { | 200 | } else { |
@@ -203,11 +203,11 @@ u8 w1_triplet(struct w1_master *dev, int bdir) | |||
203 | retval = id_bit ? 0x05 : 0x02; | 203 | retval = id_bit ? 0x05 : 0x02; |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( dev->bus_master->touch_bit ) | 206 | if (dev->bus_master->touch_bit) |
207 | w1_touch_bit(dev, bdir); | 207 | w1_touch_bit(dev, bdir); |
208 | else | 208 | else |
209 | w1_write_bit(dev, bdir); | 209 | w1_write_bit(dev, bdir); |
210 | return(retval); | 210 | return retval; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||