fsi: master-gpio: Add support for link_config

To configure the send and echo delays
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: default avatarJoel Stanley <joel@jms.id.au>
parent edc24851
...@@ -64,6 +64,8 @@ struct fsi_master_gpio { ...@@ -64,6 +64,8 @@ struct fsi_master_gpio {
bool external_mode; bool external_mode;
bool no_delays; bool no_delays;
uint32_t last_addr; uint32_t last_addr;
uint8_t t_send_delay;
uint8_t t_echo_delay;
}; };
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
...@@ -338,7 +340,7 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id) ...@@ -338,7 +340,7 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id)
static void echo_delay(struct fsi_master_gpio *master) static void echo_delay(struct fsi_master_gpio *master)
{ {
set_sda_output(master, 1); set_sda_output(master, 1);
clock_toggle(master, FSI_ECHO_DELAY_CLOCKS); clock_toggle(master, master->t_echo_delay);
} }
static void build_term_command(struct fsi_gpio_msg *cmd, uint8_t slave_id) static void build_term_command(struct fsi_gpio_msg *cmd, uint8_t slave_id)
...@@ -540,7 +542,7 @@ static int poll_for_response(struct fsi_master_gpio *master, ...@@ -540,7 +542,7 @@ static int poll_for_response(struct fsi_master_gpio *master,
* from receive of response back to send of data. * from receive of response back to send of data.
*/ */
local_irq_save(flags); local_irq_save(flags);
clock_zeros(master, FSI_SEND_DELAY_CLOCKS); clock_zeros(master, master->t_send_delay);
local_irq_restore(flags); local_irq_restore(flags);
return rc; return rc;
...@@ -722,6 +724,22 @@ static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link) ...@@ -722,6 +724,22 @@ static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
return rc; return rc;
} }
static int fsi_master_gpio_link_config(struct fsi_master *_master, int link,
u8 t_send_delay, u8 t_echo_delay)
{
struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
if (link != 0)
return -ENODEV;
mutex_lock(&master->cmd_lock);
master->t_send_delay = t_send_delay;
master->t_echo_delay = t_echo_delay;
mutex_unlock(&master->cmd_lock);
return 0;
}
static ssize_t external_mode_show(struct device *dev, static ssize_t external_mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -826,6 +844,10 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) ...@@ -826,6 +844,10 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
*/ */
master->no_delays = device_property_present(&pdev->dev, "no-gpio-delays"); master->no_delays = device_property_present(&pdev->dev, "no-gpio-delays");
/* Default FSI command delays */
master->t_send_delay = FSI_SEND_DELAY_CLOCKS;
master->t_echo_delay = FSI_ECHO_DELAY_CLOCKS;
master->master.n_links = 1; master->master.n_links = 1;
master->master.flags = FSI_MASTER_FLAG_SWCLOCK; master->master.flags = FSI_MASTER_FLAG_SWCLOCK;
master->master.read = fsi_master_gpio_read; master->master.read = fsi_master_gpio_read;
...@@ -833,6 +855,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) ...@@ -833,6 +855,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
master->master.term = fsi_master_gpio_term; master->master.term = fsi_master_gpio_term;
master->master.send_break = fsi_master_gpio_break; master->master.send_break = fsi_master_gpio_break;
master->master.link_enable = fsi_master_gpio_link_enable; master->master.link_enable = fsi_master_gpio_link_enable;
master->master.link_config = fsi_master_gpio_link_config;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
mutex_init(&master->cmd_lock); mutex_init(&master->cmd_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment