fsi: Add support for device-tree provided chip IDs
They get retrieved from the device-tree and exposed as an attribute in sysfs Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
e13c542d52
commit
0a213777d1
@ -80,6 +80,7 @@ struct fsi_slave {
|
||||
struct fsi_master *master;
|
||||
int id;
|
||||
int link;
|
||||
int chip_id;
|
||||
uint32_t size; /* size of slave address space */
|
||||
u8 t_send_delay;
|
||||
u8 t_echo_delay;
|
||||
@ -717,6 +718,17 @@ static ssize_t slave_send_echo_store(struct device *dev,
|
||||
static DEVICE_ATTR(send_echo_delays, 0600,
|
||||
slave_send_echo_show, slave_send_echo_store);
|
||||
|
||||
static ssize_t chip_id_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct fsi_slave *slave = to_fsi_slave(dev);
|
||||
|
||||
return sprintf(buf, "%d\n", slave->chip_id);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RO(chip_id);
|
||||
|
||||
static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
|
||||
{
|
||||
uint32_t chip_id;
|
||||
@ -780,6 +792,14 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
|
||||
slave->t_send_delay = 16;
|
||||
slave->t_echo_delay = 16;
|
||||
|
||||
/* Get chip ID if any */
|
||||
slave->chip_id = -1;
|
||||
if (slave->dev.of_node) {
|
||||
uint32_t prop;
|
||||
if (!of_property_read_u32(slave->dev.of_node, "chip-id", &prop))
|
||||
slave->chip_id = prop;
|
||||
|
||||
}
|
||||
rc = fsi_slave_set_smode(slave);
|
||||
if (rc) {
|
||||
dev_warn(&master->dev,
|
||||
@ -814,6 +834,10 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
|
||||
if (rc)
|
||||
dev_warn(&slave->dev, "failed to create delay attr: %d\n", rc);
|
||||
|
||||
rc = device_create_file(&slave->dev, &dev_attr_chip_id);
|
||||
if (rc)
|
||||
dev_warn(&slave->dev, "failed to create chip id: %d\n", rc);
|
||||
|
||||
rc = fsi_slave_scan(slave);
|
||||
if (rc)
|
||||
dev_dbg(&master->dev, "failed during slave scan with: %d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user