linux/drivers/w1/masters/ds2482.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ds2482.c - provides i2c to w1-master bridge(s)
 * Copyright (C) 2005  Ben Gardner <[email protected]>
 *
 * The DS2482 is a sensor chip made by Dallas Semiconductor (Maxim).
 * It is a I2C to 1-wire bridge.
 * There are two variations: -100 and -800, which have 1 or 8 1-wire ports.
 * The complete datasheet can be obtained from MAXIM's website at:
 *   http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4382
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/delay.h>

#include <linux/w1.h>

/*
 * Allow the active pullup to be disabled, default is enabled.
 *
 * Note from the DS2482 datasheet:
 * The APU bit controls whether an active pullup (controlled slew-rate
 * transistor) or a passive pullup (Rwpu resistor) will be used to drive
 * a 1-Wire line from low to high. When APU = 0, active pullup is disabled
 * (resistor mode). Active Pullup should always be selected unless there is
 * only a single slave on the 1-Wire line.
 */
static int ds2482_active_pullup =;
module_param_named(active_pullup, ds2482_active_pullup, int, 0644);
MODULE_PARM_DESC();

/* extra configurations - e.g. 1WS */
static int extra_config;
module_param(extra_config, int, 0644);
MODULE_PARM_DESC();

/*
 * The DS2482 registers - there are 3 registers that are addressed by a read
 * pointer. The read pointer is set by the last command executed.
 *
 * To read the data, issue a register read for any address
 */
#define DS2482_CMD_RESET
#define DS2482_CMD_SET_READ_PTR
#define DS2482_CMD_CHANNEL_SELECT
#define DS2482_CMD_WRITE_CONFIG
#define DS2482_CMD_1WIRE_RESET
#define DS2482_CMD_1WIRE_SINGLE_BIT
#define DS2482_CMD_1WIRE_WRITE_BYTE
#define DS2482_CMD_1WIRE_READ_BYTE
/* Note to read the byte, Set the ReadPtr to Data then read (any addr) */
#define DS2482_CMD_1WIRE_TRIPLET

/* Values for DS2482_CMD_SET_READ_PTR */
#define DS2482_PTR_CODE_STATUS
#define DS2482_PTR_CODE_DATA
#define DS2482_PTR_CODE_CHANNEL
#define DS2482_PTR_CODE_CONFIG

/*
 * Configure Register bit definitions
 * The top 4 bits always read 0.
 * To write, the top nibble must be the 1's compl. of the low nibble.
 */
#define DS2482_REG_CFG_1WS
#define DS2482_REG_CFG_SPU
#define DS2482_REG_CFG_PPM
#define DS2482_REG_CFG_APU


/*
 * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only).
 * To set the channel, write the value at the index of the channel.
 * Read and compare against the corresponding value to verify the change.
 */
static const u8 ds2482_chan_wr[8] =;
static const u8 ds2482_chan_rd[8] =;


/*
 * Status Register bit definitions (read only)
 */
#define DS2482_REG_STS_DIR
#define DS2482_REG_STS_TSB
#define DS2482_REG_STS_SBR
#define DS2482_REG_STS_RST
#define DS2482_REG_STS_LL
#define DS2482_REG_STS_SD
#define DS2482_REG_STS_PPD
#define DS2482_REG_STS_1WB

/*
 * Client data (each client gets its own)
 */

struct ds2482_data;

struct ds2482_w1_chan {};

struct ds2482_data {};


/**
 * ds2482_calculate_config - Helper to calculate values for configuration register
 * @conf: the raw config value
 * Return: the value w/ complements that can be written to register
 */
static inline u8 ds2482_calculate_config(u8 conf)
{}


/**
 * ds2482_select_register - Sets the read pointer.
 * @pdev:		The ds2482 client pointer
 * @read_ptr:	see DS2482_PTR_CODE_xxx above
 * Return: -1 on failure, 0 on success
 */
