Re: [PATCH v3 10/13] usb: chipidea: add sys inputs for OTG fsm input.
On Thu, Mar 06, 2014 at 12:44:16PM +0800, Peter Chen wrote: On Thu, Feb 27, 2014 at 07:38:28AM +0800, Li Jun wrote: This patch adds sys input to control and show OTG fsm inputs by application, user can do host and preipheral role switch by change these inputs. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/otg.c |1 + drivers/usb/chipidea/otg_fsm.c | 192 drivers/usb/chipidea/otg_fsm.h |6 ++ 3 files changed, 199 insertions(+) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 4fb33a2..6c10b91 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -129,4 +129,5 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci) } ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS); ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS); + ci_hdrc_otg_fsm_remove(ci); } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 0601058..0e980f1 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -41,6 +41,185 @@ static struct ci_otg_fsm_timer *otg_timer_initializer return timer; } +/* Add for otg: interact with user space app */ +static ssize_t +get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_req); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_req = 0; + } else if (buf[0] == '1') { + /* If a_bus_drop is TRUE, a_bus_req can't be set */ + if (ci-fsm-a_bus_drop) + goto end; + ci-fsm-a_bus_req = 1; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } else + dev_err(ci-dev, error: otg setup is not completed!\n); +end: + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req); + +static ssize_t +get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_drop); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_drop(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_drop = 0; + } else if (buf[0] == '1') { + ci-fsm-a_bus_drop = 1; + ci-fsm-a_bus_req = 0; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, + set_a_bus_drop); + +static ssize_t +get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-b_bus_req); + size -= t; + next += t; + } + + return PAGE_SIZE - size; +} + +static ssize_t +set_b_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if
Re: [PATCH v3 10/13] usb: chipidea: add sys inputs for OTG fsm input.
On Wed, Mar 12, 2014 at 04:03:34PM +0800, Li Jun wrote: On Thu, Mar 06, 2014 at 12:44:16PM +0800, Peter Chen wrote: On Thu, Feb 27, 2014 at 07:38:28AM +0800, Li Jun wrote: This patch adds sys input to control and show OTG fsm inputs by application, user can do host and preipheral role switch by change these inputs. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/otg.c |1 + drivers/usb/chipidea/otg_fsm.c | 192 drivers/usb/chipidea/otg_fsm.h |6 ++ 3 files changed, 199 insertions(+) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 4fb33a2..6c10b91 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -129,4 +129,5 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci) } ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS); ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS); + ci_hdrc_otg_fsm_remove(ci); } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 0601058..0e980f1 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -41,6 +41,185 @@ static struct ci_otg_fsm_timer *otg_timer_initializer return timer; } +/* Add for otg: interact with user space app */ +static ssize_t +get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_req); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_req = 0; + } else if (buf[0] == '1') { + /* If a_bus_drop is TRUE, a_bus_req can't be set */ + if (ci-fsm-a_bus_drop) + goto end; + ci-fsm-a_bus_req = 1; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } else + dev_err(ci-dev, error: otg setup is not completed!\n); +end: + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req); + +static ssize_t +get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_drop); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_drop(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_drop = 0; + } else if (buf[0] == '1') { + ci-fsm-a_bus_drop = 1; + ci-fsm-a_bus_req = 0; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, + set_a_bus_drop); + +static ssize_t +get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-b_bus_req); + size -= t; + next += t; + } + + return PAGE_SIZE - size; +} + +static ssize_t +set_b_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count)
Re: [PATCH v3 10/13] usb: chipidea: add sys inputs for OTG fsm input.
On Thu, Feb 27, 2014 at 07:38:28AM +0800, Li Jun wrote: This patch adds sys input to control and show OTG fsm inputs by application, user can do host and preipheral role switch by change these inputs. Signed-off-by: Li Jun b47...@freescale.com --- drivers/usb/chipidea/otg.c |1 + drivers/usb/chipidea/otg_fsm.c | 192 drivers/usb/chipidea/otg_fsm.h |6 ++ 3 files changed, 199 insertions(+) diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index 4fb33a2..6c10b91 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -129,4 +129,5 @@ void ci_hdrc_otg_destroy(struct ci_hdrc *ci) } ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS); ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS); + ci_hdrc_otg_fsm_remove(ci); } diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 0601058..0e980f1 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c @@ -41,6 +41,185 @@ static struct ci_otg_fsm_timer *otg_timer_initializer return timer; } +/* Add for otg: interact with user space app */ +static ssize_t +get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_req); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_req = 0; + } else if (buf[0] == '1') { + /* If a_bus_drop is TRUE, a_bus_req can't be set */ + if (ci-fsm-a_bus_drop) + goto end; + ci-fsm-a_bus_req = 1; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } else + dev_err(ci-dev, error: otg setup is not completed!\n); +end: + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req); + +static ssize_t +get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-a_bus_drop); + size -= t; + next += t; + } else + dev_err(ci-dev, error: otg setup is not completed!\n); + + return PAGE_SIZE - size; +} + +static ssize_t +set_a_bus_drop(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + + mutex_lock(ci-fsm-lock); + if (ci-transceiver ci-transceiver-otg ci-fsm) { + if (buf[0] == '0') { + ci-fsm-a_bus_drop = 0; + } else if (buf[0] == '1') { + ci-fsm-a_bus_drop = 1; + ci-fsm-a_bus_req = 0; + } + + disable_irq_nosync(ci-irq); + queue_work(ci-wq, ci-work); + } + mutex_unlock(ci-fsm-lock); + + return count; +} +static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, + set_a_bus_drop); + +static ssize_t +get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) +{ + char*next; + unsignedsize, t; + struct ci_hdrc *ci = dev_get_drvdata(dev); + + next = buf; + size = PAGE_SIZE; + + if (ci-transceiver ci-transceiver-otg ci-fsm) { + t = scnprintf(next, size, %d\n, ci-fsm-b_bus_req); + size -= t; + next += t; + } + + return PAGE_SIZE - size; +} + +static ssize_t +set_b_bus_req(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct ci_hdrc *ci = dev_get_drvdata(dev); + + if (count 2) + return -1; + +