fsi: Fixes and Coldfire coprocessor offload
Subsystems (6)
cover fsi: Fixes and Coldfire coprocessor offload
This series implements support for offloading the FSI protocol bitbanging to the ColdFire secondary core of the Aspeed SoCs. The result increases FSI performance by a factor of 4, and on systems that don't support async FSI clock, provide much more regular and continuous clocking which helps reliability.
Patch 1 may go a different route and was already posted a few weeks ago, I included it for completeness.
Patches 2..9 add some infrastructure to the FSI core to control some of the FSI protocol delays and adjustements/fixes to the existing GPIO bitbanging master. They are "mechanical" dependencies
Patch 10 moves some protocol definitions to a common place where the new master driver can find them
Patch 11 is the DT binding for the new driver with comes with patch 12
Finally patch 13 and 14 update the Romulus and Palmetto board device-trees to use the new driver.
There's another dependency on the Aspeed GPIO driver changes for handling with GPIO lines ownership and handshaking. The patches have been submitted and can be found for reference there:
https://github.com/ozbenh/linux-ast/commits/gpio
Finally, the driver needs a machine specific firmware file. The firwmare is open source and available at:
https://github.com/ozbenh/cf-fsi
I will submit it to linux-firmware if there's enough popular demand ;-)
PATCH 1/14 devres: Add devm_of_iomap()
There are still quite a few cases where a device might want to get to a different node of the device-tree, obtain the resources and map them.
We have of_iomap() and of_io_request_and_map() but they both have shortcomings, such as not returning the size of the resource found (which can be useful) and not being "managed".
This adds a devm_of_iomap() that provides all of these and should probably replace uses of the above in most drivers.
--- include/linux/device.h | 4 ++++ lib/devres.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
include/linux/device.h +4 -0
@@ -688,6 +688,10 @@ extern void devm_free_pages(struct device *dev, unsigned long addr);void __iomem *devm_ioremap_resource (struct device *dev,struct resource *res); +void __iomem *devm_of_iomap (struct device *dev, +struct device_node *node,int index, +resource_size_t *size); +/* allows to add/remove a custom action to devres stack */ int devm_add_action (struct device *dev,void (*action)(void *),void *data);void devm_remove_action (struct device *dev,void (*action)(void *),void *data);
lib/devres.c +36 -0
@@ -4,6 +4,7 @@#include <linux/io.h> #include <linux/gfp.h> #include <linux/export.h> +#include <linux/of_address.h> enum devm_ioremap_type {DEVM_IOREMAP =0 ,
@@ -162,6 +163,41 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res) }EXPORT_SYMBOL (devm_ioremap_resource); +/* +* devm_of_iomap - Requests a resource and maps the memory mapped IO +* for a given device_node managed by a given device +* +* Checks that a resource is a valid memory region, requests the memory +* region and ioremaps it. All operations are managed and will be undone +* on driver detach of the device. +* +* This is to be used when a device requests/maps resources described +* by other device tree nodes (children or otherwise). +* +* @dev: The device "managing" the resource +* @node: The device-tree node where the resource resides +* @index: index of the MMIO range in the "reg" property +* @size: Returns the size of the resource (pass NULL if not needed) +* Returns a pointer to the requested and mapped memory or an ERR_PTR() encoded +* error code on failure. Usage example: +* +* base = devm_of_iomap(&pdev->dev, node, 0, NULL); +* if (IS_ERR(base)) +* return PTR_ERR(base); +*/ +void __iomem *devm_of_iomap (struct device *dev,struct device_node *node,int index, +resource_size_t *size) +{ +struct resource res; + +if (of_address_to_resource (node, index, &res)) +return IOMEM_ERR_PTR (-EINVAL ); +if (size) + *size =resource_size (&res); +return devm_ioremap_resource (dev, &res); +} +EXPORT_SYMBOL (devm_of_iomap); +#ifdef CONFIG_HAS_IOPORT_MAP /* * Generic iomap devres
Signature · 1 line
2.17.1
PATCH 2/14 fsi: Move code around to avoid forward declaration
In reply to Benjamin HerrenschmidtMove fsi_slave_set_smode() and its helpers to before it's first user and remove the corresponding forward declaration.
--- drivers/fsi/fsi-core.c | 94 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 48 deletions(-)
drivers/fsi/fsi-core.c +46 -48
@@ -215,7 +215,52 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) &irq, sizeof(irq)); } -static int fsi_slave_set_smode (struct fsi_master *master,int link,int id); +/* Encode slave local bus echo delay */ +static inline uint32_t fsi_smode_echodly (int x) +{ +return (x &FSI_SMODE_ED_MASK ) <<FSI_SMODE_ED_SHIFT ; +} + +/* Encode slave local bus send delay */ +static inline uint32_t fsi_smode_senddly (int x) +{ +return (x &FSI_SMODE_SD_MASK ) <<FSI_SMODE_SD_SHIFT ; +} + +/* Encode slave local bus clock rate ratio */ +static inline uint32_t fsi_smode_lbcrr (int x) +{ +return (x &FSI_SMODE_LBCRR_MASK ) <<FSI_SMODE_LBCRR_SHIFT ; +} + +/* Encode slave ID */ +static inline uint32_t fsi_smode_sid (int x) +{ +return (x &FSI_SMODE_SID_MASK ) <<FSI_SMODE_SID_SHIFT ; +} + +static uint32_t fsi_slave_smode (int id) +{ +return FSI_SMODE_WSC |FSI_SMODE_ECRC + |fsi_smode_sid (id) + |fsi_smode_echodly (0xf ) |fsi_smode_senddly (0xf ) + |fsi_smode_lbcrr (0x8 ); +} + +static int fsi_slave_set_smode (struct fsi_master *master,int link,int id) +{ +uint32_t smode; +__be32 data; + +/* set our smode register with the slave ID field to 0; this enables +* extended slave addressing +*/ + smode =fsi_slave_smode (id); + data =cpu_to_be32 (smode); + +return fsi_master_write (master, link, id,FSI_SLAVE_BASE +FSI_SMODE , + &data,sizeof (data)); +}static int fsi_slave_handle_error (struct fsi_slave *slave,bool write,uint32_t addr,size_t size)
@@ -569,53 +614,6 @@ static const struct bin_attribute fsi_slave_term_attr = { .write = fsi_slave_sysfs_term_write, }; -/* Encode slave local bus echo delay */ -static inline uint32_t fsi_smode_echodly (int x) -{ -return (x &FSI_SMODE_ED_MASK ) <<FSI_SMODE_ED_SHIFT ; -} - -/* Encode slave local bus send delay */ -static inline uint32_t fsi_smode_senddly (int x) -{ -return (x &FSI_SMODE_SD_MASK ) <<FSI_SMODE_SD_SHIFT ; -} - -/* Encode slave local bus clock rate ratio */ -static inline uint32_t fsi_smode_lbcrr (int x) -{ -return (x &FSI_SMODE_LBCRR_MASK ) <<FSI_SMODE_LBCRR_SHIFT ; -} - -/* Encode slave ID */ -static inline uint32_t fsi_smode_sid (int x) -{ -return (x &FSI_SMODE_SID_MASK ) <<FSI_SMODE_SID_SHIFT ; -} - -static uint32_t fsi_slave_smode (int id) -{ -return FSI_SMODE_WSC |FSI_SMODE_ECRC - |fsi_smode_sid (id) - |fsi_smode_echodly (0xf ) |fsi_smode_senddly (0xf ) - |fsi_smode_lbcrr (0x8 ); -} - -static int fsi_slave_set_smode (struct fsi_master *master,int link,int id) -{ -uint32_t smode; -__be32 data; - -/* set our smode register with the slave ID field to 0; this enables -* extended slave addressing -*/ - smode =fsi_slave_smode (id); - data =cpu_to_be32 (smode); - -return fsi_master_write (master, link, id,FSI_SLAVE_BASE +FSI_SMODE , - &data,sizeof (data)); -} -static void fsi_slave_release (struct device *dev) {struct fsi_slave *slave =to_fsi_slave (dev);
Signature · 1 line
2.17.1
PATCH 3/14 fsi: Add mechanism to set the tSendDelay and tEchoDelay values
In reply to Benjamin HerrenschmidtThose values control the amount of "dummy" clocks between commands and between a command and its response.
This adds a way to configure them from sysfs (to be later extended to defaults in the device-tree). The default remains 16 (the HW default).
This is only supported if the backend supports the new link_config() callback to configure the generation of those delays.
---
--- drivers/fsi/fsi-core.c | 109 ++++++++++++++++++++++++++++++++------- drivers/fsi/fsi-master.h | 2 + 2 files changed, 93 insertions(+), 18 deletions(-)
drivers/fsi/fsi-core.c +91 -18
@@ -81,6 +81,8 @@ struct fsi_slave {int id;int link;uint32_t size;/* size of slave address space */ +u8 t_send_delay; +u8 t_echo_delay; };#define to_fsi_master (d) container_of(d, struct fsi_master, dev)
@@ -239,15 +241,15 @@ static inline uint32_t fsi_smode_sid(int x)return (x &FSI_SMODE_SID_MASK ) <<FSI_SMODE_SID_SHIFT ; } -static uint32_t fsi_slave_smode (int id) +static uint32_t fsi_slave_smode (int id,u8 t_senddly,u8 t_echodly) {return FSI_SMODE_WSC |FSI_SMODE_ECRC |fsi_smode_sid (id) - |fsi_smode_echodly (0xf ) |fsi_smode_senddly (0xf ) + |fsi_smode_echodly (t_echodly -1 ) |fsi_smode_senddly (t_senddly -1 ) |fsi_smode_lbcrr (0x8 ); } -static int fsi_slave_set_smode (struct fsi_master *master,int link,int id) +static int fsi_slave_set_smode (struct fsi_slave *slave) {uint32_t smode;__be32 data;
@@ -255,11 +257,12 @@ static int fsi_slave_set_smode(struct fsi_master *master, int link, int id)/* set our smode register with the slave ID field to 0; this enables * extended slave addressing */ - smode =fsi_slave_smode (id); + smode =fsi_slave_smode (slave->id, slave->t_send_delay, slave->t_echo_delay); data =cpu_to_be32 (smode); -return fsi_master_write (master, link, id,FSI_SLAVE_BASE +FSI_SMODE , - &data,sizeof (data)); +return fsi_master_write (slave->master, slave->link, slave->id, +FSI_SLAVE_BASE +FSI_SMODE , + &data,sizeof (data)); } static int fsi_slave_handle_error(struct fsi_slave *slave, bool write,
@@ -268,7 +271,7 @@ static int fsi_slave_handle_error(struct fsi_slave *slave, bool write,struct fsi_master *master = slave->master;int rc, link;uint32_t reg; -uint8_t id; +uint8_t id, send_delay, echo_delay;if (discard_errors)return -1 ;
@@ -299,15 +302,26 @@ static int fsi_slave_handle_error(struct fsi_slave *slave, bool write, } } + send_delay = slave->t_send_delay; + echo_delay = slave->t_echo_delay; +/* getting serious, reset the slave via BREAK */ rc =fsi_master_break (master, link);if (rc)return rc; - rc =fsi_slave_set_smode (master, link, id); + slave->t_send_delay = send_delay; + slave->t_echo_delay = echo_delay; + + rc =fsi_slave_set_smode (slave);if (rc)return rc; +if (master->link_config) + master->link_config (master, link, + slave->t_send_delay, + slave->t_echo_delay); +return fsi_slave_report_and_clear_errors (slave); }
@@ -665,6 +679,50 @@ static struct device_node *fsi_slave_find_of_node(struct fsi_master *master,return NULL ; } +static ssize_t slave_send_echo_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct fsi_slave *slave =to_fsi_slave (dev); + +return sprintf (buf,"%u\n" , slave->t_send_delay); +} + +static ssize_t slave_send_echo_store (struct device *dev, +struct device_attribute *attr,const char *buf,size_t count) +{ +struct fsi_slave *slave =to_fsi_slave (dev); +struct fsi_master *master = slave->master; +unsigned long val; +int rc; + +if (kstrtoul (buf,0 , &val) <0 ) +return -EINVAL ; + +if (val <1 || val >16 ) +return -EINVAL ; + +if (!master->link_config) +return -ENXIO ; + +/* Current HW mandates that send and echo delay are identical */ + slave->t_send_delay = val; + slave->t_echo_delay = val; + + rc =fsi_slave_set_smode (slave); +if (rc <0 ) +return rc; +if (master->link_config) + master->link_config (master, slave->link, + slave->t_send_delay, + slave->t_echo_delay); + +return count; +} + +static DEVICE_ATTR(send_echo_delays, 0600, + slave_send_echo_show, slave_send_echo_store); +static int fsi_slave_init (struct fsi_master *master,int link,uint8_t id) {uint32_t chip_id;
@@ -697,14 +755,6 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)dev_dbg (&master->dev,"fsi: found chip %08x at %02x:%02x:%02x\n" , chip_id, master->idx, link, id); - rc =fsi_slave_set_smode (master, link, id); -if (rc) { -dev_warn (&master->dev, -"can't set smode on slave:%02x:%02x %d\n" , - link, id, rc); -return -ENODEV ; - } -/* If we're behind a master that doesn't provide a self-running bus * clock, put the slave into async mode */
@@ -733,6 +783,21 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) slave->link = link; slave->id = id; slave->size = FSI_SLAVE_SIZE_23b; + slave->t_send_delay =16 ; + slave->t_echo_delay =16 ; + + rc =fsi_slave_set_smode (slave); +if (rc) { +dev_warn (&master->dev, +"can't set smode on slave:%02x:%02x %d\n" , + link, id, rc); +kfree (slave); +return -ENODEV ; + } +if (master->link_config) + master->link_config (master, link, + slave->t_send_delay, + slave->t_echo_delay);dev_set_name (&slave->dev,"slave@%02x:%02x" , link, id); rc =device_register (&slave->dev);
@@ -751,6 +816,10 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)if (rc)dev_warn (&slave->dev,"failed to create term attr: %d\n" , rc); + rc =device_create_file (&slave->dev, &dev_attr_send_echo_delays); +if (rc) +dev_warn (&slave->dev,"failed to create delay attr: %d\n" , rc); + rc =fsi_slave_scan (slave);if (rc) dev_dbg(&master->dev, "failed during slave scan with: %d\n",
@@ -821,12 +890,16 @@ static int fsi_master_link_enable(struct fsi_master *master, int link)*/ static int fsi_master_break (struct fsi_master *master,int link) { +int rc =0 ; +trace_fsi_master_break (master, link);if (master->send_break) -return master->send_break (master, link); + rc = master->send_break (master, link); +if (master->link_config) + master->link_config (master, link,16 ,16 ); -return 0 ; +return rc; }static int fsi_master_scan (struct fsi_master *master)
drivers/fsi/fsi-master.h +2 -0
@@ -33,6 +33,8 @@ struct fsi_master {int (*term)(struct fsi_master *,int link,uint8_t id);int (*send_break)(struct fsi_master *,int link);int (*link_enable)(struct fsi_master *,int link); +int (*link_config)(struct fsi_master *,int link, +u8 t_send_delay,u8 t_echo_delay); };#define dev_to_fsi_master (d) container_of(d, struct fsi_master, dev)
Signature · 1 line
2.17.1
PATCH 4/14 fsi: master-gpio: Rename and adjust send delay
In reply to Benjamin HerrenschmidtWhat the driver called "FSI_GPIO_PRIME_SLAVE_CLOCKS" is what the FSI spec calls tSendDelay and should be 16 clocks by default.
--- drivers/fsi/fsi-master-gpio.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/fsi/fsi-master-gpio.c +6 -3
@@ -18,6 +18,7 @@#define FSI_GPIO_STD_DLY 1/* Standard pin delay in nS */ #define FSI_ECHO_DELAY_CLOCKS 16/* Number clocks for echo delay */ +#define FSI_SEND_DELAY_CLOCKS 16/* Number clocks for send delay */ #define FSI_PRE_BREAK_CLOCKS 50/* Number clocks to prep for break */ #define FSI_BREAK_CLOCKS 256/* Number of clocks to issue break */ #define FSI_POST_BREAK_CLOCKS 16000/* Number clocks to set up cfam */
@@ -48,7 +49,6 @@#define FSI_GPIO_CRC_SIZE 4#define FSI_GPIO_MSG_ID_SIZE 2#define FSI_GPIO_MSG_RESPID_SIZE 2 -#define FSI_GPIO_PRIME_SLAVE_CLOCKS 20#define LAST_ADDR_INVALID 0x1
@@ -535,9 +535,12 @@ static int poll_for_response(struct fsi_master_gpio *master,if (busy_count >0 )trace_fsi_master_gpio_poll_response_busy (master, busy_count); fail: -/* Clock the slave enough to be ready for next operation */ +/* +* tSendDelay clocks, avoids signal reflections when switching +* from receive of response back to send of data. +*/ local_irq_save (flags); -clock_zeros (master,FSI_GPIO_PRIME_SLAVE_CLOCKS ); +clock_zeros (master,FSI_SEND_DELAY_CLOCKS );local_irq_restore (flags);return rc;
Signature · 1 line
2.17.1
PATCH 5/14 fsi: master-gpio: Add support for link_config
In reply to Benjamin HerrenschmidtTo configure the send and echo delays
--- drivers/fsi/fsi-master-gpio.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/fsi/fsi-master-gpio.c +25 -2
@@ -64,6 +64,8 @@ struct fsi_master_gpio {bool external_mode;bool no_delays;uint32_t last_addr; +uint8_t t_send_delay; +uint8_t t_echo_delay; };#define CREATE_TRACE_POINTS
@@ -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) {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)
@@ -540,7 +542,7 @@ static int poll_for_response(struct fsi_master_gpio *master,* from receive of response back to send of data. */ local_irq_save (flags); -clock_zeros (master,FSI_SEND_DELAY_CLOCKS ); +clock_zeros (master, master->t_send_delay);local_irq_restore (flags);return rc;
@@ -728,6 +730,22 @@ static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)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,struct device_attribute *attr,char *buf) {
@@ -832,6 +850,10 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)*/ 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.flags =FSI_MASTER_FLAG_SWCLOCK ; master->master.read = fsi_master_gpio_read;
@@ -839,6 +861,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) master->master.term = fsi_master_gpio_term; master->master.send_break = fsi_master_gpio_break; master->master.link_enable = fsi_master_gpio_link_enable; + master->master.link_config = fsi_master_gpio_link_config;platform_set_drvdata (pdev, master);mutex_init (&master->cmd_lock);
Signature · 1 line
2.17.1
PATCH 6/14 fsi: master-gpio: Add more tracepoints
In reply to Benjamin HerrenschmidtThis adds a few more tracepoints that have proven useful when debugging issues with the FSI bus.
--- drivers/fsi/fsi-master-gpio.c | 16 ++++--- include/trace/events/fsi_master_gpio.h | 59 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-)
drivers/fsi/fsi-master-gpio.c +10 -6
@@ -130,10 +130,17 @@ static void set_sda_output(struct fsi_master_gpio *master, int value)static void clock_zeros (struct fsi_master_gpio *master,int count) { +trace_fsi_master_gpio_clock_zeros (master, count);set_sda_output (master,1 );clock_toggle (master, count); } +static void echo_delay (struct fsi_master_gpio *master) +{ +clock_zeros (master, master->t_echo_delay); +} + +static void serial_in (struct fsi_master_gpio *master,struct fsi_gpio_msg *msg,uint8_t num_bits) {
@@ -279,16 +286,19 @@ static void build_ar_command(struct fsi_master_gpio *master, addr_bits =2 ; opcode_bits =2 ; opcode =FSI_GPIO_CMD_SAME_AR ; +trace_fsi_master_gpio_cmd_same_addr (master); }else if (check_relative_address (master, id, addr, &rel_addr)) {/* 8 bits plus sign */ addr_bits =9 ; addr = rel_addr; opcode =FSI_GPIO_CMD_REL_AR ; +trace_fsi_master_gpio_cmd_rel_addr (master, rel_addr); }else { addr_bits =21 ; opcode =FSI_GPIO_CMD_ABS_AR ; +trace_fsi_master_gpio_cmd_abs_addr (master, addr); }/*
@@ -337,12 +347,6 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id)msg_push_crc (cmd); } -static void echo_delay (struct fsi_master_gpio *master) -{ -set_sda_output (master,1 ); -clock_toggle (master, master->t_echo_delay); -} -static void build_term_command (struct fsi_gpio_msg *cmd,uint8_t slave_id) { cmd->bits =0 ;
include/trace/events/fsi_master_gpio.h +59 -0
71 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 7/14 fsi: master-gpio: Remove unused definitions
In reply to Benjamin Herrenschmidt--- drivers/fsi/fsi-master-gpio.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/fsi/fsi-master-gpio.c +0 -6
@@ -25,9 +25,6 @@#define FSI_INIT_CLOCKS 5000/* Clock out any old data */ #define FSI_GPIO_DPOLL_CLOCKS 50/* < 21 will cause slave to hang */ #define FSI_GPIO_EPOLL_CLOCKS 50/* Number of clocks for E_POLL retry */ -#define FSI_GPIO_STD_DELAY 10/* Standard GPIO delay in nS */ -/* todo: adjust down as low as */ -/* possible or eliminate */ #define FSI_CRC_ERR_RETRIES 10#define FSI_GPIO_CMD_DPOLL 0x2
@@ -45,10 +42,7 @@#define FSI_GPIO_MAX_BUSY 200#define FSI_GPIO_MTOE_COUNT 1000 -#define FSI_GPIO_DRAIN_BITS 20#define FSI_GPIO_CRC_SIZE 4 -#define FSI_GPIO_MSG_ID_SIZE 2 -#define FSI_GPIO_MSG_RESPID_SIZE 2#define LAST_ADDR_INVALID 0x1
Signature · 1 line
2.17.1
PATCH 8/14 fsi: master-gpio: Remove "GPIO" prefix on some definitions
In reply to Benjamin HerrenschmidtSome definitions are generic to the FSI protocol or any give master implementation. Rename them to remove the "GPIO" prefix in preparation for moving them to a common header.
--- drivers/fsi/fsi-master-gpio.c | 70 ++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 34 deletions(-)
drivers/fsi/fsi-master-gpio.c +36 -34
@@ -23,26 +23,28 @@#define FSI_BREAK_CLOCKS 256/* Number of clocks to issue break */ #define FSI_POST_BREAK_CLOCKS 16000/* Number clocks to set up cfam */ #define FSI_INIT_CLOCKS 5000/* Clock out any old data */ -#define FSI_GPIO_DPOLL_CLOCKS 50/* < 21 will cause slave to hang */ -#define FSI_GPIO_EPOLL_CLOCKS 50/* Number of clocks for E_POLL retry */ +#define FSI_MASTER_DPOLL_CLOCKS 50/* < 21 will cause slave to hang */ +#define FSI_MASTER_EPOLL_CLOCKS 50/* Number of clocks for E_POLL retry */ +#define FSI_CRC_ERR_RETRIES 10 -#define FSI_GPIO_CMD_DPOLL 0x2 -#define FSI_GPIO_CMD_EPOLL 0x3 -#define FSI_GPIO_CMD_TERM 0x3f -#define FSI_GPIO_CMD_ABS_AR 0x4 -#define FSI_GPIO_CMD_REL_AR 0x5 -#define FSI_GPIO_CMD_SAME_AR 0x3/* but only a 2-bit opcode... */ +#define FSI_CMD_DPOLL 0x2 +#define FSI_CMD_EPOLL 0x3 +#define FSI_CMD_TERM 0x3f +#define FSI_CMD_ABS_AR 0x4 +#define FSI_CMD_REL_AR 0x5 +#define FSI_CMD_SAME_AR 0x3/* but only a 2-bit opcode... */ /* Slave responses */ -#define FSI_GPIO_RESP_ACK 0/* Success */ -#define FSI_GPIO_RESP_BUSY 1/* Slave busy */ -#define FSI_GPIO_RESP_ERRA 2/* Any (misc) Error */ -#define FSI_GPIO_RESP_ERRC 3/* Slave reports master CRC error */ +#define FSI_RESP_ACK 0/* Success */ +#define FSI_RESP_BUSY 1/* Slave busy */ +#define FSI_RESP_ERRA 2/* Any (misc) Error */ +#define FSI_RESP_ERRC 3/* Slave reports master CRC error */ + +#define FSI_MASTER_MAX_BUSY 200 -#define FSI_GPIO_MAX_BUSY 200 -#define FSI_GPIO_MTOE_COUNT 1000 -#define FSI_GPIO_CRC_SIZE 4 +#define FSI_MASTER_MTOE_COUNT 1000 +#define FSI_CRC_SIZE 4#define LAST_ADDR_INVALID 0x1
@@ -279,19 +281,19 @@ static void build_ar_command(struct fsi_master_gpio *master,/* we still address the byte offset within the word */ addr_bits =2 ; opcode_bits =2 ; - opcode =FSI_GPIO_CMD_SAME_AR ; + opcode =FSI_CMD_SAME_AR ;trace_fsi_master_gpio_cmd_same_addr (master); }else if (check_relative_address (master, id, addr, &rel_addr)) {/* 8 bits plus sign */ addr_bits =9 ; addr = rel_addr; - opcode =FSI_GPIO_CMD_REL_AR ; + opcode =FSI_CMD_REL_AR ;trace_fsi_master_gpio_cmd_rel_addr (master, rel_addr); }else { addr_bits =21 ; - opcode =FSI_GPIO_CMD_ABS_AR ; + opcode =FSI_CMD_ABS_AR ;trace_fsi_master_gpio_cmd_abs_addr (master, addr); }
@@ -327,7 +329,7 @@ static void build_dpoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id) cmd->msg =0 ;msg_push_bits (cmd, slave_id,2 ); -msg_push_bits (cmd,FSI_GPIO_CMD_DPOLL ,3 ); +msg_push_bits (cmd,FSI_CMD_DPOLL ,3 );msg_push_crc (cmd); }
@@ -337,7 +339,7 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id) cmd->msg =0 ;msg_push_bits (cmd, slave_id,2 ); -msg_push_bits (cmd,FSI_GPIO_CMD_EPOLL ,3 ); +msg_push_bits (cmd,FSI_CMD_EPOLL ,3 );msg_push_crc (cmd); }
@@ -347,7 +349,7 @@ static void build_term_command(struct fsi_gpio_msg *cmd, uint8_t slave_id) cmd->msg =0 ;msg_push_bits (cmd, slave_id,2 ); -msg_push_bits (cmd,FSI_GPIO_CMD_TERM ,6 ); +msg_push_bits (cmd,FSI_CMD_TERM ,6 );msg_push_crc (cmd); }
@@ -369,14 +371,14 @@ static int read_one_response(struct fsi_master_gpio *master,local_irq_save (flags);/* wait for the start bit */ -for (i =0 ; i <FSI_GPIO_MTOE_COUNT ; i++) { +for (i =0 ; i <FSI_MASTER_MTOE_COUNT ; i++) { msg.bits =0 ; msg.msg =0 ;serial_in (master, &msg,1 );if (msg.msg)break ; } -if (i ==FSI_GPIO_MTOE_COUNT ) { +if (i ==FSI_MASTER_MTOE_COUNT ) {dev_warn (master->dev,"Master time out waiting for response\n" );local_irq_restore (flags);
@@ -392,11 +394,11 @@ static int read_one_response(struct fsi_master_gpio *master, tag = msg.msg &0x3 ;/* If we have an ACK and we're expecting data, clock the data in too */ -if (tag ==FSI_GPIO_RESP_ACK && data_size) +if (tag ==FSI_RESP_ACK && data_size)serial_in (master, &msg, data_size *8 );/* read CRC */ -serial_in (master, &msg,FSI_GPIO_CRC_SIZE ); +serial_in (master, &msg,FSI_CRC_SIZE );local_irq_restore (flags);
@@ -439,7 +441,7 @@ static int issue_term(struct fsi_master_gpio *master, uint8_t slave)dev_err (master->dev,"TERM failed; lost communication with slave\n" );return -EIO ; - }else if (tag !=FSI_GPIO_RESP_ACK ) { + }else if (tag !=FSI_RESP_ACK ) {dev_err (master->dev,"TERM failed; response %d\n" , tag);return -EIO ; }
@@ -475,7 +477,7 @@ static int poll_for_response(struct fsi_master_gpio *master,trace_fsi_master_gpio_crc_rsp_error (master);build_epoll_command (&cmd, slave);local_irq_save (flags); -clock_zeros (master,FSI_GPIO_EPOLL_CLOCKS ); +clock_zeros (master,FSI_MASTER_EPOLL_CLOCKS );serial_out (master, &cmd);echo_delay (master);local_irq_restore (flags);
@@ -484,7 +486,7 @@ static int poll_for_response(struct fsi_master_gpio *master, goto fail;switch (tag) { -case FSI_GPIO_RESP_ACK : +case FSI_RESP_ACK :if (size && data) {uint64_t val = response.msg;/* clear crc & mask */
@@ -497,16 +499,16 @@ static int poll_for_response(struct fsi_master_gpio *master, } }break ; -case FSI_GPIO_RESP_BUSY : +case FSI_RESP_BUSY :/* * Its necessary to clock slave before issuing * d-poll, not indicated in the hardware protocol * spec. < 20 clocks causes slave to hang, 21 ok. */ -if (busy_count++ <FSI_GPIO_MAX_BUSY ) { +if (busy_count++ <FSI_MASTER_MAX_BUSY ) {build_dpoll_command (&cmd, slave);local_irq_save (flags); -clock_zeros (master,FSI_GPIO_DPOLL_CLOCKS ); +clock_zeros (master,FSI_MASTER_DPOLL_CLOCKS );serial_out (master, &cmd);echo_delay (master);local_irq_restore (flags);
@@ -515,17 +517,17 @@ static int poll_for_response(struct fsi_master_gpio *master,dev_warn (master->dev,"ERR slave is stuck in busy state, issuing TERM\n" );local_irq_save (flags); -clock_zeros (master,FSI_GPIO_DPOLL_CLOCKS ); +clock_zeros (master,FSI_MASTER_DPOLL_CLOCKS );local_irq_restore (flags);issue_term (master, slave); rc = -EIO ;break ; -case FSI_GPIO_RESP_ERRA : +case FSI_RESP_ERRA :dev_warn (master->dev,"ERRA received: 0x%x\n" , (int )response.msg); rc = -EIO ;break ; -case FSI_GPIO_RESP_ERRC : +case FSI_RESP_ERRC :dev_warn (master->dev,"ERRC received: 0x%x\n" , (int )response.msg);trace_fsi_master_gpio_crc_cmd_error (master); rc = -EAGAIN ;
Signature · 1 line
2.17.1
PATCH 9/14 fsi: master-gpio: Add missing release function
In reply to Benjamin HerrenschmidtThe embedded struct device needs a release function to be able to successfully remove the driver.
We remove the devm_gpiod_put() as they are unnecessary (the resources will be released automatically) and because fsi_master_unregister() will cause the master structure to be freed.
--- drivers/fsi/fsi-master-gpio.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/fsi/fsi-master-gpio.c +17 -11
@@ -792,6 +792,15 @@ static ssize_t external_mode_store(struct device *dev, static DEVICE_ATTR(external_mode, 0664, external_mode_show, external_mode_store); +static void fsi_master_gpio_release (struct device *dev) +{ +struct fsi_master_gpio *master =to_fsi_master_gpio (dev_to_fsi_master (dev)); + +of_node_put (dev_of_node (master->dev)); + +kfree (dev); +} +static int fsi_master_gpio_probe (struct platform_device *pdev) {struct fsi_master_gpio *master;
@@ -805,6 +814,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) master->dev = &pdev->dev; master->master.dev.parent = master->dev; master->master.dev.of_node =of_node_get (dev_of_node (master->dev)); + master->master.dev.release = fsi_master_gpio_release; master->last_addr =LAST_ADDR_INVALID ; gpio =devm_gpiod_get (&pdev->dev,"clock" ,0 );
@@ -871,25 +881,21 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)if (rc)return rc; -return fsi_master_register (&master->master); + rc =fsi_master_register (&master->master); +if (rc) +device_remove_file (&pdev->dev, &dev_attr_external_mode); +return rc; } +static int fsi_master_gpio_remove (struct platform_device *pdev) {struct fsi_master_gpio *master =platform_get_drvdata (pdev); -devm_gpiod_put (&pdev->dev, master->gpio_clk); -devm_gpiod_put (&pdev->dev, master->gpio_data); -if (master->gpio_trans) -devm_gpiod_put (&pdev->dev, master->gpio_trans); -if (master->gpio_enable) -devm_gpiod_put (&pdev->dev, master->gpio_enable); -if (master->gpio_mux) -devm_gpiod_put (&pdev->dev, master->gpio_mux); -fsi_master_unregister (&master->master); +device_remove_file (&pdev->dev, &dev_attr_external_mode); -of_node_put (master->master.dev.of_node); +fsi_master_unregister (&master->master);return 0 ; }
Signature · 1 line
2.17.1
PATCH 10/14 fsi: Move various master definitions to a common header
In reply to Benjamin HerrenschmidtThis moves the definitions for various protocol details (message & response codes, delays etc...) out of fsi-master-gpio.c to fsi-master.h in order to share them with other master implementations.
--- drivers/fsi/fsi-master-gpio.c | 29 ----------------------------- drivers/fsi/fsi-master.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 29 deletions(-)
drivers/fsi/fsi-master-gpio.c +0 -29
@@ -17,35 +17,6 @@#include "fsi-master.h" #define FSI_GPIO_STD_DLY 1/* Standard pin delay in nS */ -#define FSI_ECHO_DELAY_CLOCKS 16/* Number clocks for echo delay */ -#define FSI_SEND_DELAY_CLOCKS 16/* Number clocks for send delay */ -#define FSI_PRE_BREAK_CLOCKS 50/* Number clocks to prep for break */ -#define FSI_BREAK_CLOCKS 256/* Number of clocks to issue break */ -#define FSI_POST_BREAK_CLOCKS 16000/* Number clocks to set up cfam */ -#define FSI_INIT_CLOCKS 5000/* Clock out any old data */ -#define FSI_MASTER_DPOLL_CLOCKS 50/* < 21 will cause slave to hang */ -#define FSI_MASTER_EPOLL_CLOCKS 50/* Number of clocks for E_POLL retry */ - -#define FSI_CRC_ERR_RETRIES 10 - -#define FSI_CMD_DPOLL 0x2 -#define FSI_CMD_EPOLL 0x3 -#define FSI_CMD_TERM 0x3f -#define FSI_CMD_ABS_AR 0x4 -#define FSI_CMD_REL_AR 0x5 -#define FSI_CMD_SAME_AR 0x3/* but only a 2-bit opcode... */ - -/* Slave responses */ -#define FSI_RESP_ACK 0/* Success */ -#define FSI_RESP_BUSY 1/* Slave busy */ -#define FSI_RESP_ERRA 2/* Any (misc) Error */ -#define FSI_RESP_ERRC 3/* Slave reports master CRC error */ - -#define FSI_MASTER_MAX_BUSY 200 - -#define FSI_MASTER_MTOE_COUNT 1000 -#define FSI_CRC_SIZE 4 -#define LAST_ADDR_INVALID 0x1struct fsi_master_gpio {
drivers/fsi/fsi-master.h +33 -0
@@ -19,6 +19,39 @@#include <linux/device.h> +/* Various protocol delays */ +#define FSI_ECHO_DELAY_CLOCKS 16/* Number clocks for echo delay */ +#define FSI_SEND_DELAY_CLOCKS 16/* Number clocks for send delay */ +#define FSI_PRE_BREAK_CLOCKS 50/* Number clocks to prep for break */ +#define FSI_BREAK_CLOCKS 256/* Number of clocks to issue break */ +#define FSI_POST_BREAK_CLOCKS 16000/* Number clocks to set up cfam */ +#define FSI_INIT_CLOCKS 5000/* Clock out any old data */ +#define FSI_MASTER_DPOLL_CLOCKS 50/* < 21 will cause slave to hang */ +#define FSI_MASTER_EPOLL_CLOCKS 50/* Number of clocks for E_POLL retry */ + +/* Various retry maximums */ +#define FSI_CRC_ERR_RETRIES 10 +#define FSI_MASTER_MAX_BUSY 200 +#define FSI_MASTER_MTOE_COUNT 1000 + +/* Command encodings */ +#define FSI_CMD_DPOLL 0x2 +#define FSI_CMD_EPOLL 0x3 +#define FSI_CMD_TERM 0x3f +#define FSI_CMD_ABS_AR 0x4 +#define FSI_CMD_REL_AR 0x5 +#define FSI_CMD_SAME_AR 0x3/* but only a 2-bit opcode... */ + +/* Slave responses */ +#define FSI_RESP_ACK 0/* Success */ +#define FSI_RESP_BUSY 1/* Slave busy */ +#define FSI_RESP_ERRA 2/* Any (misc) Error */ +#define FSI_RESP_ERRC 3/* Slave reports master CRC error */ + +/* Misc */ +#define FSI_CRC_SIZE 4 + +/* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1struct fsi_master {
Signature · 1 line
2.17.1
PATCH 11/14 dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
In reply to Benjamin HerrenschmidtThis isn't per-se a real device, it's a pseudo-device that represents the use of the Aspeed built-in ColdFire to implement the FSI protocol by bitbanging the GPIOs instead of doing it from the ARM core.
Thus it's a drop-in replacement for the existing fsi-master-gpio pseudo-device for use on systems for which a corresponding firmware file exists. It has most of the same properties, plus some more needed to operate the coprocessor.
--- .../bindings/fsi/fsi-master-ast-cf.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +36 -0
@@ -0,0 +1,36 @@ +Device-tree bindings for ColdFire offloaded gpio-based FSI master driver +------------------------------------------------------------------------ + +Required properties: + - compatible = + "fsi-master-ast-2400-cf" for an AST2400 based system + or + "fsi-master-ast-2500-cf" for an AST2500 based system + + - clock-gpios = <gpio-descriptor>; : GPIO for FSI clock + - data-gpios = <gpio-descriptor>; : GPIO for FSI data signal + - enable-gpios = <gpio-descriptor>; : GPIO for enable signal + - trans-gpios = <gpio-descriptor>; : GPIO for voltage translator enable + - mux-gpios = <gpio-descriptor>; : GPIO for pin multiplexing with other + functions (eg, external FSI masters) + - memory-region = <phandle>; : Reference to the reserved memory for + the ColdFire. Must be 2M aligned on + AST2400 and 1M aligned on AST2500 + - sram = <phandle>; : Reference to the SRAM node. + - cvic = <phandle>; : Reference to the CVIC node. + - fw-name = <string>; : The name used to construct the firmware + file name (cf-fsi-<name>.bin) + - fw-platform-sig = <value>; : A signature value that must match the one + contained in the firmware image. Known + values are listed in the firmware interface + file cf-fsi-fw.h +Examples: + + fsi-master { + compatible = "fsi-master-gpio", "fsi-master"; + clock-gpios = <&gpio 0>; + data-gpios = <&gpio 1>; + enable-gpios = <&gpio 2>; + trans-gpios = <&gpio 3>; + mux-gpios = <&gpio 4>; + }
Signature · 1 line
2.17.1
PATCH 12/14 fsi: master-ast-cf: Add new FSI master using Aspeed ColdFire
In reply to Benjamin HerrenschmidtThe Aspeed AST2x00 can contain a ColdFire v1 coprocessor which is currently unused on OpenPower systems.
This adds an alternative to the fsi-master-gpio driver that uses that coprocessor instead of bit banging from the ARM core itself. The end result is about 4 times faster.
The firmware for the coprocessor and its source code can be found at https://github.com/ozbenh/cf-fsi and is system specific.
Currently tested on Romulus and Palmetto systems.
--- drivers/fsi/Kconfig | 9 + drivers/fsi/Makefile | 1 + drivers/fsi/cf-fsi-fw.h | 131 ++ drivers/fsi/fsi-master-ast-cf.c | 1376 ++++++++++++++++++++++ include/trace/events/fsi_master_ast_cf.h | 150 +++ 5 files changed, 1667 insertions(+) create mode 100644 drivers/fsi/cf-fsi-fw.h create mode 100644 drivers/fsi/fsi-master-ast-cf.c create mode 100644 include/trace/events/fsi_master_ast_cf.h
drivers/fsi/Kconfig +9 -0
@@ -27,6 +27,15 @@ config FSI_MASTER_HUB allow chaining of FSI links to an arbitrary depth. This allows for a high target device fanout. +config FSI_MASTER_AST_CF + tristate "FSI master based on Aspeed ColdFire coprocessor" + depends on GPIOLIB + depends on GPIO_ASPEED + ---help--- + This option enables a FSI master using the AST2400 and AST2500 GPIO + lines driven by the internal ColdFire coprocessor. This requires + the corresponding machine specific ColdFire firmware to be available. + config FSI_SCOM tristate "SCOM FSI client device driver" ---help---
drivers/fsi/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_FSI) += fsi-core.o obj-$(CONFIG_FSI_MASTER_HUB) += fsi-master-hub.o obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o +obj-$(CONFIG_FSI_MASTER_AST_CF) += fsi-master-ast-cf.o obj-$(CONFIG_FSI_SCOM) += fsi-scom.o obj-$(CONFIG_FSI_SBEFIFO) += fsi-sbefifo.o obj-$(CONFIG_FSI_OCC) += fsi-occ.o
drivers/fsi/cf-fsi-fw.h new file +131 -0
131 lines not on this page · raw message
drivers/fsi/fsi-master-ast-cf.c new file +1376 -0
1,376 lines not on this page · raw message
include/trace/events/fsi_master_ast_cf.h new file +150 -0
150 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 13/14 arm: dts: OpenPower Romulus system can use coprocessor for FSI
In reply to Benjamin Herrenschmidt--- arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts +13 -2
@@ -37,6 +37,11 @@ compatible = "shared-dma-pool"; reusable; }; + + coldfire_memory: codefire_memory at 9ef00000 { + reg = <0x9ef00000 0x00100000>; + no-map; + }; }; leds {
@@ -56,10 +61,16 @@ }; fsi: gpio-fsi { - compatible = "fsi-master-gpio", "fsi-master"; + compatible = "ibm,fsi-master-ast2500-cf", "fsi-master"; #address-cells = <2>; #size-cells = <0>; - no-gpio-delays; + + memory-region = <&coldfire_memory>; + sram = <&sram>; + cvic = <&cvic>; + + fw-name = "romulus"; + fw-platform-sig = <0x526d>; clock-gpios = <&gpio ASPEED_GPIO(AA, 0) GPIO_ACTIVE_HIGH>; data-gpios = <&gpio ASPEED_GPIO(AA, 2) GPIO_ACTIVE_HIGH>;
Signature · 1 line
2.17.1
PATCH 14/14 arm: dts: OpenPower Palmetto system can use coprocessor for FSI
In reply to Benjamin HerrenschmidtThis switches away from userspace bitbanging to kernel FSI using the coprocessor.
--- arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-)
arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts +24 -7
@@ -31,6 +31,11 @@ no-map; reg = <0x98000000 0x01000000>; /* 16MB */ }; + + coldfire_memory: codefire_memory at 5ee00000 { + reg = <0x5ee00000 0x00200000>; + no-map; + }; }; leds {
@@ -49,6 +54,25 @@ }; }; + fsi: gpio-fsi { + compatible = "ibm,fsi-master-ast2400-cf", "fsi-master"; + #address-cells = <2>; + #size-cells = <0>; + + memory-region = <&coldfire_memory>; + sram = <&sram>; + cvic = <&cvic>; + + fw-name = "palmetto"; + fw-platform-sig = <0x5061>; + + clock-gpios = <&gpio ASPEED_GPIO(A, 4) GPIO_ACTIVE_HIGH>; + data-gpios = <&gpio ASPEED_GPIO(A, 5) GPIO_ACTIVE_HIGH>; + mux-gpios = <&gpio ASPEED_GPIO(A, 6) GPIO_ACTIVE_HIGH>; + enable-gpios = <&gpio ASPEED_GPIO(D, 0) GPIO_ACTIVE_HIGH>; + trans-gpios = <&gpio ASPEED_GPIO(H, 6) GPIO_ACTIVE_HIGH>; + }; + gpio-keys { compatible = "gpio-keys";
@@ -323,13 +347,6 @@ line-name = "SYS_PWROK_BMC"; }; - pin_gpio_h6 { - gpio-hog; - gpios = <ASPEED_GPIO(H, 6) GPIO_ACTIVE_HIGH>; - output-high; - line-name = "SCM1_FSI0_DATA_EN"; - }; - pin_gpio_h7 { gpio-hog; gpios = <ASPEED_GPIO(H, 7) GPIO_ACTIVE_HIGH>;
Signature · 1 line
2.17.1
Re: [PATCH 03/14] fsi: Add mechanism to set the tSendDelay and tEchoDelay values
In reply to Benjamin HerrenschmidtQuoted 5 lines · Benjamin Herrenschmidt
Those values control the amount of "dummy" clocks between commands and between a command and its response.
This adds a way to configure them from sysfs (to be later extended to defaults in the device-tree). The default remains 16 (the HW default).
We should add these to Documentation/ABI/testing/sysfs-bus-fsi.
Quoted 4 lines
This is only supported if the backend supports the new
link_config()callback to configure the generation of those delays.Signed-off-by Benjamin Herrenschmidt <[email protected]>
Quoted 20 lines
---
--- drivers/fsi/fsi-core.c | 109 ++++++++++++++++++++++++++++++++------- drivers/fsi/fsi-master.h | 2 + 2 files changed, 93 insertions(+), 18 deletions(-)drivers/fsi/fsi-core.c +2
-0@@ -81,6 +81,8 @@ struct fsi_slave {int id;int link;uint32_t size;/* size of slave address space */ +u8 t_send_delay; +u8 t_echo_delay; };#define to_fsi_master (d) container_of(d, struct fsi_master, dev)
drivers/fsi/fsi-core.c static inline uint32_t fsi_smode_sid(int x) · line 244
Quoted 5 lines
drivers/fsi/fsi-core.c +1
-1@@ -239,15 +241,15 @@ static inline uint32_t fsi_smode_sid(int x)return (x &FSI_SMODE_SID_MASK ) <<FSI_SMODE_SID_SHIFT ; } -static uint32_t fsi_slave_smode (int id) +static uint32_t fsi_slave_smode (int id,u8 t_senddly,u8 t_echodly)
Can I buy you a vowel? :)
Quoted 8 lines
drivers/fsi/fsi-core.c +1
-1{return FSI_SMODE_WSC |FSI_SMODE_ECRC |fsi_smode_sid (id) - |fsi_smode_echodly (0xf ) |fsi_smode_senddly (0xf ) + |fsi_smode_echodly (t_echodly -1 ) |fsi_smode_senddly (t_senddly -1 ) |fsi_smode_lbcrr (0x8 ); }
Re: [PATCH 05/14] fsi: master-gpio: Add support for link_config
In reply to Benjamin HerrenschmidtQuoted 3 lines · Benjamin Herrenschmidt
To configure the send and echo delays
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Re: [PATCH 06/14] fsi: master-gpio: Add more tracepoints
In reply to Benjamin HerrenschmidtQuoted 4 lines · Benjamin Herrenschmidt
This adds a few more tracepoints that have proven useful when debugging issues with the FSI bus.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Quoted 12 lines
--- drivers/fsi/fsi-master-gpio.c | 16 ++++--- include/trace/events/fsi_master_gpio.h | 59 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-)drivers/fsi/fsi-master-gpio.c +0
-0@@ -130,10 +130,17 @@ static void set_sda_output(struct fsi_master_gpio *master, int value)static void clock_zeros (struct fsi_master_gpio *master,int count)
drivers/fsi/fsi-master-gpio.c static void set_sda_output(struct fsi_master_gpio *master, int value) · line 141
Quoted 10 lines
drivers/fsi/fsi-master-gpio.c +5
-0{ +trace_fsi_master_gpio_clock_zeros (master, count);set_sda_output (master,1 );clock_toggle (master, count); } +static void echo_delay (struct fsi_master_gpio *master) +{ +clock_zeros (master, master->t_echo_delay); +}
This doesn't look like it belongs in this patch.
You've just moved it up. Not worth a re-spin.
Quoted 38 lines
drivers/fsi/fsi-master-gpio.c +5
-6+ +static void serial_in (struct fsi_master_gpio *master,struct fsi_gpio_msg *msg,uint8_t num_bits) {@@ -279,16 +286,19 @@ static void build_ar_command(struct fsi_master_gpio *master, addr_bits =2 ; opcode_bits =2 ; opcode =FSI_GPIO_CMD_SAME_AR ; +trace_fsi_master_gpio_cmd_same_addr (master); }else if (check_relative_address (master, id, addr, &rel_addr)) {/* 8 bits plus sign */ addr_bits =9 ; addr = rel_addr; opcode =FSI_GPIO_CMD_REL_AR ; +trace_fsi_master_gpio_cmd_rel_addr (master, rel_addr); }else { addr_bits =21 ; opcode =FSI_GPIO_CMD_ABS_AR ; +trace_fsi_master_gpio_cmd_abs_addr (master, addr); }/* @@ -337,12 +347,6 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id)msg_push_crc (cmd); } -static void echo_delay (struct fsi_master_gpio *master) -{ -set_sda_output (master,1 ); -clock_toggle (master, master->t_echo_delay); -} -static void build_term_command (struct fsi_gpio_msg *cmd,uint8_t slave_id) { cmd->bits =0 ;
Re: [PATCH 07/14] fsi: master-gpio: Remove unused definitions
In reply to Benjamin HerrenschmidtQuoted 1 line · Benjamin Herrenschmidt
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Re: [PATCH 08/14] fsi: master-gpio: Remove "GPIO" prefix on some definitions
In reply to Benjamin HerrenschmidtQuoted 6 lines · Benjamin Herrenschmidt
Some definitions are generic to the FSI protocol or any give master implementation. Rename them to remove the "GPIO" prefix in preparation for moving them to a common header.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Re: [PATCH 09/14] fsi: master-gpio: Add missing release function
In reply to Benjamin HerrenschmidtQuoted 9 lines · Benjamin Herrenschmidt
The embedded struct device needs a release function to be able to successfully remove the driver.
We remove the
devm_gpiod_put()as they are unnecessary (the resources will be released automatically) and becausefsi_master_unregister()will cause the master structure to be freed.Signed-off-by Benjamin Herrenschmidt <[email protected]>
Re: [PATCH 10/14] fsi: Move various master definitions to a common header
In reply to Benjamin HerrenschmidtQuoted 6 lines · Benjamin Herrenschmidt
This moves the definitions for various protocol details (message & response codes, delays etc...) out of
fsi-master-gpio.ctofsi-master.hin order to share them with other master implementations.Signed-off-by Benjamin Herrenschmidt <[email protected]>
Re: [PATCH 11/14] dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
In reply to Benjamin HerrenschmidtQuoted 5 lines · Benjamin Herrenschmidt
This isn't per-se a real device, it's a pseudo-device that represents the use of the Aspeed built-in ColdFire to implement the FSI protocol by bitbanging the GPIOs instead of doing it from the ARM core.
Quoted 7 lines
Thus it's a drop-in replacement for the existing fsi-master-gpio pseudo-device for use on systems for which a corresponding firmware file exists. It has most of the same properties, plus some more needed to operate the coprocessor.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Joel Stanley
maintainerRe: [PATCH 13/14] arm: dts: OpenPower Romulus system can use coprocessor for FSI
In reply to Benjamin HerrenschmidtQuoted 1 line · Benjamin Herrenschmidt
Signed-off-by Benjamin Herrenschmidt <[email protected]>
I will take this through the ASPEED SoC tree once we've got acks on the bindings.
Cheers,
Joel
Quoted 42 lines
--- arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts +13
-3@@ -37,6 +37,11 @@ compatible = "shared-dma-pool"; reusable; }; + + coldfire_memory: codefire_memory at 9ef00000 { + reg = <0x9ef00000 0x00100000>; + no-map; + }; }; leds {@@ -56,10 +61,16 @@ }; fsi: gpio-fsi { - compatible = "fsi-master-gpio", "fsi-master"; + compatible = "ibm,fsi-master-ast2500-cf", "fsi-master"; #address-cells = <2>; #size-cells = <0>; - no-gpio-delays; + + memory-region = <&coldfire_memory>; + sram = <&sram>; + cvic = <&cvic>; + + fw-name = "romulus"; + fw-platform-sig = <0x526d>; clock-gpios = <&gpio ASPEED_GPIO(AA, 0) GPIO_ACTIVE_HIGH>; data-gpios = <&gpio ASPEED_GPIO(AA, 2) GPIO_ACTIVE_HIGH>; --2.17.1
Joel Stanley
maintainerRe: [PATCH 14/14] arm: dts: OpenPower Palmetto system can use coprocessor for FSI
In reply to Benjamin HerrenschmidtQuoted 4 lines · Benjamin Herrenschmidt
This switches away from userspace bitbanging to kernel FSI using the coprocessor.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
As with the other patch, I will take this through the ASPEED SoC tree once we've got acks on the bindings.
Cheers,
Joel
Joel Stanley
maintainerRe: [PATCH 12/14] fsi: master-ast-cf: Add new FSI master using Aspeed ColdFire
In reply to Benjamin HerrenschmidtHi Ben,
Quoted 7 lines · Benjamin Herrenschmidt
The Aspeed AST2x00 can contain a ColdFire v1 coprocessor which is currently unused on OpenPower systems.
This adds an alternative to the fsi-master-gpio driver that uses that coprocessor instead of bit banging from the ARM core itself. The end result is about 4 times faster.
Quoted 6 lines
The firmware for the coprocessor and its source code can be found at https://github.com/ozbenh/cf-fsi and is system specific.
Currently tested on Romulus and Palmetto systems.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Nice work. I gave this a spin on Romulus and it looked good.
If you run it through sparse there are a bunch of things to fix. I've also got some comments below.
drivers/fsi/cf-fsi-fw.h
Quoted 3 lines
drivers/fsi/cf-fsi-fw.h new file +0
-0@@ -0,0 +1,131 @@
Copyright?
Quoted 17 lines
drivers/fsi/cf-fsi-fw.h new file +10
-0+#ifndef __CF_FSI_FW_H +#define __CF_FSI_FW_H + +/* +* uCode file layout +* +* 0000...03ff : m68k exception vectors +* 0400...04ff : Header info & boot config block +* 0500....... : Code & stack +*/ drivers/fsi/fsi-master-ast-cf.c new file +0
-0
drivers/fsi/fsi-master-ast-cf.c line 1
Quoted 1 line
drivers/fsi/fsi-master-ast-cf.c new file +1
-0@@ -0,0 +1,1376 @@ +// SPDX-License-Identifier: GPL-2.0
Normally 2+ for new IBM code? You also need something like this on the next line:
// Copyright 2018 IBM Corp
Quoted 56 lines
drivers/fsi/fsi-master-ast-cf.c new file +56
-0+static int read_copro_response (struct fsi_master_acf *master,uint8_t size, +__be32 *response,u8 *tag) +{ +u8 rtag =readb (master->sram +STAT_RTAG ); +u8 rcrc =readb (master->sram +STAT_RCRC ); +__be32 rdata =0 ; +u32 crc; +u8 ack; + + *tag = ack = rtag &3 ; + +/* we have a whole message now; check CRC */ + crc =crc4 (0 ,1 ,1 ); + crc =crc4 (crc, rtag,4 ); +if (ack ==FSI_RESP_ACK && size) { + rdata =readl (master->sram +RSP_DATA ); + crc =crc4 (crc,be32_to_cpu (rdata),32 ); +if (response) + *response = rdata; + } + crc =crc4 (crc, rcrc,4 ); + +trace_fsi_master_acf_copro_response (master, rtag, rcrc, rdata, crc ==0 ); + +if (crc) { +/* +* Check if it's all 1's or all 0's, that probably means +* the host is off +*/ +if ((rtag ==0xf && rcrc ==0xf ) || (rtag ==0 && rcrc ==0 )) +return -ENODEV ; +dev_dbg (master->dev,"Bad response CRC !\n" ); +return -EAGAIN ; + } +return 0 ; +} + +static int send_term (struct fsi_master_acf *master,uint8_t slave) +{ +struct fsi_msg cmd; +uint8_t tag; +int rc; + +build_term_command (&cmd, slave); + + rc =send_request (master, &cmd, true); +if (rc) { +dev_warn (master->dev,"Error %d sending term\n" , rc); +return rc; + } + + rc =read_copro_response (master,0 ,NULL , &tag); +if (rc <0 ) { +dev_err (master->dev, +"TERM failed; lost communication with slave\n" ); +return -EIO ;
drivers/fsi/fsi-master-ast-cf.c line 433
Quoted 10 lines
drivers/fsi/fsi-master-ast-cf.c new file +10
-0+ }else if (tag !=FSI_RESP_ACK ) { +dev_err (master->dev,"TERM failed; response %d\n" , tag); +return -EIO ; + } +return 0 ; +} + +static void dump_trace (struct fsi_master_acf *master) +{ +char trbuf[52 ];
I was checking that this was big enough.
52 = 16 * 3 + '\n' + \0' = 50?
Looks to be okay.
Quoted 65 lines
drivers/fsi/fsi-master-ast-cf.c new file +65
-0+char *p; +int i; + +dev_dbg (master->dev, +"CMDSTAT:%08x RTAG=%02x RCRC=%02x RDATA=%02x #INT=%08x\n" , +be32_to_cpu (readl (master->sram +CMD_STAT_REG )), +readb (master->sram +STAT_RTAG ), +readb (master->sram +STAT_RCRC ), +be32_to_cpu (readl (master->sram +RSP_DATA )), +be32_to_cpu (readl (master->sram +INT_CNT ))); + +for (i =0 ; i <512 ; i++) { +uint8_t v; +if ((i %16 ) ==0 ) + p = trbuf; + v =readb (master->sram +TRACEBUF + i); + p +=sprintf (p,"%02x " , v); +if (((i %16 ) ==15 ) || v ==TR_END ) +dev_dbg (master->dev,"%s\n" , trbuf); +if (v ==TR_END ) +break ; + } +} + +static int handle_response (struct fsi_master_acf *master, +uint8_t slave,uint8_t size,void *data) +{ +int busy_count =0 , rc; +int crc_err_retries =0 ; +struct fsi_msg cmd; +__be32 response; +uint8_t tag; +retry: + rc =read_copro_response (master, size, &response, &tag); + +/* Handle retries on CRC errors */ +if (rc == -EAGAIN ) { +/* Too many retries ? */ +if (crc_err_retries++ >FSI_CRC_ERR_RETRIES ) { +/* +* Pass it up as a -EIO otherwise upper level will retry +* the whole command which isn't what we want here. +*/ + rc = -EIO ; + goto bail; + } +trace_fsi_master_acf_crc_rsp_error (master, crc_err_retries); +if (master->trace_enabled) +dump_trace (master); + rc =clock_zeros (master,FSI_MASTER_EPOLL_CLOCKS ); +if (rc) { +dev_warn (master->dev, +"Error %d clocking zeros for E_POLL\n" , rc); +return rc; + } +build_epoll_command (&cmd, slave); + rc =send_request (master, &cmd, size ==0 ); +if (rc) { +dev_warn (master->dev,"Error %d sending E_POLL\n" , rc); +return -EIO ; + } + goto retry; + } +if (rc) +return rc;
drivers/fsi/fsi-master-ast-cf.c line 508
Quoted 10 lines
drivers/fsi/fsi-master-ast-cf.c new file +10
-0+ +switch (tag) { +case FSI_RESP_ACK : +if (size && data) { +if (size ==4 ) + *(__be32 *)data = response; +else if (size ==2 ) + *(__be16 *)data = response; +else + *(u8 *)data = response;
Response is a u32, the idea here is to discard the top two or three byes?
Quoted 7 lines
drivers/fsi/fsi-master-ast-cf.c new file +6
-0+ +static int fsi_master_acf_setup (struct fsi_master_acf *master) +{ +int timeout, rc; +u32 val; +
drivers/fsi/fsi-master-ast-cf.c line 920
Quoted 10 lines
drivers/fsi/fsi-master-ast-cf.c new file +10
-0+ +/* Wait for status register to indicate command completion +* which signals the initialization is complete +*/ +for (timeout =0 ; timeout <10 ; timeout++) { + val =readb (master->sram +CF_STARTED ); +if (val) +break ; +msleep (1 ); + };
drivers/fsi/fsi-master-ast-cf.c:920:2-3: Unneeded semicolon
Quoted 48 lines
drivers/fsi/fsi-master-ast-cf.c new file +47
-0+if (!val) { +dev_err (master->dev,"Coprocessor startup timeout !\n" ); + rc = -ENODEV ; + goto err; + } + +/* Configure echo & send delay */ +writeb (master->t_send_delay, master->sram +SEND_DLY_REG ); +writeb (master->t_echo_delay, master->sram +ECHO_DLY_REG ); + +/* Enable SW interrupt to copro if any */ +if (master->cvic) { + rc =copro_enable_sw_irq (master); +if (rc) + goto err; + } +return 0 ; + err: +/* An error occurred, don't leave the coprocessor running */ +reset_cf (master); + +/* Release the GPIOs */ +release_copro_gpios (master); + +return rc; +} +static int fsi_master_acf_gpio_request (void *data) +{ +struct fsi_master_acf *master = data; +int timeout; +u8 val; + +/* Note: This doesn't require holding out mutex */ + +/* Write reqest */ +writeb (ARB_ARM_REQ , master->sram +ARB_REG ); + +/* Read back to avoid ordering issue */ + (void )readb (master->sram +ARB_REG ); + +/* +* There is a race (which does happen at boot time) when we get an +* arbitration request as we are either about to or just starting +* the coprocessor. +* +* To handle it, we first check if we are running. If not yet we +* check whether the copro is started in the SCU.
drivers/fsi/fsi-master-ast-cf.c
Quoted 10 lines
drivers/fsi/fsi-master-ast-cf.c new file +10
-0+* +* If it's not started, we can basically just assume we have arbitration +* and return. Otherwise, we wait normally expecting for the arbitration +* to eventually complete. +*/ +if (readl (master->sram +CF_STARTED ) ==0 ) { +unsigned int reg =0 ; + +regmap_read (master->scu,SCU_COPRO_CTRL , ®); +if (!reg &SCU_COPRO_CLK_EN )
Is this correct? Looks like it might be missing some ( )
Quoted 21 lines
drivers/fsi/fsi-master-ast-cf.c new file +21
-0+return 0 ; + } + +/* Ring doorbell if any */ +if (master->cvic) +writel (0x2 , master->cvic +CVIC_TRIG_REG ); + +for (timeout =0 ; timeout <10000 ; timeout++) { + val =readb (master->sram +ARB_REG ); +if (val !=ARB_ARM_REQ ) +break ; +udelay (1 ); + } + +/* If it failed, override anyway */ +if (val !=ARB_ARM_ACK ) +dev_warn (master->dev,"GPIO request arbitration timeout\n" ); + +return 0 ; +} +
Rob Herring
maintainerRe: [PATCH 11/14] dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
In reply to Benjamin HerrenschmidtQuoted 23 lines · Benjamin Herrenschmidt
This isn't per-se a real device, it's a pseudo-device that represents the use of the Aspeed built-in ColdFire to implement the FSI protocol by bitbanging the GPIOs instead of doing it from the ARM core.
Thus it's a drop-in replacement for the existing fsi-master-gpio pseudo-device for use on systems for which a corresponding firmware file exists. It has most of the same properties, plus some more needed to operate the coprocessor.
Signed-off-by Benjamin Herrenschmidt <[email protected]>--- .../bindings/fsi/fsi-master-ast-cf.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txtDocumentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +0
-0
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +8
-0@@ -0,0 +1,36 @@ +Device-tree bindings for ColdFire offloaded gpio-based FSI master driver +------------------------------------------------------------------------ + +Required properties: + - compatible = + "fsi-master-ast-2400-cf" for an AST2400 based system + or + "fsi-master-ast-2500-cf" for an AST2500 based system
<vendor>,<soc>-<block>
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 14
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ + - clock-gpios = <gpio-descriptor>; : GPIO for FSI clock + - data-gpios = <gpio-descriptor>; : GPIO for FSI data signal + - enable-gpios = <gpio-descriptor>; : GPIO for enable signal + - trans-gpios = <gpio-descriptor>; : GPIO for voltage translator enable + - mux-gpios = <gpio-descriptor>; : GPIO for pin multiplexing with other
So the gpio info is pased to the CF? Otherwise, what's the point of having these in DT?
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 20
Quoted 7 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ functions (eg, external FSI masters) + - memory-region = <phandle>; : Reference to the reserved memory for + the ColdFire. Must be 2M aligned on + AST2400 and 1M aligned on AST2500 + - sram = <phandle>; : Reference to the SRAM node. + - cvic = <phandle>; : Reference to the CVIC node.
Vendor prefixes.
Quoted 2 lines
+ - fw-name = <string>; : The name used to construct the firmware
+ file name (cf-fsi-<name>.bin)
firmware-name is used in some other places (and is the full filename).
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 26
Quoted 4 lines
+ - fw-platform-sig = <value>; : A signature value that must match the one
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +3
-0+ contained in the firmware image. Known + values are listed in the firmware interface + file cf-fsi-fw.h
Vendor prefix unless you think this could be common.
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 30
Quoted 4 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +4
-0+Examples: + + fsi-master { + compatible = "fsi-master-gpio", "fsi-master";
Forget to update the example?
Quoted 13 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ clock-gpios = <&gpio 0>; + data-gpios = <&gpio 1>; + enable-gpios = <&gpio 2>; + trans-gpios = <&gpio 3>; + mux-gpios = <&gpio 4>; + }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 11/14] dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
Quoted 18 lines · Rob Herring
Quoted 17 lines · Benjamin Herrenschmidt
This isn't per-se a real device, it's a pseudo-device that represents the use of the Aspeed built-in ColdFire to implement the FSI protocol by bitbanging the GPIOs instead of doing it from the ARM core.
Thus it's a drop-in replacement for the existing fsi-master-gpio pseudo-device for use on systems for which a corresponding firmware file exists. It has most of the same properties, plus some more needed to operate the coprocessor.
Signed-off-by Benjamin Herrenschmidt <[email protected]>--- .../bindings/fsi/fsi-master-ast-cf.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt
Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +0
-0Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +8
-0@@ -0,0 +1,36 @@ +Device-tree bindings for ColdFire offloaded gpio-based FSI master driver +------------------------------------------------------------------------ + +Required properties: + - compatible = + "fsi-master-ast-2400-cf" for an AST2400 based system + or + "fsi-master-ast-2500-cf" for an AST2500 based system<vendor>,<soc>-<block>
It's not really a SOC block from a vendor, it's a pseudo-device in a way. The current one that doesn't use the coldfire offload is just compatible "fsi-master-gpio".
I can add a vendor but what should it be ? aspeed because it runs on the aspeed SoCs only ? ibm because we wrote it and FSI is an IBM protocol ?
<soc>-<block> doesn't make sense here though.
Quoted 9 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 14
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ + - clock-gpios = <gpio-descriptor>; : GPIO for FSI clock + - data-gpios = <gpio-descriptor>; : GPIO for FSI data signal + - enable-gpios = <gpio-descriptor>; : GPIO for enable signal + - trans-gpios = <gpio-descriptor>; : GPIO for voltage translator enable + - mux-gpios = <gpio-descriptor>; : GPIO for pin multiplexing with otherSo the gpio info is pased to the CF? Otherwise, what's the point of having these in DT?
In the original version you are looking at, they are not passed to the CF per-se but the driver does use aspeed GPIO specific APIs to configure them to be owned by the CF, so we need the references.
However, I've just reworked the ucode with a few tricks to avoid losing singificant performance, so that we can indeed pass them to the CF, thus avoiding the need for a per-system image, so the above are here to stay.
Quoted 8 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 20
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ functions (eg, external FSI masters) + - memory-region = <phandle>; : Reference to the reserved memory for + the ColdFire. Must be 2M aligned on + AST2400 and 1M aligned on AST2500 + - sram = <phandle>; : Reference to the SRAM node. + - cvic = <phandle>; : Reference to the CVIC node.Vendor prefixes.
On what ? Why would an "sram" pointer have a vendor prefix ? Or a memory region pointer ?
Quoted 4 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 22
Quoted 2 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +2
-0+ - fw-name = <string>; : The name used to construct the firmware + file name (cf-fsi-<name>.bin)firmware-name is used in some other places (and is the full filename).
It's gone in the latest version as there's a single FW file now for all systems.
Quoted 7 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 26
Quoted 5 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +4
-0+ - fw-platform-sig = <value>; : A signature value that must match the one + contained in the firmware image. Known + values are listed in the firmware interface + file cf-fsi-fw.hVendor prefix unless you think this could be common.
It's going away.
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 30
Quoted 4 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +4
-0+Examples: + + fsi-master { + compatible = "fsi-master-gpio", "fsi-master";Forget to update the example?
Indeed :)
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ clock-gpios = <&gpio 0>; + data-gpios = <&gpio 1>; + enable-gpios = <&gpio 2>; + trans-gpios = <&gpio 3>; + mux-gpios = <&gpio 4>; + }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Rob Herring
maintainerRe: [PATCH 11/14] dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
Quoted 37 lines · Benjamin Herrenschmidt
Quoted 18 lines · Rob Herring
Quoted 17 lines · Benjamin Herrenschmidt
This isn't per-se a real device, it's a pseudo-device that represents the use of the Aspeed built-in ColdFire to implement the FSI protocol by bitbanging the GPIOs instead of doing it from the ARM core.
Thus it's a drop-in replacement for the existing fsi-master-gpio pseudo-device for use on systems for which a corresponding firmware file exists. It has most of the same properties, plus some more needed to operate the coprocessor.
Signed-off-by Benjamin Herrenschmidt <[email protected]>--- .../bindings/fsi/fsi-master-ast-cf.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txtQuoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +0
-0Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +8
-0@@ -0,0 +1,36 @@ +Device-tree bindings for ColdFire offloaded gpio-based FSI master driver +------------------------------------------------------------------------ + +Required properties: + - compatible = + "fsi-master-ast-2400-cf" for an AST2400 based system + or + "fsi-master-ast-2500-cf" for an AST2500 based system<vendor>,<soc>-<block>
Quoted 7 lines
It's not really a SOC block from a vendor, it's a pseudo-device in a way. The current one that doesn't use the coldfire offload is just compatible "fsi-master-gpio".
I can add a vendor but what should it be ? aspeed because it runs on the aspeed SoCs only ? ibm because we wrote it and FSI is an IBM protocol ?
I would say aspeed as it is tied to their chip.
Quoted 2 lines
<soc>-<block> doesn't make sense here though.
But you do already have <soc> in the compatible, but in a slightly different form and position. And "cf" is the block.
So I'd propose: aspeed,ast2500-cf-fsi-master
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ + - clock-gpios = <gpio-descriptor>; : GPIO for FSI clock + - data-gpios = <gpio-descriptor>; : GPIO for FSI data signal + - enable-gpios = <gpio-descriptor>; : GPIO for enable signal + - trans-gpios = <gpio-descriptor>; : GPIO for voltage translator enable + - mux-gpios = <gpio-descriptor>; : GPIO for pin multiplexing with other
Quoted 6 lines
Quoted 2 lines
So the gpio info is pased to the CF? Otherwise, what's the point of having these in DT?
In the original version you are looking at, they are not passed to the CF per-se but the driver does use aspeed GPIO specific APIs to configure them to be owned by the CF, so we need the references.
Okay.
Quoted 12 lines
However, I've just reworked the ucode with a few tricks to avoid losing singificant performance, so that we can indeed pass them to the CF, thus avoiding the need for a per-system image, so the above are here to stay.
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ functions (eg, external FSI masters) + - memory-region = <phandle>; : Reference to the reserved memory for + the ColdFire. Must be 2M aligned on + AST2400 and 1M aligned on AST2500 + - sram = <phandle>; : Reference to the SRAM node. + - cvic = <phandle>; : Reference to the CVIC node.
Quoted 4 lines
Quoted 1 line
Vendor prefixes.
On what ? Why would an "sram" pointer have a vendor prefix ? Or a memory region pointer ?
memory-region is a standard property. sram and cvic are not, so should have vendor prefixes. However, perhaps we should add a common "sram" property to sram/sram.txt.
Rob
Re: [PATCH 11/14] dt-bindings: fsi: Document binding for the fsi-master-ast-cf "device"
Quoted 12 lines · Rob Herring
Quoted 8 lines
It's not really a SOC block from a vendor, it's a pseudo-device in a way. The current one that doesn't use the coldfire offload is just compatible "fsi-master-gpio".
I can add a vendor but what should it be ? aspeed because it runs on the aspeed SoCs only ? ibm because we wrote it and FSI is an IBM protocol ?
I would say aspeed as it is tied to their chip.
Quoted 1 line
Quoted 6 lines
Quoted 1 line
<soc>-<block> doesn't make sense here though.
But you do already have <soc> in the compatible, but in a slightly different form and position. And "cf" is the block.
So I'd propose: aspeed,ast2500-cf-fsi-master
Ok, I'll do that.
Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
+
+ - clock-gpios = <gpio-descriptor>; : GPIO for FSI clock
+ - data-gpios = <gpio-descriptor>; : GPIO for FSI data signal
+ - enable-gpios = <gpio-descriptor>; : GPIO for enable signal
+ - trans-gpios = <gpio-descriptor>; : GPIO for voltage translator enable
+ - mux-gpios = <gpio-descriptor>; : GPIO for pin multiplexing with otherQuoted 6 lines
Quoted 2 lines
So the gpio info is pased to the CF? Otherwise, what's the point of having these in DT?
In the original version you are looking at, they are not passed to the CF per-se but the driver does use aspeed GPIO specific APIs to configure them to be owned by the CF, so we need the references.
Okay.
Quoted 12 lines
However, I've just reworked the ucode with a few tricks to avoid losing singificant performance, so that we can indeed pass them to the CF, thus avoiding the need for a per-system image, so the above are here to stay.
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/fsi/fsi-master-ast-cf.txt new file +6
-0+ functions (eg, external FSI masters) + - memory-region = <phandle>; : Reference to the reserved memory for + the ColdFire. Must be 2M aligned on + AST2400 and 1M aligned on AST2500 + - sram = <phandle>; : Reference to the SRAM node. + - cvic = <phandle>; : Reference to the CVIC node.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Vendor prefixes.
On what ? Why would an "sram" pointer have a vendor prefix ? Or a memory region pointer ?
memory-region is a standard property. sram and cvic are not, so should have vendor prefixes. However, perhaps we should add a common "sram" property to
sram/sram.txt.
Hrm... originally vendor prefix on properties were for things that didn't have a binding afaik. IE a way for an f-code driver to stash things in the DT that were vendor specific and retrieve them from the OS driver for example.
Here with well defined bindings it's rather bloaty don't you think ? I don't strongly object to doing it, it's just a bit ... odd.
Cheers,
Ben.
Re: [PATCH 06/14] fsi: master-gpio: Add more tracepoints
In reply to Joel StanleyQuoted 27 lines · Joel Stanley
Quoted 4 lines · Benjamin Herrenschmidt
This adds a few more tracepoints that have proven useful when debugging issues with the FSI bus.
Signed-off-by Benjamin Herrenschmidt <[email protected]>Reviewed-by Joel Stanley <[email protected]>Quoted 18 lines
--- drivers/fsi/fsi-master-gpio.c | 16 ++++--- include/trace/events/fsi_master_gpio.h | 59 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-)drivers/fsi/fsi-master-gpio.c +1
-0@@ -130,10 +130,17 @@ static void set_sda_output(struct fsi_master_gpio *master, int value)static void clock_zeros (struct fsi_master_gpio *master,int count) { +trace_fsi_master_gpio_clock_zeros (master, count);set_sda_output (master,1 );clock_toggle (master, count); }
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c static void set_sda_output(struct fsi_master_gpio *master, int value) · line 141
Quoted 4 lines
drivers/fsi/fsi-master-gpio.c +4
-0+static void echo_delay (struct fsi_master_gpio *master) +{ +clock_zeros (master, master->t_echo_delay); +}This doesn't look like it belongs in this patch.
You've just moved it up. Not worth a re-spin.
I've done more, I made it use clock_zeros() instead of open coding it in order to share the tracepoint.
Quoted 39 lines
Quoted 39 lines
drivers/fsi/fsi-master-gpio.c +5
-6+ +static void serial_in (struct fsi_master_gpio *master,struct fsi_gpio_msg *msg,uint8_t num_bits) {@@ -279,16 +286,19 @@ static void build_ar_command(struct fsi_master_gpio *master, addr_bits =2 ; opcode_bits =2 ; opcode =FSI_GPIO_CMD_SAME_AR ; +trace_fsi_master_gpio_cmd_same_addr (master); }else if (check_relative_address (master, id, addr, &rel_addr)) {/* 8 bits plus sign */ addr_bits =9 ; addr = rel_addr; opcode =FSI_GPIO_CMD_REL_AR ; +trace_fsi_master_gpio_cmd_rel_addr (master, rel_addr); }else { addr_bits =21 ; opcode =FSI_GPIO_CMD_ABS_AR ; +trace_fsi_master_gpio_cmd_abs_addr (master, addr); }/* @@ -337,12 +347,6 @@ static void build_epoll_command(struct fsi_gpio_msg *cmd, uint8_t slave_id)msg_push_crc (cmd); } -static void echo_delay (struct fsi_master_gpio *master) -{ -set_sda_output (master,1 ); -clock_toggle (master, master->t_echo_delay); -} -static void build_term_command (struct fsi_gpio_msg *cmd,uint8_t slave_id) { cmd->bits =0 ;