static inline int ds2482_select_register(struct ds2482_data *pdev, u8 read_ptr)
{}

/**
 * ds2482_send_cmd - Sends a command without a parameter
 * @pdev:	The ds2482 client pointer
 * @cmd:	DS2482_CMD_RESET,
 *		DS2482_CMD_1WIRE_RESET,
 *		DS2482_CMD_1WIRE_READ_BYTE
 * Return: -1 on failure, 0 on success
 */
static inline int ds2482_send_cmd(struct ds2482_data *pdev, u8 cmd)
{}

/**
 * ds2482_send_cmd_data - Sends a command with a parameter
 * @pdev:	The ds2482 client pointer
 * @cmd:	DS2482_CMD_WRITE_CONFIG,
 *		DS2482_CMD_1WIRE_SINGLE_BIT,
 *		DS2482_CMD_1WIRE_WRITE_BYTE,
 *		DS2482_CMD_1WIRE_TRIPLET
 * @byte:	The data to send
 * Return: -1 on failure, 0 on success
 */
static inline int ds2482_send_cmd_data(struct ds2482_data *pdev,
				       u8 cmd, u8 byte)
{}


/*
 * 1-Wire interface code
 */

#define DS2482_WAIT_IDLE_TIMEOUT

/**
 * ds2482_wait_1wire_idle - Waits until the 1-wire interface is idle (not busy)
 *
 * @pdev: Pointer to the device structure
 * Return: the last value read from status or -1 (failure)
 */
static int ds2482_wait_1wire_idle(struct ds2482_data *pdev)
{}

/**
 * ds2482_set_channel - Selects a w1 channel.
 * The 1-wire interface must be idle before calling this function.
 *
 * @pdev:		The ds2482 client pointer
 * @channel:		0-7
 * Return:		-1 (failure) or 0 (success)
 */
static int ds2482_set_channel(struct ds2482_data *pdev, u8 channel)
{}


/**
 * ds2482_w1_touch_bit - Performs the touch-bit function, which writes a 0 or 1 and reads the level.
 *
 * @data:	The ds2482 channel pointer
 * @bit:	The level to write: 0 or non-zero
 * Return:	The level read: 0 or 1
 */
static u8 ds2482_w1_touch_bit(void *data, u8 bit)
{}

/**
 * ds2482_w1_triplet - Performs the triplet function, which reads two bits and writes a bit.
 * The bit written is determined by the two reads:
 *   00 => dbit, 01 => 0, 10 => 1
 *
 * @data:	The ds2482 channel pointer
 * @dbit:	The direction to choose if both branches are valid
 * Return:	b0=read1 b1=read2 b3=bit written
 */
static u8 ds2482_w1_triplet(void *data, u8 dbit)
{}

/**
 * ds2482_w1_write_byte - Performs the write byte function.
 *
 * @data:	The ds2482 channel pointer
 * @byte:	The value to write
 */
static void ds2482_w1_write_byte(void *data, u8 byte)
{}

/**
 * ds2482_w1_read_byte - Performs the read byte function.
 *
 * @data:	The ds2482 channel pointer
 * Return:	The value read
 */
static u8 ds2482_w1_read_byte(void *data)
{}


/**
 * ds2482_w1_reset_bus - Sends a reset on the 1-wire interface
 *
 * @data:	The ds2482 channel pointer
 * Return:	0=Device present, 1=No device present or error
 */
static u8 ds2482_w1_reset_bus(void *data)
{}

static u8 ds2482_w1_set_pullup(void *data, int delay)
{}


static int ds2482_probe(struct i2c_client *client)
{}

static void ds2482_remove(struct i2c_client *client)
{}

/*
 * Driver data (common to all clients)
 */
static const struct i2c_device_id ds2482_id[] =;
MODULE_DEVICE_TABLE(i2c, ds2482_id);

static struct i2c_driver ds2482_driver =;
module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();

MODULE_LICENSE();