.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /** |
---|
2 | 3 | * ds2482.c - provides i2c to w1-master bridge(s) |
---|
3 | 4 | * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> |
---|
.. | .. |
---|
7 | 8 | * There are two variations: -100 and -800, which have 1 or 8 1-wire ports. |
---|
8 | 9 | * The complete datasheet can be obtained from MAXIM's website at: |
---|
9 | 10 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4382 |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or modify |
---|
12 | | - * it under the terms of the GNU General Public License as published by |
---|
13 | | - * the Free Software Foundation; version 2 of the License. |
---|
14 | 11 | */ |
---|
15 | 12 | |
---|
16 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
36 | 33 | module_param_named(active_pullup, ds2482_active_pullup, int, 0644); |
---|
37 | 34 | MODULE_PARM_DESC(active_pullup, "Active pullup (apply to all buses): " \ |
---|
38 | 35 | "0-disable, 1-enable (default)"); |
---|
| 36 | + |
---|
| 37 | +/* extra configurations - e.g. 1WS */ |
---|
| 38 | +static int extra_config; |
---|
| 39 | +module_param(extra_config, int, S_IRUGO | S_IWUSR); |
---|
| 40 | +MODULE_PARM_DESC(extra_config, "Extra Configuration settings 1=APU,2=PPM,3=SPU,8=1WS"); |
---|
39 | 41 | |
---|
40 | 42 | /** |
---|
41 | 43 | * The DS2482 registers - there are 3 registers that are addressed by a read |
---|
.. | .. |
---|
70 | 72 | #define DS2482_REG_CFG_PPM 0x02 /* presence pulse masking */ |
---|
71 | 73 | #define DS2482_REG_CFG_APU 0x01 /* active pull-up */ |
---|
72 | 74 | |
---|
73 | | -/* extra configurations - e.g. 1WS */ |
---|
74 | | -static int extra_config; |
---|
75 | 75 | |
---|
76 | 76 | /** |
---|
77 | 77 | * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only). |
---|
.. | .. |
---|
130 | 130 | */ |
---|
131 | 131 | static inline u8 ds2482_calculate_config(u8 conf) |
---|
132 | 132 | { |
---|
| 133 | + conf |= extra_config; |
---|
| 134 | + |
---|
133 | 135 | if (ds2482_active_pullup) |
---|
134 | 136 | conf |= DS2482_REG_CFG_APU; |
---|
135 | 137 | |
---|
.. | .. |
---|
405 | 407 | /* If the chip did reset since detect, re-config it */ |
---|
406 | 408 | if (err & DS2482_REG_STS_RST) |
---|
407 | 409 | ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG, |
---|
408 | | - ds2482_calculate_config(extra_config)); |
---|
| 410 | + ds2482_calculate_config(0x00)); |
---|
409 | 411 | } |
---|
410 | 412 | |
---|
411 | 413 | mutex_unlock(&pdev->access_lock); |
---|
.. | .. |
---|
431 | 433 | ds2482_wait_1wire_idle(pdev); |
---|
432 | 434 | /* note: it seems like both SPU and APU have to be set! */ |
---|
433 | 435 | retval = ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG, |
---|
434 | | - ds2482_calculate_config(extra_config|DS2482_REG_CFG_SPU|DS2482_REG_CFG_APU)); |
---|
| 436 | + ds2482_calculate_config(DS2482_REG_CFG_SPU | |
---|
| 437 | + DS2482_REG_CFG_APU)); |
---|
435 | 438 | ds2482_wait_1wire_idle(pdev); |
---|
436 | 439 | } |
---|
437 | 440 | |
---|
.. | .. |
---|
484 | 487 | |
---|
485 | 488 | /* Set all config items to 0 (off) */ |
---|
486 | 489 | ds2482_send_cmd_data(data, DS2482_CMD_WRITE_CONFIG, |
---|
487 | | - ds2482_calculate_config(extra_config)); |
---|
| 490 | + ds2482_calculate_config(0x00)); |
---|
488 | 491 | |
---|
489 | 492 | mutex_init(&data->access_lock); |
---|
490 | 493 | |
---|
.. | .. |
---|
559 | 562 | |
---|
560 | 563 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); |
---|
561 | 564 | MODULE_DESCRIPTION("DS2482 driver"); |
---|
562 | | -module_param(extra_config, int, S_IRUGO | S_IWUSR); |
---|
563 | | -MODULE_PARM_DESC(extra_config, "Extra Configuration settings 1=APU,2=PPM,3=SPU,8=1WS"); |
---|
564 | 565 | |
---|
565 | 566 | MODULE_LICENSE("GPL"); |
---|