hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/w1/masters/ds2482.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * ds2482.c - provides i2c to w1-master bridge(s)
34 * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
....@@ -7,10 +8,6 @@
78 * There are two variations: -100 and -800, which have 1 or 8 1-wire ports.
89 * The complete datasheet can be obtained from MAXIM's website at:
910 * 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.
1411 */
1512
1613 #include <linux/module.h>
....@@ -36,6 +33,11 @@
3633 module_param_named(active_pullup, ds2482_active_pullup, int, 0644);
3734 MODULE_PARM_DESC(active_pullup, "Active pullup (apply to all buses): " \
3835 "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");
3941
4042 /**
4143 * The DS2482 registers - there are 3 registers that are addressed by a read
....@@ -70,8 +72,6 @@
7072 #define DS2482_REG_CFG_PPM 0x02 /* presence pulse masking */
7173 #define DS2482_REG_CFG_APU 0x01 /* active pull-up */
7274
73
-/* extra configurations - e.g. 1WS */
74
-static int extra_config;
7575
7676 /**
7777 * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only).
....@@ -130,6 +130,8 @@
130130 */
131131 static inline u8 ds2482_calculate_config(u8 conf)
132132 {
133
+ conf |= extra_config;
134
+
133135 if (ds2482_active_pullup)
134136 conf |= DS2482_REG_CFG_APU;
135137
....@@ -405,7 +407,7 @@
405407 /* If the chip did reset since detect, re-config it */
406408 if (err & DS2482_REG_STS_RST)
407409 ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
408
- ds2482_calculate_config(extra_config));
410
+ ds2482_calculate_config(0x00));
409411 }
410412
411413 mutex_unlock(&pdev->access_lock);
....@@ -431,7 +433,8 @@
431433 ds2482_wait_1wire_idle(pdev);
432434 /* note: it seems like both SPU and APU have to be set! */
433435 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));
435438 ds2482_wait_1wire_idle(pdev);
436439 }
437440
....@@ -484,7 +487,7 @@
484487
485488 /* Set all config items to 0 (off) */
486489 ds2482_send_cmd_data(data, DS2482_CMD_WRITE_CONFIG,
487
- ds2482_calculate_config(extra_config));
490
+ ds2482_calculate_config(0x00));
488491
489492 mutex_init(&data->access_lock);
490493
....@@ -559,7 +562,5 @@
559562
560563 MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
561564 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");
564565
565566 MODULE_LICENSE("GPL");