Re: [PATCH net v1] lan743x: fix ethernet frame cutoff issue

2021-04-09 Thread George McCollister
On Thu, Apr 8, 2021 at 7:39 PM Sven Van Asbroeck  wrote:
>
> From: Sven Van Asbroeck 
>
> The ethernet frame length is calculated incorrectly. Depending on
> the value of RX_HEAD_PADDING, this may result in ethernet frames
> that are too short (cut off at the end), or too long (garbage added
> to the end).
>
> Fix by calculating the ethernet frame length correctly. For added
> clarity, use the ETH_FCS_LEN constant in the calculation.
>
> Many thanks to Heiner Kallweit for suggesting this solution.
>
> Fixes: 3e21a10fdea3 ("lan743x: trim all 4 bytes of the FCS; not just 2")
> Link: https://lore.kernel.org/lkml/20210408172353.21143-1-thesve...@gmail.com/
> Signed-off-by: Sven Van Asbroeck 

I'm glad everyone was able to work together to get this fixed properly
without any figure pointing or mud slinging! Kudos everyone.

Reviewed-by: George McCollister 
Tested-By: George McCollister 

> ---
>
> Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git # 
> 864db232dc70
>
> To: Bryan Whitehead 
> To: "David S. Miller" 
> To: Jakub Kicinski 
> To: George McCollister 
> Cc: Heiner Kallweit 
> Cc: Andrew Lunn 
> Cc: unglinuxdri...@microchip.com
> Cc: net...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
>  drivers/net/ethernet/microchip/lan743x_main.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index 1c3e204d727c..7b6794aa8ea9 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -885,8 +885,8 @@ static int lan743x_mac_set_mtu(struct lan743x_adapter 
> *adapter, int new_mtu)
> }
>
> mac_rx &= ~(MAC_RX_MAX_SIZE_MASK_);
> -   mac_rx |= (((new_mtu + ETH_HLEN + 4) << MAC_RX_MAX_SIZE_SHIFT_) &
> - MAC_RX_MAX_SIZE_MASK_);
> +   mac_rx |= (((new_mtu + ETH_HLEN + ETH_FCS_LEN)
> + << MAC_RX_MAX_SIZE_SHIFT_) & MAC_RX_MAX_SIZE_MASK_);
> lan743x_csr_write(adapter, MAC_RX, mac_rx);
>
> if (enabled) {
> @@ -1944,7 +1944,7 @@ static int lan743x_rx_init_ring_element(struct 
> lan743x_rx *rx, int index)
> struct sk_buff *skb;
> dma_addr_t dma_ptr;
>
> -   buffer_length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING;
> +   buffer_length = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + 
> RX_HEAD_PADDING;
>
> descriptor = >ring_cpu_ptr[index];
> buffer_info = >buffer_info[index];
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
> +   frame_length = max_t(int, 0, frame_length - ETH_FCS_LEN);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;
> --
> 2.17.1
>


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 1:35 PM Sven Van Asbroeck  wrote:
>
> Hi George,
>
> On Thu, Apr 8, 2021 at 2:26 PM Sven Van Asbroeck  wrote:
> >
> > George, I will send a patch for you to try shortly. Except if you're
> > already ahead :)
>
> Would this work for you? It does for me.

Works for me too.

>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index dbdfabff3b00..7b6794aa8ea9 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -885,8 +885,8 @@ static int lan743x_mac_set_mtu(struct
> lan743x_adapter *adapter, int new_mtu)
> }
>
> mac_rx &= ~(MAC_RX_MAX_SIZE_MASK_);
> -   mac_rx |= (((new_mtu + ETH_HLEN + 4) << MAC_RX_MAX_SIZE_SHIFT_) &
> - MAC_RX_MAX_SIZE_MASK_);
> +   mac_rx |= (((new_mtu + ETH_HLEN + ETH_FCS_LEN)
> + << MAC_RX_MAX_SIZE_SHIFT_) & MAC_RX_MAX_SIZE_MASK_);
> lan743x_csr_write(adapter, MAC_RX, mac_rx);
>
> if (enabled) {
> @@ -1944,7 +1944,7 @@ static int lan743x_rx_init_ring_element(struct
> lan743x_rx *rx, int index)
> struct sk_buff *skb;
> dma_addr_t dma_ptr;
>
> -   buffer_length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING;
> +   buffer_length = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + 
> RX_HEAD_PADDING;
>
> descriptor = >ring_cpu_ptr[index];
> buffer_info = >buffer_info[index];
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
> +   frame_length = max_t(int, 0, frame_length - ETH_FCS_LEN);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 12:46 PM Sven Van Asbroeck  wrote:
>
> Hi George,
>
> On Thu, Apr 8, 2021 at 1:36 PM George McCollister
>  wrote:
> >
> > Can you explain the difference in behavior with what I was observing
> > on the LAN7431?
>
> I'm not using DSA in my application, so I cannot test or replicate
> what you were observing. It would be great if we could work together
> and settle on a solution that is acceptable to both of us.

Sounds good.

>
> > I'll retest but if this is reverted I'm going to start
> > seeing 2 extra bytes on the end of frames and it's going to break DSA
> > with the LAN7431 again.
> >
>
> Seen from my point of view, your patch is a regression. But perhaps my
> patch set is a regression for you? Catch 22...
>
> Would you be able to identify which patch broke your DSA behaviour?
> Was it one of mine? Perhaps we can start from there.

Yes, first I'm going to confirm that what is in the net branch still
works (unlikely but perhaps something else could have broken it since
last I tried it).
Then I'll confirm the patch which I believe broke it actually did and
report back.

>
> Sven


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 12:23 PM Sven Van Asbroeck  wrote:
>
> From: Sven Van Asbroeck 
>
> This reverts commit 3e21a10fdea3c2e4e4d1b72cb9d720256461af40.
>
> The reverted patch completely breaks all network connectivity on the
> lan7430. tcpdump indicates missing bytes when receiving ping
> packets from an external host:

Can you explain the difference in behavior with what I was observing
on the LAN7431? I'll retest but if this is reverted I'm going to start
seeing 2 extra bytes on the end of frames and it's going to break DSA
with the LAN7431 again.

>
> host$ ping $lan7430_ip
> lan7430$ tcpdump -v
> IP truncated-ip - 2 bytes missing! (tos 0x0, ttl 64, id 21715,
> offset 0, flags [DF], proto ICMP (1), length 84)
>
> Fixes: 3e21a10fdea3 ("lan743x: trim all 4 bytes of the FCS; not just 2")
> Signed-off-by: Sven Van Asbroeck 
> ---
>
> To: Bryan Whitehead 
> To: "David S. Miller" 
> To: Jakub Kicinski 
> To: George McCollister 
> Cc: unglinuxdri...@microchip.com
> Cc: net...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
>  drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index 1c3e204d727c..dbdfabff3b00 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
> +   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;
> --
> 2.17.1
>

Regards,
George


Re: [PATCH net] net: dsa: don't assign an error value to tag_ops

2021-03-22 Thread George McCollister
On Mon, Mar 22, 2021 at 3:46 PM Vladimir Oltean  wrote:
>
> On Mon, Mar 22, 2021 at 03:26:50PM -0500, George McCollister wrote:
> > Use a temporary variable to hold the return value from
> > dsa_tag_driver_get() instead of assigning it to dst->tag_ops. Leaving
> > an error value in dst->tag_ops can result in deferencing an invalid
> > pointer when a deferred switch configuration happens later.
> >
> > Fixes: 357f203bb3b5 ("net: dsa: keep a copy of the tagging protocol in the 
> > DSA switch tree")
> >
> > Signed-off-by: George McCollister 
> > ---
>
> Who dereferences the invalid pointer? dsa_tree_free I guess?

I saw it occur just above on the following line the next time
dsa_port_parse_cpu() is called:
if (dst->tag_ops->proto != tag_protocol) {

-George


[PATCH net] net: dsa: don't assign an error value to tag_ops

2021-03-22 Thread George McCollister
Use a temporary variable to hold the return value from
dsa_tag_driver_get() instead of assigning it to dst->tag_ops. Leaving
an error value in dst->tag_ops can result in deferencing an invalid
pointer when a deferred switch configuration happens later.

Fixes: 357f203bb3b5 ("net: dsa: keep a copy of the tagging protocol in the DSA 
switch tree")

Signed-off-by: George McCollister 
---
 net/dsa/dsa2.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index eb709d988c54..8f9e35e1aa89 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -1068,6 +1068,7 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct 
net_device *master)
 {
struct dsa_switch *ds = dp->ds;
struct dsa_switch_tree *dst = ds->dst;
+   const struct dsa_device_ops *tag_ops;
enum dsa_tag_protocol tag_protocol;
 
tag_protocol = dsa_get_tag_protocol(dp, master);
@@ -1082,14 +1083,16 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, 
struct net_device *master)
 * nothing to do here.
 */
} else {
-   dst->tag_ops = dsa_tag_driver_get(tag_protocol);
-   if (IS_ERR(dst->tag_ops)) {
-   if (PTR_ERR(dst->tag_ops) == -ENOPROTOOPT)
+   tag_ops = dsa_tag_driver_get(tag_protocol);
+   if (IS_ERR(tag_ops)) {
+   if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
return -EPROBE_DEFER;
dev_warn(ds->dev, "No tagger for this switch\n");
dp->master = NULL;
-   return PTR_ERR(dst->tag_ops);
+   return PTR_ERR(tag_ops);
}
+
+   dst->tag_ops = tag_ops;
}
 
dp->master = master;
-- 
2.11.0



[PATCH net] net: dsa: xrs700x: check if partner is same as port in hsr join

2021-03-08 Thread George McCollister
Don't assign dp to partner if it's the same port that xrs700x_hsr_join
was called with. The partner port is supposed to be the other port in
the HSR/PRP redundant pair not the same port. This fixes an issue
observed in testing where forwarding between redundant HSR ports on this
switch didn't work depending on the order the ports were added to the
hsr device.

Fixes: bd62e6f5e6a9 ("net: dsa: xrs700x: add HSR offloading support")
Signed-off-by: George McCollister 
---
 drivers/net/dsa/xrs700x/xrs700x.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/xrs700x/xrs700x.c 
b/drivers/net/dsa/xrs700x/xrs700x.c
index f025f968f96d..fde6e99274b6 100644
--- a/drivers/net/dsa/xrs700x/xrs700x.c
+++ b/drivers/net/dsa/xrs700x/xrs700x.c
@@ -528,7 +528,10 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int 
port,
return -EOPNOTSUPP;
 
dsa_hsr_foreach_port(dp, ds, hsr) {
-   partner = dp;
+   if (dp->index != port) {
+   partner = dp;
+   break;
+   }
}
 
/* We can't enable redundancy on the switch until both
@@ -582,7 +585,10 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int 
port,
unsigned int val;
 
dsa_hsr_foreach_port(dp, ds, hsr) {
-   partner = dp;
+   if (dp->index != port) {
+   partner = dp;
+   break;
+   }
}
 
if (!partner)
-- 
2.11.0



[PATCH net] lan743x: trim all 4 bytes of the FCS; not just 2

2021-03-05 Thread George McCollister
Trim all 4 bytes of the received FCS; not just 2 of them. Leaving 2
bytes of the FCS on the frame breaks DSA tailing tag drivers.

Fixes: a8db76d40e4d ("lan743x: boost performance on cpu archs w/o dma cache 
snooping")
Signed-off-by: George McCollister 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index 334e99ffe56f..360d16965a5c 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length)
dev_kfree_skb_irq(skb);
return NULL;
}
-   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
+   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
if (skb->len > frame_length) {
skb->tail -= skb->len - frame_length;
skb->len = frame_length;
-- 
2.11.0



Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-22 Thread George McCollister
On Mon, Feb 22, 2021 at 7:38 AM Wenzel, Marco  wrote:
>
> On Fri, Feb 19, 2021 at 2:14 PM : George McCollister 
>  wrote:
> >
> > On Fri, Feb 19, 2021 at 2:27 AM Wenzel, Marco  > eberle.de> wrote:
> > >
> > > On Thu, Feb 18, 2021 at 6:06 PM : George McCollister
> >  wrote:
> > > >
> > > > On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  > > > eberle.de> wrote:
> > > > >
> > > > > In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms.
> > > > > When a node does not send any frame within this time, the sequence
> > > > > number check for can be ignored. This solves communication issues
> > > > > with Cisco IE 2000 in Redbox mode.
> > > > >
> > > > > Fixes: f421436a591d ("net/hsr: Add support for the
> > > > > High-availability Seamless Redundancy protocol (HSRv0)")
> > > > > Signed-off-by: Marco Wenzel 
> > > > > ---
> > > > >  net/hsr/hsr_framereg.c | 9 +++--  net/hsr/hsr_framereg.h | 1
> > > > > +
> > > > >  net/hsr/hsr_main.h | 1 +
> > > > >  3 files changed, 9 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index
> > > > > 5c97de459905..805f974923b9 100644
> > > > > --- a/net/hsr/hsr_framereg.c
> > > > > +++ b/net/hsr/hsr_framereg.c
> > > > > @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct
> > > > hsr_priv *hsr,
> > > > >  * as initialization. (0 could trigger an spurious ring error 
> > > > > warning).
> > > > >  */
> > > > > now = jiffies;
> > > > > -   for (i = 0; i < HSR_PT_PORTS; i++)
> > > > > +   for (i = 0; i < HSR_PT_PORTS; i++) {
> > > > > new_node->time_in[i] = now;
> > > > > +   new_node->time_out[i] = now;
> > > > > +   }
> > > > > for (i = 0; i < HSR_PT_PORTS; i++)
> > > > > new_node->seq_out[i] = seq_out;
> > > > >
> > > > > @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node
> > > > *node,
> > > > > struct hsr_port *port,  int hsr_register_frame_out(struct hsr_port
> > > > > *port,
> > > > struct hsr_node *node,
> > > > >u16 sequence_nr)  {
> > > > > -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port-
> > >type]))
> > > > > +   if (seq_nr_before_or_eq(sequence_nr,
> > > > > + node->seq_out[port->type])
> > > > &&
> > > > > +   time_is_after_jiffies(node->time_out[port->type] +
> > > > > +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> > > > > return 1;
> > > > >
> > > > > +   node->time_out[port->type] = jiffies;
> > > > > node->seq_out[port->type] = sequence_nr;
> > > > > return 0;
> > > > >  }
> > > > > diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index
> > > > > 86b43f539f2c..d9628e7a5f05 100644
> > > > > --- a/net/hsr/hsr_framereg.h
> > > > > +++ b/net/hsr/hsr_framereg.h
> > > > > @@ -75,6 +75,7 @@ struct hsr_node {
> > > > > enum hsr_port_type  addr_B_port;
> > > > > unsigned long   time_in[HSR_PT_PORTS];
> > > > > booltime_in_stale[HSR_PT_PORTS];
> > > > > +   unsigned long   time_out[HSR_PT_PORTS];
> > > > > /* if the node is a SAN */
> > > > > boolsan_a;
> > > > > boolsan_b;
> > > > > diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index
> > > > > 7dc92ce5a134..f79ca55d6986 100644
> > > > > --- a/net/hsr/hsr_main.h
> > > > > +++ b/net/hsr/hsr_main.h
> > > > > @@ -21,6 +21,7 @@
> > > > >  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
> > > > >  #define HSR_NODE_FORGET_TIME   6 /* ms */
> > > > >  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> > > > > +#define HSR_ENTRY_FORGET_TIME400 /* ms 

Re: [PATCH net-next] net: dsa: Fix dependencies with HSR

2021-02-20 Thread George McCollister
On Fri, Feb 19, 2021 at 11:14 PM Florian Fainelli  wrote:
>
>
>
> On 2/19/2021 9:12 PM, Florian Fainelli wrote:
> > The core DSA framework uses hsr_is_master() which would not resolve to a
> > valid symbol if HSR is built-into the kernel and DSA is a module.
> >
> > Fixes: 18596f504a3e ("net: dsa: add support for offloading HSR")
> > Reported-by: kernel test robot 
> > Signed-off-by: Florian Fainelli 
> > ---
> > David, Jakub,
> >
> > This showed up in linux-next which means it will show up in Linus' tree
> > soon as well when your pull request gets sent out.
>
> I had initially considered making is_hsr_master() a static inline that
> would compare dev->dev.type->name with "hsr" since the HSR master would
> set a custom dev_type, however the xrs700x driver would still fail to
> link because it calls hsr_get_version() and for that one there is no
> easy solution.

Thanks for looking into this. It's not something I've run into before.
It didn't occur to me what would happen if HSR was a module. I'll look
out for this in the future.

Sorry for the inconvenience.

Reviewed-by: George McCollister 

-George

> --
> Florian


Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-19 Thread George McCollister
On Fri, Feb 19, 2021 at 2:27 AM Wenzel, Marco  wrote:
>
> On Thu, Feb 18, 2021 at 6:06 PM : George McCollister 
>  wrote:
> >
> > On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  > eberle.de> wrote:
> > >
> > > In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms. When
> > > a node does not send any frame within this time, the sequence number
> > > check for can be ignored. This solves communication issues with Cisco
> > > IE 2000 in Redbox mode.
> > >
> > > Fixes: f421436a591d ("net/hsr: Add support for the High-availability
> > > Seamless Redundancy protocol (HSRv0)")
> > > Signed-off-by: Marco Wenzel 
> > > ---
> > >  net/hsr/hsr_framereg.c | 9 +++--
> > >  net/hsr/hsr_framereg.h | 1 +
> > >  net/hsr/hsr_main.h | 1 +
> > >  3 files changed, 9 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index
> > > 5c97de459905..805f974923b9 100644
> > > --- a/net/hsr/hsr_framereg.c
> > > +++ b/net/hsr/hsr_framereg.c
> > > @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct
> > hsr_priv *hsr,
> > >  * as initialization. (0 could trigger an spurious ring error 
> > > warning).
> > >  */
> > > now = jiffies;
> > > -   for (i = 0; i < HSR_PT_PORTS; i++)
> > > +   for (i = 0; i < HSR_PT_PORTS; i++) {
> > > new_node->time_in[i] = now;
> > > +   new_node->time_out[i] = now;
> > > +   }
> > > for (i = 0; i < HSR_PT_PORTS; i++)
> > > new_node->seq_out[i] = seq_out;
> > >
> > > @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node
> > *node,
> > > struct hsr_port *port,  int hsr_register_frame_out(struct hsr_port *port,
> > struct hsr_node *node,
> > >u16 sequence_nr)  {
> > > -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]))
> > > +   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type])
> > &&
> > > +   time_is_after_jiffies(node->time_out[port->type] +
> > > +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> > > return 1;
> > >
> > > +   node->time_out[port->type] = jiffies;
> > > node->seq_out[port->type] = sequence_nr;
> > > return 0;
> > >  }
> > > diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index
> > > 86b43f539f2c..d9628e7a5f05 100644
> > > --- a/net/hsr/hsr_framereg.h
> > > +++ b/net/hsr/hsr_framereg.h
> > > @@ -75,6 +75,7 @@ struct hsr_node {
> > > enum hsr_port_type  addr_B_port;
> > > unsigned long   time_in[HSR_PT_PORTS];
> > > booltime_in_stale[HSR_PT_PORTS];
> > > +   unsigned long   time_out[HSR_PT_PORTS];
> > > /* if the node is a SAN */
> > > boolsan_a;
> > > boolsan_b;
> > > diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index
> > > 7dc92ce5a134..f79ca55d6986 100644
> > > --- a/net/hsr/hsr_main.h
> > > +++ b/net/hsr/hsr_main.h
> > > @@ -21,6 +21,7 @@
> > >  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
> > >  #define HSR_NODE_FORGET_TIME   6 /* ms */
> > >  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> > > +#define HSR_ENTRY_FORGET_TIME400 /* ms */
> > >
> > >  /* By how much may slave1 and slave2 timestamps of latest received
> > frame from
> > >   * each node differ before we notify of communication problem?
> > > --
> > > 2.30.0
> > >
> >
> > scripts/checkpatch.pl gives errors about DOS line endings but once that is
> > resolved this looks good. I tested it on an HSR network with the software
> > implementation and the xrs700x which uses offloading and everything still
> > works. I don't have a way to force anything on the HSR network to reuse
> > sequence numbers after 400ms.
> >
> > Reviewed-by: George McCollister  > Tested-by: George McCollister 
> Thank you very much for reviewing, testing and supporting!
>
> Where do you see the incorrect line endings? I just ran scripts/checkpath.pl 
> as git commit hook and it did not report any errors. When I run it again 
> manually, it also does not report any errors:
>
> # ./scripts/checkpatch.pl --strict 
> /tmp/0001-net-hsr-add-support-for-EntryForgetTime.patch
> total: 0 errors, 0 warnings, 0 checks, 38 lines checked
>
> /tmp/0001-net-hsr-add-support-for-EntryForgetTime.patch has no obvious style 
> problems and is ready for submission.

Sorry about this. It seems when I downloaded the patch with Chromium
from gmail in Linux it added DOS new lines (this is unexpected). When
I downloaded it from lore.kernel.org it's fine.

Reviewed-by: George McCollister 
Tested-by: George McCollister 

>
>
> Regards,
> Marco Wenzel


Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-18 Thread George McCollister
On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  wrote:
>
> In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms. When a
> node does not send any frame within this time, the sequence number check
> for can be ignored. This solves communication issues with Cisco IE 2000
> in Redbox mode.
>
> Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless 
> Redundancy protocol (HSRv0)")
> Signed-off-by: Marco Wenzel 
> ---
>  net/hsr/hsr_framereg.c | 9 +++--
>  net/hsr/hsr_framereg.h | 1 +
>  net/hsr/hsr_main.h | 1 +
>  3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
> index 5c97de459905..805f974923b9 100644
> --- a/net/hsr/hsr_framereg.c
> +++ b/net/hsr/hsr_framereg.c
> @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct hsr_priv 
> *hsr,
>  * as initialization. (0 could trigger an spurious ring error 
> warning).
>  */
> now = jiffies;
> -   for (i = 0; i < HSR_PT_PORTS; i++)
> +   for (i = 0; i < HSR_PT_PORTS; i++) {
> new_node->time_in[i] = now;
> +   new_node->time_out[i] = now;
> +   }
> for (i = 0; i < HSR_PT_PORTS; i++)
> new_node->seq_out[i] = seq_out;
>
> @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node *node, struct 
> hsr_port *port,
>  int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
>u16 sequence_nr)
>  {
> -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]))
> +   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]) &&
> +   time_is_after_jiffies(node->time_out[port->type] +
> +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> return 1;
>
> +   node->time_out[port->type] = jiffies;
> node->seq_out[port->type] = sequence_nr;
> return 0;
>  }
> diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
> index 86b43f539f2c..d9628e7a5f05 100644
> --- a/net/hsr/hsr_framereg.h
> +++ b/net/hsr/hsr_framereg.h
> @@ -75,6 +75,7 @@ struct hsr_node {
> enum hsr_port_type  addr_B_port;
> unsigned long   time_in[HSR_PT_PORTS];
> booltime_in_stale[HSR_PT_PORTS];
> +   unsigned long   time_out[HSR_PT_PORTS];
> /* if the node is a SAN */
> boolsan_a;
> boolsan_b;
> diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h
> index 7dc92ce5a134..f79ca55d6986 100644
> --- a/net/hsr/hsr_main.h
> +++ b/net/hsr/hsr_main.h
> @@ -21,6 +21,7 @@
>  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
>  #define HSR_NODE_FORGET_TIME   6 /* ms */
>  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> +#define HSR_ENTRY_FORGET_TIME400 /* ms */
>
>  /* By how much may slave1 and slave2 timestamps of latest received frame from
>   * each node differ before we notify of communication problem?
> --
> 2.30.0
>

scripts/checkpatch.pl gives errors about DOS line endings but once
that is resolved this looks good. I tested it on an HSR network with
the software implementation and the xrs700x which uses offloading and
everything still works. I don't have a way to force anything on the
HSR network to reuse sequence numbers after 400ms.

Reviewed-by: George McCollister 

Re: [PATCH net-next 1/2] net: add EXPORT_INDIRECT_CALLABLE wrapper

2021-02-04 Thread George McCollister
I don't see the second patch.

Regards,
George McCollister


Re: [PATCH v4 net-next 1/2] net: dsa: add optional stats64 support

2020-12-07 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Allow DSA drivers to export stats64
>
> Signed-off-by: Oleksij Rempel 
> Reviewed-by: Vladimir Oltean 

Reviewed-by: George McCollister 

I've already updated my xrs700x dsa driver for v3 to use this. I'm
blocked on sending v3 until this is in. Please CC me on any updates.

Thanks,
George


Re: [PATCH v4 net-next 2/2] net: dsa: qca: ar9331: export stats64

2020-12-04 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Add stats support for the ar9331 switch.
>
> Signed-off-by: Oleksij Rempel 
> ---
>  drivers/net/dsa/qca/ar9331.c | 247 ++-
>  1 file changed, 246 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c
> index 605d7b675216..4c1a4c448d80 100644
> --- a/drivers/net/dsa/qca/ar9331.c
> +++ b/drivers/net/dsa/qca/ar9331.c
> @@ -101,6 +101,57 @@
>  AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN 
> | \
>  AR9331_SW_PORT_STATUS_SPEED_M)
>
> +/* MIB registers */
> +#define AR9331_MIB_COUNTER(x)  (0x2 + ((x) * 0x100))
> +
> +#define AR9331_PORT_MIB_rxbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x00)
> +#define AR9331_PORT_MIB_rxpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x04)
> +#define AR9331_PORT_MIB_rxmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x08)
> +#define AR9331_PORT_MIB_rxfcserr(_port)
> (AR9331_MIB_COUNTER(_port) + 0x0c)
> +#define AR9331_PORT_MIB_rxalignerr(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x10)
> +#define AR9331_PORT_MIB_rxrunt(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x14)
> +#define AR9331_PORT_MIB_rxfragment(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x18)
> +#define AR9331_PORT_MIB_rx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x1c)
> +#define AR9331_PORT_MIB_rx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x20)
> +#define AR9331_PORT_MIB_rx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x24)
> +#define AR9331_PORT_MIB_rx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x28)
> +#define AR9331_PORT_MIB_rx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x2c)
> +#define AR9331_PORT_MIB_rx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x30)
> +#define AR9331_PORT_MIB_rxmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x34)
> +#define AR9331_PORT_MIB_rxtoolong(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x38)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxgoodbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x3c)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxbadbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x44)
> +
> +#define AR9331_PORT_MIB_rxoverflow(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x4c)
> +#define AR9331_PORT_MIB_filtered(_port)
> (AR9331_MIB_COUNTER(_port) + 0x50)
> +#define AR9331_PORT_MIB_txbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x54)
> +#define AR9331_PORT_MIB_txpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x58)
> +#define AR9331_PORT_MIB_txmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x5c)
> +#define AR9331_PORT_MIB_txunderrun(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x60)
> +#define AR9331_PORT_MIB_tx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x64)
> +#define AR9331_PORT_MIB_tx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x68)
> +#define AR9331_PORT_MIB_tx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x6c)
> +#define AR9331_PORT_MIB_tx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x70)
> +#define AR9331_PORT_MIB_tx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x74)
> +#define AR9331_PORT_MIB_tx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x78)
> +#define AR9331_PORT_MIB_txmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x7c)
> +#define AR9331_PORT_MIB_txoversize(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x80)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_txbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x84)
> +
> +#define AR9331_PORT_MIB_txcollision(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x8c)
> +#define AR9331_PORT_MIB_txabortcol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x90)
> +#define AR9331_PORT_MIB_txmulticol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x94)
> +#define AR9331_PORT_MIB_txsinglecol(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x98)
> +#define AR9331_PORT_MIB_txexcdefer(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x9c)
> +#define AR9331_PORT_MIB_txdefer(_port) (AR9331_MIB_COUNTER(_port) + 
> 0xa0)
> +#define AR9331_PORT_MIB_txlatecol(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0xa4)
> +
>  /* Phy bypass mode
>   * 
>   * Bit:   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 |
> @@ -154,6 +205,59 @@
>  #define AR9331_SW_MDIO_POLL_SLEEP_US   1
>  #define AR9331_SW_MDIO_POLL_TIMEOUT_US 20
>
> +#define STATS_INTERVAL_JIFFIES (3 * HZ)
> +
> +struct ar9331_sw_stats {
> +   u64 rxbroad;
> +   u64 rxpause;
> +   u64 rxmulti;
> +   u64 rxfcserr;
> +   u64 rxalignerr;
> +   u64 rxrunt;
> +   u64 rxfragment;
> +   u64 rx64byte;
> +   u64 rx128byte;
> +   u64 rx256byte;
> +   u64 rx512byte;
> +   u64 rx1024byte;
> +   u64 rx1518byte;
> +  

Re: [PATCH v4 net-next 2/2] net: dsa: qca: ar9331: export stats64

2020-12-04 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Add stats support for the ar9331 switch.
>
> Signed-off-by: Oleksij Rempel 
> ---
>  drivers/net/dsa/qca/ar9331.c | 247 ++-
>  1 file changed, 246 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c
> index 605d7b675216..4c1a4c448d80 100644
> --- a/drivers/net/dsa/qca/ar9331.c
> +++ b/drivers/net/dsa/qca/ar9331.c
> @@ -101,6 +101,57 @@
>  AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN 
> | \
>  AR9331_SW_PORT_STATUS_SPEED_M)
>
> +/* MIB registers */
> +#define AR9331_MIB_COUNTER(x)  (0x2 + ((x) * 0x100))
> +
> +#define AR9331_PORT_MIB_rxbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x00)
> +#define AR9331_PORT_MIB_rxpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x04)
> +#define AR9331_PORT_MIB_rxmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x08)
> +#define AR9331_PORT_MIB_rxfcserr(_port)
> (AR9331_MIB_COUNTER(_port) + 0x0c)
> +#define AR9331_PORT_MIB_rxalignerr(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x10)
> +#define AR9331_PORT_MIB_rxrunt(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x14)
> +#define AR9331_PORT_MIB_rxfragment(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x18)
> +#define AR9331_PORT_MIB_rx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x1c)
> +#define AR9331_PORT_MIB_rx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x20)
> +#define AR9331_PORT_MIB_rx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x24)
> +#define AR9331_PORT_MIB_rx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x28)
> +#define AR9331_PORT_MIB_rx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x2c)
> +#define AR9331_PORT_MIB_rx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x30)
> +#define AR9331_PORT_MIB_rxmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x34)
> +#define AR9331_PORT_MIB_rxtoolong(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x38)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxgoodbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x3c)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxbadbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x44)
> +
> +#define AR9331_PORT_MIB_rxoverflow(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x4c)
> +#define AR9331_PORT_MIB_filtered(_port)
> (AR9331_MIB_COUNTER(_port) + 0x50)
> +#define AR9331_PORT_MIB_txbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x54)
> +#define AR9331_PORT_MIB_txpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x58)
> +#define AR9331_PORT_MIB_txmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x5c)
> +#define AR9331_PORT_MIB_txunderrun(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x60)
> +#define AR9331_PORT_MIB_tx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x64)
> +#define AR9331_PORT_MIB_tx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x68)
> +#define AR9331_PORT_MIB_tx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x6c)
> +#define AR9331_PORT_MIB_tx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x70)
> +#define AR9331_PORT_MIB_tx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x74)
> +#define AR9331_PORT_MIB_tx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x78)
> +#define AR9331_PORT_MIB_txmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x7c)
> +#define AR9331_PORT_MIB_txoversize(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x80)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_txbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x84)
> +
> +#define AR9331_PORT_MIB_txcollision(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x8c)
> +#define AR9331_PORT_MIB_txabortcol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x90)
> +#define AR9331_PORT_MIB_txmulticol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x94)
> +#define AR9331_PORT_MIB_txsinglecol(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x98)
> +#define AR9331_PORT_MIB_txexcdefer(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x9c)
> +#define AR9331_PORT_MIB_txdefer(_port) (AR9331_MIB_COUNTER(_port) + 
> 0xa0)
> +#define AR9331_PORT_MIB_txlatecol(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0xa4)
> +
>  /* Phy bypass mode
>   * 
>   * Bit:   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 |
> @@ -154,6 +205,59 @@
>  #define AR9331_SW_MDIO_POLL_SLEEP_US   1
>  #define AR9331_SW_MDIO_POLL_TIMEOUT_US 20
>
> +#define STATS_INTERVAL_JIFFIES (3 * HZ)
> +
> +struct ar9331_sw_stats {
> +   u64 rxbroad;
> +   u64 rxpause;
> +   u64 rxmulti;
> +   u64 rxfcserr;
> +   u64 rxalignerr;
> +   u64 rxrunt;
> +   u64 rxfragment;
> +   u64 rx64byte;
> +   u64 rx128byte;
> +   u64 rx256byte;
> +   u64 rx512byte;
> +   u64 rx1024byte;
> +   u64 rx1518byte;
> +  

Re: [PATCH net-next v2 1/3] net: dsa: microchip: add KSZ9477 I2C driver

2019-09-10 Thread George McCollister
Andrew,

On Tue, Sep 10, 2019 at 9:03 AM Andrew Lunn  wrote:
>
> Hi George
>
> > +KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
> > +
> > @@ -294,6 +294,8 @@ static inline void ksz_pwrite32(struct ksz_device *dev, 
> > int port, int offset,
> >  #define KSZ_SPI_OP_RD3
> >  #define KSZ_SPI_OP_WR2
> >
> > +#define swabnot_used(x)  0
>
> > +
> >  #define KSZ_SPI_OP_FLAG_MASK(opcode, swp, regbits, regpad)   \
> >   swab##swp((opcode) << ((regbits) + (regpad)))
>
> There seems to be quite a lot of macro magic here which is not
> obvious. Can this be simplified or made more obvious?

I thought about this for quite some time. To reduce the "macro magic"
the SPI specific parts will need to be removed from the common macro
and arguments for read_flag_mask and write_flag_mask would need to be
added to both KSZ_REGMAP_TABLE and KSZ_REGMAP_TABLE. That would leave
us with two macros that have 7 arguments. Not really an improvement
IMHO. Alternatively we could have different macros for SPI and I2C (or
not use the macros at all and define the i2c regmaps in ksz9477_i2c.c)
at the cost of ~20 lines of duplication. I prefer the "macro magic"
approach, however if you won't let the patch through the way it is
I'll respect your decision, just let me know which of the three
proposed approaches you want to go with.

>
>  Andrew

Cheers,
George


[PATCH net-next v2 3/3] net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON

2019-09-10 Thread George McCollister
Remove the superfluous NET_DSA_TAG_KSZ_COMMON and just use the existing
NET_DSA_TAG_KSZ. Update the description to mention the three switch
families it supports. No functional change.

Signed-off-by: George McCollister 
Reviewed-by: Marek Vasut 
---

Changes since v1:
- Added Reviewed-by.

 net/dsa/Kconfig  | 9 ++---
 net/dsa/Makefile | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 2f69d4b53d46..29e2bd5cc5af 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -73,16 +73,11 @@ config NET_DSA_TAG_MTK
  Say Y or M if you want to enable support for tagging frames for
  Mediatek switches.
 
-config NET_DSA_TAG_KSZ_COMMON
-   tristate
-   default n
-
 config NET_DSA_TAG_KSZ
-   tristate "Tag driver for Microchip 9893 family of switches"
-   select NET_DSA_TAG_KSZ_COMMON
+   tristate "Tag driver for Microchip 8795/9477/9893 families of switches"
help
  Say Y if you want to enable support for tagging frames for the
- Microchip 9893 family of switches.
+ Microchip 8795/9477/9893 families of switches.
 
 config NET_DSA_TAG_QCA
tristate "Tag driver for Qualcomm Atheros QCA8K switches"
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index c342f54715ba..2c6d286f0511 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o
 obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o
-obj-$(CONFIG_NET_DSA_TAG_KSZ_COMMON) += tag_ksz.o
+obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o
 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
 obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
-- 
2.11.0



[PATCH net-next v2 2/3] net: dsa: microchip: add ksz9567 to ksz9477 driver

2019-09-10 Thread George McCollister
Add support for the KSZ9567 7-Port Gigabit Ethernet Switch to the
ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the
ksz9567 is already in the device tree binding documentation.

Signed-off-by: George McCollister 
Reviewed-by: Marek Vasut 
---

Changes since v1:
- Added Reviewed-by.

 drivers/net/dsa/microchip/ksz9477.c | 9 +
 drivers/net/dsa/microchip/ksz9477_i2c.c | 1 +
 drivers/net/dsa/microchip/ksz9477_spi.c | 1 +
 3 files changed, 11 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c 
b/drivers/net/dsa/microchip/ksz9477.c
index 187be42de5f1..50ffc63d6231 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1529,6 +1529,15 @@ static const struct ksz_chip_data ksz9477_switch_chips[] 
= {
.cpu_ports = 0x07,  /* can be configured as cpu port */
.port_cnt = 3,  /* total port count */
},
+   {
+   .chip_id = 0x00956700,
+   .dev_name = "KSZ9567",
+   .num_vlans = 4096,
+   .num_alus = 4096,
+   .num_statics = 16,
+   .cpu_ports = 0x7F,  /* can be configured as cpu port */
+   .port_cnt = 7,  /* total physical port count */
+   },
 };
 
 static int ksz9477_switch_init(struct ksz_device *dev)
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c 
b/drivers/net/dsa/microchip/ksz9477_i2c.c
index 79867cc2474b..0b1e01f0873d 100644
--- a/drivers/net/dsa/microchip/ksz9477_i2c.c
+++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
@@ -77,6 +77,7 @@ MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
 static const struct of_device_id ksz9477_dt_ids[] = {
{ .compatible = "microchip,ksz9477" },
{ .compatible = "microchip,ksz9897" },
+   { .compatible = "microchip,ksz9567" },
{},
 };
 MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
diff --git a/drivers/net/dsa/microchip/ksz9477_spi.c 
b/drivers/net/dsa/microchip/ksz9477_spi.c
index 2e402e4d866f..f4198d6f72be 100644
--- a/drivers/net/dsa/microchip/ksz9477_spi.c
+++ b/drivers/net/dsa/microchip/ksz9477_spi.c
@@ -81,6 +81,7 @@ static const struct of_device_id ksz9477_dt_ids[] = {
{ .compatible = "microchip,ksz9893" },
{ .compatible = "microchip,ksz9563" },
{ .compatible = "microchip,ksz8563" },
+   { .compatible = "microchip,ksz9567" },
{},
 };
 MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
-- 
2.11.0



[PATCH net-next v2 1/3] net: dsa: microchip: add KSZ9477 I2C driver

2019-09-10 Thread George McCollister
From: Tristram Ha 

Add KSZ9477 I2C driver support.  The code ksz9477.c and ksz_common.c are
used together to generate the I2C driver.

Signed-off-by: Tristram Ha 
[george.mccollis...@gmail.com: bring up to date, use ksz_common regmap macros]
Signed-off-by: George McCollister 
---

Changes since v1:
- Adjust order of includes so they are in alphabetical order.

 drivers/net/dsa/microchip/Kconfig   |   7 +++
 drivers/net/dsa/microchip/Makefile  |   1 +
 drivers/net/dsa/microchip/ksz9477_i2c.c | 100 
 drivers/net/dsa/microchip/ksz_common.h  |   2 +
 4 files changed, 110 insertions(+)
 create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c

diff --git a/drivers/net/dsa/microchip/Kconfig 
b/drivers/net/dsa/microchip/Kconfig
index e1c23d1e91e6..1d7870c6df3c 100644
--- a/drivers/net/dsa/microchip/Kconfig
+++ b/drivers/net/dsa/microchip/Kconfig
@@ -9,6 +9,13 @@ menuconfig NET_DSA_MICROCHIP_KSZ9477
help
  This driver adds support for Microchip KSZ9477 switch chips.
 
+config NET_DSA_MICROCHIP_KSZ9477_I2C
+   tristate "KSZ9477 series I2C connected switch driver"
+   depends on NET_DSA_MICROCHIP_KSZ9477 && I2C
+   select REGMAP_I2C
+   help
+ Select to enable support for registering switches configured through 
I2C.
+
 config NET_DSA_MICROCHIP_KSZ9477_SPI
tristate "KSZ9477 series SPI connected switch driver"
depends on NET_DSA_MICROCHIP_KSZ9477 && SPI
diff --git a/drivers/net/dsa/microchip/Makefile 
b/drivers/net/dsa/microchip/Makefile
index e3d799b95d7d..929caa81e782 100644
--- a/drivers/net/dsa/microchip/Makefile
+++ b/drivers/net/dsa/microchip/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_common.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477)+= ksz9477.o
+obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C)+= ksz9477_i2c.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI)+= ksz9477_spi.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795)+= ksz8795.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795_SPI)+= ksz8795_spi.o
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c 
b/drivers/net/dsa/microchip/ksz9477_i2c.c
new file mode 100644
index ..79867cc2474b
--- /dev/null
+++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Microchip KSZ9477 series register access through I2C
+ *
+ * Copyright (C) 2018-2019 Microchip Technology Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "ksz_common.h"
+
+KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
+
+static int ksz9477_i2c_probe(struct i2c_client *i2c,
+const struct i2c_device_id *i2c_id)
+{
+   struct ksz_device *dev;
+   int i, ret;
+
+   dev = ksz_switch_alloc(>dev, i2c);
+   if (!dev)
+   return -ENOMEM;
+
+   for (i = 0; i < ARRAY_SIZE(ksz9477_regmap_config); i++) {
+   dev->regmap[i] = devm_regmap_init_i2c(i2c,
+   _regmap_config[i]);
+   if (IS_ERR(dev->regmap[i])) {
+   ret = PTR_ERR(dev->regmap[i]);
+   dev_err(>dev,
+   "Failed to initialize regmap%i: %d\n",
+   ksz9477_regmap_config[i].val_bits, ret);
+   return ret;
+   }
+   }
+
+   if (i2c->dev.platform_data)
+   dev->pdata = i2c->dev.platform_data;
+
+   ret = ksz9477_switch_register(dev);
+
+   /* Main DSA driver may not be started yet. */
+   if (ret)
+   return ret;
+
+   i2c_set_clientdata(i2c, dev);
+
+   return 0;
+}
+
+static int ksz9477_i2c_remove(struct i2c_client *i2c)
+{
+   struct ksz_device *dev = i2c_get_clientdata(i2c);
+
+   ksz_switch_remove(dev);
+
+   return 0;
+}
+
+static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
+{
+   struct ksz_device *dev = i2c_get_clientdata(i2c);
+
+   if (dev && dev->dev_ops->shutdown)
+   dev->dev_ops->shutdown(dev);
+}
+
+static const struct i2c_device_id ksz9477_i2c_id[] = {
+   { "ksz9477-switch", 0 },
+   {},
+};
+
+MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
+
+static const struct of_device_id ksz9477_dt_ids[] = {
+   { .compatible = "microchip,ksz9477" },
+   { .compatible = "microchip,ksz9897" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
+
+static struct i2c_driver ksz9477_i2c_driver = {
+   .driver = {
+   .name   = "ksz9477-switch",
+   .owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(ksz9477_dt_ids),
+   },
+   .probe  = ksz9477_i2c_probe,
+   .remove = ksz9477_i2c_remove,
+   .shutdown = ksz9477_i2c_shutdown,
+  

[PATCH net-next v2 0/3] add ksz9567 with I2C support to ksz9477 driver

2019-09-10 Thread George McCollister
Resurrect KSZ9477 I2C driver support patch originally sent to the list
by Tristram Ha and resolve outstanding issues. It now works as similarly to
the ksz9477 SPI driver as possible, using the same regmap macros.

Add support for ksz9567 to the ksz9477 driver (tested on a board with
ksz9567 connected via I2C).

Remove NET_DSA_TAG_KSZ_COMMON since it's not needed.

Changes since v1:
Put ksz9477_i2c.c includes in alphabetical order.
Added Reviewed-Bys.

George McCollister (2):
  net: dsa: microchip: add ksz9567 to ksz9477 driver
  net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON

Tristram Ha (1):
  net: dsa: microchip: add KSZ9477 I2C driver

 drivers/net/dsa/microchip/Kconfig   |   7 +++
 drivers/net/dsa/microchip/Makefile  |   1 +
 drivers/net/dsa/microchip/ksz9477.c |   9 +++
 drivers/net/dsa/microchip/ksz9477_i2c.c | 101 
 drivers/net/dsa/microchip/ksz9477_spi.c |   1 +
 drivers/net/dsa/microchip/ksz_common.h  |   2 +
 net/dsa/Kconfig |   9 +--
 net/dsa/Makefile|   2 +-
 8 files changed, 124 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c

-- 
2.11.0



Re: [PATCH net-next 2/3] net: dsa: microchip: add ksz9567 to ksz9477 driver

2019-09-09 Thread George McCollister
On Fri, Sep 6, 2019 at 4:42 PM Marek Vasut  wrote:
>
> On 9/6/19 11:30 PM, George McCollister wrote:
> > Add support for the KSZ9567 7-Port Gigabit Ethernet Switch to the
> > ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the
> > ksz9567 is already in the device tree binding documentation.
> >
> > Signed-off-by: George McCollister 
> > ---
> >  drivers/net/dsa/microchip/ksz9477.c | 9 +
> >  drivers/net/dsa/microchip/ksz9477_i2c.c | 1 +
> >  drivers/net/dsa/microchip/ksz9477_spi.c | 1 +
> >  3 files changed, 11 insertions(+)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz9477.c 
> > b/drivers/net/dsa/microchip/ksz9477.c
> > index 187be42de5f1..50ffc63d6231 100644
> > --- a/drivers/net/dsa/microchip/ksz9477.c
> > +++ b/drivers/net/dsa/microchip/ksz9477.c
> > @@ -1529,6 +1529,15 @@ static const struct ksz_chip_data 
> > ksz9477_switch_chips[] = {
> >   .cpu_ports = 0x07,  /* can be configured as cpu port */
> >   .port_cnt = 3,  /* total port count */
> >   },
> > + {
> > + .chip_id = 0x00956700,
> > + .dev_name = "KSZ9567",
> > + .num_vlans = 4096,
> > + .num_alus = 4096,
> > + .num_statics = 16,
> > + .cpu_ports = 0x7F,  /* can be configured as cpu port */
> > + .port_cnt = 7,  /* total physical port count */
>
> I might be wrong, and this is just an idea for future improvement, but
> is .cpu_ports = GEN_MASK(.port_cnt, 0) always ?

GENMASK, not GEN_MASK. And I think it would be .cpu_ports =
GENMASK(.port_cnt - 1, 0).
I'm not sure if it would always be that. TBH I'm not sure if 0x7F is
even correct. For instance if a port has a PHY should it be excluded
from this mask or only if it doesn't support tail tagging? Maybe
someone would hook the CPU port up with a PHY instead of
RGMII/MII/RMII but it seems quite an odd thing to do.

On the KSZ9567R datasheet it shows 1-7 for this so if actually correct
I believe all ports support tail tagging but maybe some other variants
don't:
Port Operation Control 0 Register
Port N: 1-7
Bit 2 - Tail Tag Enable
When tail tagging is enabled for a port, it designates that port to be
the “host” or “CPU” port. Do not enable tail tagging for more than one
port.

My inclination is to leave it as is until a more compelling reason for
changing it arises.

>
> > + },
> >  };
> >
> >  static int ksz9477_switch_init(struct ksz_device *dev)
> > diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c 
> > b/drivers/net/dsa/microchip/ksz9477_i2c.c
> > index 85fd0fb43941..c1548a43b60d 100644
> > --- a/drivers/net/dsa/microchip/ksz9477_i2c.c
> > +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
> > @@ -77,6 +77,7 @@ MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
> >  static const struct of_device_id ksz9477_dt_ids[] = {
> >   { .compatible = "microchip,ksz9477" },
> >   { .compatible = "microchip,ksz9897" },
> > + { .compatible = "microchip,ksz9567" },
> >   {},
> >  };
> >  MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
> > diff --git a/drivers/net/dsa/microchip/ksz9477_spi.c 
> > b/drivers/net/dsa/microchip/ksz9477_spi.c
> > index 2e402e4d866f..f4198d6f72be 100644
> > --- a/drivers/net/dsa/microchip/ksz9477_spi.c
> > +++ b/drivers/net/dsa/microchip/ksz9477_spi.c
> > @@ -81,6 +81,7 @@ static const struct of_device_id ksz9477_dt_ids[] = {
> >   { .compatible = "microchip,ksz9893" },
> >   { .compatible = "microchip,ksz9563" },
> >   { .compatible = "microchip,ksz8563" },
> > + { .compatible = "microchip,ksz9567" },
> >   {},
> >  };
> >  MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
> >
>
> Reviewed-by: Marek Vasut 

Thanks.

>
> --
> Best regards,
> Marek Vasut


Re: [PATCH net-next 1/3] net: dsa: microchip: add KSZ9477 I2C driver

2019-09-09 Thread George McCollister
On Fri, Sep 6, 2019 at 4:42 PM Marek Vasut  wrote:
>
> On 9/6/19 11:30 PM, George McCollister wrote:
>
> [...]
>
> > --- /dev/null
> > +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
> > @@ -0,0 +1,100 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Microchip KSZ9477 series register access through I2C
> > + *
> > + * Copyright (C) 2018-2019 Microchip Technology Inc.
>
> Doesn't the copyright need update ?

I figured it wasn't necessary since you didn't update the copyright in
ksz9477_spi.c when you converted it to use regmap and made other
changes.
You're suggesting I add my copyright below this one, correct?

>
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
>
> Please keep the headers sorted.

Ack. Moving linux/i2c.h before linux/kernel.h in v2.

>
> > +#include "ksz_common.h"
> > +
> > +KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
> > +
>
> The rest looks good.
>
> [...]
>
> --
> Best regards,
> Marek Vasut


[PATCH net-next 3/3] net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON

2019-09-06 Thread George McCollister
Remove the superfluous NET_DSA_TAG_KSZ_COMMON and just use the existing
NET_DSA_TAG_KSZ. Update the description to mention the three switch
families it supports. No functional change.

Signed-off-by: George McCollister 
---
 net/dsa/Kconfig  | 9 ++---
 net/dsa/Makefile | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 2f69d4b53d46..29e2bd5cc5af 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -73,16 +73,11 @@ config NET_DSA_TAG_MTK
  Say Y or M if you want to enable support for tagging frames for
  Mediatek switches.
 
-config NET_DSA_TAG_KSZ_COMMON
-   tristate
-   default n
-
 config NET_DSA_TAG_KSZ
-   tristate "Tag driver for Microchip 9893 family of switches"
-   select NET_DSA_TAG_KSZ_COMMON
+   tristate "Tag driver for Microchip 8795/9477/9893 families of switches"
help
  Say Y if you want to enable support for tagging frames for the
- Microchip 9893 family of switches.
+ Microchip 8795/9477/9893 families of switches.
 
 config NET_DSA_TAG_QCA
tristate "Tag driver for Qualcomm Atheros QCA8K switches"
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index c342f54715ba..2c6d286f0511 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -9,7 +9,7 @@ obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o
 obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o
-obj-$(CONFIG_NET_DSA_TAG_KSZ_COMMON) += tag_ksz.o
+obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o
 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
 obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
-- 
2.11.0



[PATCH net-next 1/3] net: dsa: microchip: add KSZ9477 I2C driver

2019-09-06 Thread George McCollister
From: Tristram Ha 

Add KSZ9477 I2C driver support.  The code ksz9477.c and ksz_common.c are
used together to generate the I2C driver.

Signed-off-by: Tristram Ha 
[george.mccollis...@gmail.com: bring up to date, use ksz_common regmap macros]
Signed-off-by: George McCollister 
---
 drivers/net/dsa/microchip/Kconfig   |   7 +++
 drivers/net/dsa/microchip/Makefile  |   1 +
 drivers/net/dsa/microchip/ksz9477_i2c.c | 100 
 drivers/net/dsa/microchip/ksz_common.h  |   2 +
 4 files changed, 110 insertions(+)
 create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c

diff --git a/drivers/net/dsa/microchip/Kconfig 
b/drivers/net/dsa/microchip/Kconfig
index e1c23d1e91e6..1d7870c6df3c 100644
--- a/drivers/net/dsa/microchip/Kconfig
+++ b/drivers/net/dsa/microchip/Kconfig
@@ -9,6 +9,13 @@ menuconfig NET_DSA_MICROCHIP_KSZ9477
help
  This driver adds support for Microchip KSZ9477 switch chips.
 
+config NET_DSA_MICROCHIP_KSZ9477_I2C
+   tristate "KSZ9477 series I2C connected switch driver"
+   depends on NET_DSA_MICROCHIP_KSZ9477 && I2C
+   select REGMAP_I2C
+   help
+ Select to enable support for registering switches configured through 
I2C.
+
 config NET_DSA_MICROCHIP_KSZ9477_SPI
tristate "KSZ9477 series SPI connected switch driver"
depends on NET_DSA_MICROCHIP_KSZ9477 && SPI
diff --git a/drivers/net/dsa/microchip/Makefile 
b/drivers/net/dsa/microchip/Makefile
index e3d799b95d7d..929caa81e782 100644
--- a/drivers/net/dsa/microchip/Makefile
+++ b/drivers/net/dsa/microchip/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_common.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477)+= ksz9477.o
+obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C)+= ksz9477_i2c.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI)+= ksz9477_spi.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795)+= ksz8795.o
 obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795_SPI)+= ksz8795_spi.o
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c 
b/drivers/net/dsa/microchip/ksz9477_i2c.c
new file mode 100644
index ..85fd0fb43941
--- /dev/null
+++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Microchip KSZ9477 series register access through I2C
+ *
+ * Copyright (C) 2018-2019 Microchip Technology Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "ksz_common.h"
+
+KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
+
+static int ksz9477_i2c_probe(struct i2c_client *i2c,
+const struct i2c_device_id *i2c_id)
+{
+   struct ksz_device *dev;
+   int i, ret;
+
+   dev = ksz_switch_alloc(>dev, i2c);
+   if (!dev)
+   return -ENOMEM;
+
+   for (i = 0; i < ARRAY_SIZE(ksz9477_regmap_config); i++) {
+   dev->regmap[i] = devm_regmap_init_i2c(i2c,
+   _regmap_config[i]);
+   if (IS_ERR(dev->regmap[i])) {
+   ret = PTR_ERR(dev->regmap[i]);
+   dev_err(>dev,
+   "Failed to initialize regmap%i: %d\n",
+   ksz9477_regmap_config[i].val_bits, ret);
+   return ret;
+   }
+   }
+
+   if (i2c->dev.platform_data)
+   dev->pdata = i2c->dev.platform_data;
+
+   ret = ksz9477_switch_register(dev);
+
+   /* Main DSA driver may not be started yet. */
+   if (ret)
+   return ret;
+
+   i2c_set_clientdata(i2c, dev);
+
+   return 0;
+}
+
+static int ksz9477_i2c_remove(struct i2c_client *i2c)
+{
+   struct ksz_device *dev = i2c_get_clientdata(i2c);
+
+   ksz_switch_remove(dev);
+
+   return 0;
+}
+
+static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
+{
+   struct ksz_device *dev = i2c_get_clientdata(i2c);
+
+   if (dev && dev->dev_ops->shutdown)
+   dev->dev_ops->shutdown(dev);
+}
+
+static const struct i2c_device_id ksz9477_i2c_id[] = {
+   { "ksz9477-switch", 0 },
+   {},
+};
+
+MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
+
+static const struct of_device_id ksz9477_dt_ids[] = {
+   { .compatible = "microchip,ksz9477" },
+   { .compatible = "microchip,ksz9897" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
+
+static struct i2c_driver ksz9477_i2c_driver = {
+   .driver = {
+   .name   = "ksz9477-switch",
+   .owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(ksz9477_dt_ids),
+   },
+   .probe  = ksz9477_i2c_probe,
+   .remove = ksz9477_i2c_remove,
+   .shutdown = ksz9477_i2c_shutdown,
+   .id_table = ksz9477_i2c_id,
+};
+
+module_i2c_driver(ksz9477_i2c_driver);
+
+MODULE_AU

[PATCH net-next 2/3] net: dsa: microchip: add ksz9567 to ksz9477 driver

2019-09-06 Thread George McCollister
Add support for the KSZ9567 7-Port Gigabit Ethernet Switch to the
ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the
ksz9567 is already in the device tree binding documentation.

Signed-off-by: George McCollister 
---
 drivers/net/dsa/microchip/ksz9477.c | 9 +
 drivers/net/dsa/microchip/ksz9477_i2c.c | 1 +
 drivers/net/dsa/microchip/ksz9477_spi.c | 1 +
 3 files changed, 11 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz9477.c 
b/drivers/net/dsa/microchip/ksz9477.c
index 187be42de5f1..50ffc63d6231 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1529,6 +1529,15 @@ static const struct ksz_chip_data ksz9477_switch_chips[] 
= {
.cpu_ports = 0x07,  /* can be configured as cpu port */
.port_cnt = 3,  /* total port count */
},
+   {
+   .chip_id = 0x00956700,
+   .dev_name = "KSZ9567",
+   .num_vlans = 4096,
+   .num_alus = 4096,
+   .num_statics = 16,
+   .cpu_ports = 0x7F,  /* can be configured as cpu port */
+   .port_cnt = 7,  /* total physical port count */
+   },
 };
 
 static int ksz9477_switch_init(struct ksz_device *dev)
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c 
b/drivers/net/dsa/microchip/ksz9477_i2c.c
index 85fd0fb43941..c1548a43b60d 100644
--- a/drivers/net/dsa/microchip/ksz9477_i2c.c
+++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
@@ -77,6 +77,7 @@ MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
 static const struct of_device_id ksz9477_dt_ids[] = {
{ .compatible = "microchip,ksz9477" },
{ .compatible = "microchip,ksz9897" },
+   { .compatible = "microchip,ksz9567" },
{},
 };
 MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
diff --git a/drivers/net/dsa/microchip/ksz9477_spi.c 
b/drivers/net/dsa/microchip/ksz9477_spi.c
index 2e402e4d866f..f4198d6f72be 100644
--- a/drivers/net/dsa/microchip/ksz9477_spi.c
+++ b/drivers/net/dsa/microchip/ksz9477_spi.c
@@ -81,6 +81,7 @@ static const struct of_device_id ksz9477_dt_ids[] = {
{ .compatible = "microchip,ksz9893" },
{ .compatible = "microchip,ksz9563" },
{ .compatible = "microchip,ksz8563" },
+   { .compatible = "microchip,ksz9567" },
{},
 };
 MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
-- 
2.11.0



[PATCH net-next 0/3] add ksz9567 with I2C support to ksz9477 driver

2019-09-06 Thread George McCollister
Resurrect KSZ9477 I2C driver support patch originally sent to the list
by Tristram Ha and resolve outstanding issues. It now works as similarly to
the ksz9477 SPI driver as possible, using the same regmap macros.

Add support for ksz9567 to the ksz9477 driver (tested on a board with
ksz9567 connected via I2C).

Remove NET_DSA_TAG_KSZ_COMMON since it's not needed.

George McCollister (2):
  net: dsa: microchip: add ksz9567 to ksz9477 driver
  net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON

Tristram Ha (1):
  net: dsa: microchip: add KSZ9477 I2C driver

 drivers/net/dsa/microchip/Kconfig   |   7 +++
 drivers/net/dsa/microchip/Makefile  |   1 +
 drivers/net/dsa/microchip/ksz9477.c |   9 +++
 drivers/net/dsa/microchip/ksz9477_i2c.c | 101 
 drivers/net/dsa/microchip/ksz9477_spi.c |   1 +
 drivers/net/dsa/microchip/ksz_common.h  |   2 +
 net/dsa/Kconfig |   9 +--
 net/dsa/Makefile|   2 +-
 8 files changed, 124 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c

-- 
2.11.0



[PATCH] net: dsa: microchip: fill regmap_config name

2019-08-29 Thread George McCollister
Use the register value width as the regmap_config name to prevent the
following error when the second and third regmap_configs are
initialized.
 "debugfs: Directory '${bus-id}' with parent 'regmap' already present!"

Signed-off-by: George McCollister 
---
 drivers/net/dsa/microchip/ksz_common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/dsa/microchip/ksz_common.h 
b/drivers/net/dsa/microchip/ksz_common.h
index ee7096d8af07..72ec250b9540 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -128,6 +128,7 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int 
port, int offset,
 
 #define KSZ_REGMAP_ENTRY(width, swp, regbits, regpad, regalign)
\
{   \
+   .name = #width, \
.val_bits = (width),\
.reg_stride = (width) / 8,  \
.reg_bits = (regbits) + (regalign), \
-- 
2.11.0



[PATCH] USB: serial: ftdi_sio: add additional NovaTech products

2019-03-05 Thread George McCollister
Add PIDs for the NovaTech OrionLX+ and Orion I/O so they can be
automatically detected.

Signed-off-by: George McCollister 
---
 drivers/usb/serial/ftdi_sio.c | 2 ++
 drivers/usb/serial/ftdi_sio_ids.h | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 77ef4c481f3c..4e0da23a0210 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -609,6 +609,8 @@ static const struct usb_device_id id_table_combined[] = {
.driver_info = (kernel_ulong_t)_jtag_quirk },
{ USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID),
.driver_info = (kernel_ulong_t)_jtag_quirk },
+   { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLX_PLUS_PID) },
+   { USB_DEVICE(FTDI_VID, FTDI_NT_ORION_IO_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
b/drivers/usb/serial/ftdi_sio_ids.h
index 975d02666c5a..cb0adba174a7 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -567,7 +567,9 @@
 /*
  * NovaTech product ids (FTDI_VID)
  */
-#define FTDI_NT_ORIONLXM_PID   0x7c90  /* OrionLXm Substation Automation 
Platform */
+#define FTDI_NT_ORIONLXM_PID   0x7c90  /* OrionLXm Substation 
Automation Platform */
+#define FTDI_NT_ORIONLX_PLUS_PID   0x7c91  /* OrionLX+ Substation 
Automation Platform */
+#define FTDI_NT_ORION_IO_PID   0x7c92  /* Orion I/O */
 
 /*
  * Synapse Wireless product ids (FTDI_VID)
-- 
2.20.1



[PATCH] regulator: pfuze100-regulator: add coin support

2017-03-09 Thread George McCollister
Add support for PF0200 coin cell/super capacitor charger which works as
a current limited voltage source via the LICELL pin. When VIN goes below
a certain threshold LICELL is used to provide power for VSNVS which is
usually used to hold up secure non-volatile storage and the real-time
clock on the SoC.

Signed-off-by: George McCollister <george.mccollis...@gmail.com>
---
 .../devicetree/bindings/regulator/pfuze100.txt |  8 +++-
 drivers/regulator/pfuze100-regulator.c | 24 ++
 include/linux/regulator/pfuze100.h |  1 +
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/regulator/pfuze100.txt 
b/Documentation/devicetree/bindings/regulator/pfuze100.txt
index 9b40db88f637..444c47831a40 100644
--- a/Documentation/devicetree/bindings/regulator/pfuze100.txt
+++ b/Documentation/devicetree/bindings/regulator/pfuze100.txt
@@ -13,7 +13,7 @@ Required child node:
   --PFUZE100
   sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
   --PFUZE200
-  sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6
+  sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6,coin
   --PFUZE3000
   sw1a,sw1b,sw2,sw3,swbst,vsnvs,vrefddr,vldo1,vldo2,vccsd,v33,vldo3,vldo4
 
@@ -205,6 +205,12 @@ Example 2: PFUZE200
regulator-max-microvolt = <330>;
regulator-always-on;
};
+
+   coin_reg: coin {
+   regulator-min-microvolt = <250>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
};
};
 
diff --git a/drivers/regulator/pfuze100-regulator.c 
b/drivers/regulator/pfuze100-regulator.c
index e1938ffc..63922a2167e5 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -40,6 +40,7 @@
 #define PFUZE100_REVID 0x3
 #define PFUZE100_FABID 0x4
 
+#define PFUZE100_COINVOL   0x1a
 #define PFUZE100_SW1ABVOL  0x20
 #define PFUZE100_SW1CVOL   0x2e
 #define PFUZE100_SW2VOL0x35
@@ -81,6 +82,10 @@ static const int pfuze100_vsnvs[] = {
100, 110, 120, 130, 150, 180, 300,
 };
 
+static const int pfuze100_coin[] = {
+   250, 270, 280, 290, 300, 310, 320, 330,
+};
+
 static const int pfuze3000_sw2lo[] = {
150, 155, 160, 165, 170, 175, 180, 185,
 };
@@ -230,6 +235,23 @@ static const struct regulator_ops 
pfuze100_swb_regulator_ops = {
.stby_mask = 0x20,  \
}
 
+#define PFUZE100_COIN_REG(_chip, _name, base, mask, voltages)  \
+   [_chip ## _ ##  _name] = {  \
+   .desc = {   \
+   .name = #_name, \
+   .n_voltages = ARRAY_SIZE(voltages), \
+   .ops = _swb_regulator_ops, \
+   .type = REGULATOR_VOLTAGE,  \
+   .id = _chip ## _ ## _name,  \
+   .owner = THIS_MODULE,   \
+   .volt_table = voltages, \
+   .vsel_reg = (base), \
+   .vsel_mask = (mask),\
+   .enable_reg = (base),   \
+   .enable_mask = 0x8, \
+   },  \
+   }
+
 #define PFUZE3000_VCC_REG(_chip, _name, base, min, max, step)  {   \
.desc = {   \
.name = #_name, \
@@ -317,6 +339,7 @@ static struct pfuze_regulator pfuze200_regulators[] = {
PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 180, 330, 
10),
PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 180, 330, 
10),
PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 180, 330, 
10),
+   PFUZE100_COIN_REG(PFUZE200, COIN, PFUZE100_COINVOL, 0x7, pfuze100_coin),
 };
 
 static struct pfuze_regulator pfuze3000_regulators[] = {
@@ -371,6 +394,7 @@ static struct of_regulator_match pfuze200_matches[] = {
{ .name = "vgen4",  },
{ .name = "vgen5",  },
{ .name = "vgen6",  },
+   { .name = "coin",   },
 };
 
 /* PFUZE3000 */
diff --git a/include/linux/regulator/pfuze100.h 
b/include/linux/regulator/pfuze100.h
index 70c6c66c5bcf..e0ccf46f66cf 100644
--- a/include/linux/regulator/pfuze100.h
+++ b/include/linux/regulator/pfuze100.h
@@ -48,6 +48,7 @@
 #define PFUZE200_VGEN4 10
 #define PFUZE200_VGEN5 11
 #define PFUZE200_VGEN6 12
+#define PFUZE200_COIN  13
 
 #define PFUZE3000_SW1A 0
 #define PFUZE3000_SW1B 1
-- 
2.11.0



[PATCH] regulator: pfuze100-regulator: add coin support

2017-03-09 Thread George McCollister
Add support for PF0200 coin cell/super capacitor charger which works as
a current limited voltage source via the LICELL pin. When VIN goes below
a certain threshold LICELL is used to provide power for VSNVS which is
usually used to hold up secure non-volatile storage and the real-time
clock on the SoC.

Signed-off-by: George McCollister 
---
 .../devicetree/bindings/regulator/pfuze100.txt |  8 +++-
 drivers/regulator/pfuze100-regulator.c | 24 ++
 include/linux/regulator/pfuze100.h |  1 +
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/regulator/pfuze100.txt 
b/Documentation/devicetree/bindings/regulator/pfuze100.txt
index 9b40db88f637..444c47831a40 100644
--- a/Documentation/devicetree/bindings/regulator/pfuze100.txt
+++ b/Documentation/devicetree/bindings/regulator/pfuze100.txt
@@ -13,7 +13,7 @@ Required child node:
   --PFUZE100
   sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
   --PFUZE200
-  sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6
+  sw1ab,sw2,sw3a,sw3b,swbst,vsnvs,vrefddr,vgen1~vgen6,coin
   --PFUZE3000
   sw1a,sw1b,sw2,sw3,swbst,vsnvs,vrefddr,vldo1,vldo2,vccsd,v33,vldo3,vldo4
 
@@ -205,6 +205,12 @@ Example 2: PFUZE200
regulator-max-microvolt = <330>;
regulator-always-on;
};
+
+   coin_reg: coin {
+   regulator-min-microvolt = <250>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
};
};
 
diff --git a/drivers/regulator/pfuze100-regulator.c 
b/drivers/regulator/pfuze100-regulator.c
index e1938ffc..63922a2167e5 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -40,6 +40,7 @@
 #define PFUZE100_REVID 0x3
 #define PFUZE100_FABID 0x4
 
+#define PFUZE100_COINVOL   0x1a
 #define PFUZE100_SW1ABVOL  0x20
 #define PFUZE100_SW1CVOL   0x2e
 #define PFUZE100_SW2VOL0x35
@@ -81,6 +82,10 @@ static const int pfuze100_vsnvs[] = {
100, 110, 120, 130, 150, 180, 300,
 };
 
+static const int pfuze100_coin[] = {
+   250, 270, 280, 290, 300, 310, 320, 330,
+};
+
 static const int pfuze3000_sw2lo[] = {
150, 155, 160, 165, 170, 175, 180, 185,
 };
@@ -230,6 +235,23 @@ static const struct regulator_ops 
pfuze100_swb_regulator_ops = {
.stby_mask = 0x20,  \
}
 
+#define PFUZE100_COIN_REG(_chip, _name, base, mask, voltages)  \
+   [_chip ## _ ##  _name] = {  \
+   .desc = {   \
+   .name = #_name, \
+   .n_voltages = ARRAY_SIZE(voltages), \
+   .ops = _swb_regulator_ops, \
+   .type = REGULATOR_VOLTAGE,  \
+   .id = _chip ## _ ## _name,  \
+   .owner = THIS_MODULE,   \
+   .volt_table = voltages, \
+   .vsel_reg = (base), \
+   .vsel_mask = (mask),\
+   .enable_reg = (base),   \
+   .enable_mask = 0x8, \
+   },  \
+   }
+
 #define PFUZE3000_VCC_REG(_chip, _name, base, min, max, step)  {   \
.desc = {   \
.name = #_name, \
@@ -317,6 +339,7 @@ static struct pfuze_regulator pfuze200_regulators[] = {
PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 180, 330, 
10),
PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 180, 330, 
10),
PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 180, 330, 
10),
+   PFUZE100_COIN_REG(PFUZE200, COIN, PFUZE100_COINVOL, 0x7, pfuze100_coin),
 };
 
 static struct pfuze_regulator pfuze3000_regulators[] = {
@@ -371,6 +394,7 @@ static struct of_regulator_match pfuze200_matches[] = {
{ .name = "vgen4",  },
{ .name = "vgen5",  },
{ .name = "vgen6",  },
+   { .name = "coin",   },
 };
 
 /* PFUZE3000 */
diff --git a/include/linux/regulator/pfuze100.h 
b/include/linux/regulator/pfuze100.h
index 70c6c66c5bcf..e0ccf46f66cf 100644
--- a/include/linux/regulator/pfuze100.h
+++ b/include/linux/regulator/pfuze100.h
@@ -48,6 +48,7 @@
 #define PFUZE200_VGEN4 10
 #define PFUZE200_VGEN5 11
 #define PFUZE200_VGEN6 12
+#define PFUZE200_COIN  13
 
 #define PFUZE3000_SW1A 0
 #define PFUZE3000_SW1B 1
-- 
2.11.0



Re: [PATCH] ACPI / PNP: Reserve ACPI resources at the fs_initcall_sync stage

2015-09-16 Thread George McCollister
Unfortunately I just got around to trying linux 4.1.6 (which contains
this commit) on the Versalogic Tiger (VL-EPM-24)
http://www.versalogic.com/tiger and this commit breaks it, seems to be
back to the old behavior reported here:

http://marc.info/?t=14309238462=1=2

Before reversing the commit it shows:
pci :00:1c.0: BAR 13: assigned [io  0x2000-0x2fff]

After reversing the commit it shows:
pci :00:1c.0: BAR 13: assigned [io  0x3000-0x3fff]

I don't have a solution to propose at this point and haven't tried the
latest upstream so I'll just be building with this commit reversed
(which solves the problem) until I have a chance to look into this
further.

Regards,
George McCollister

On Fri, Jul 3, 2015 at 8:09 PM, Rafael J. Wysocki  wrote:
> From: Rafael J. Wysocki 
>
> This effectively reverts the following three commits:
>
>  7bc10388ccdd ACPI / resources: free memory on error in add_region_before()
>  0f1b414d1907 ACPI / PNP: Avoid conflicting resource reservations
>  b9a5e5e18fbf ACPI / init: Fix the ordering of acpi_reserve_resources()
>
> (commit b9a5e5e18fbf introduced regressions some of which, but not
> all, were addressed by commit 0f1b414d1907 and commit 7bc10388ccdd
> was a fixup on top of the latter) and causes ACPI fixed hardware
> resources to be reserved at the fs_initcall_sync stage of system
> initialization.
>
> The story is as follows.  First, a boot regression was reported due
> to an apparent resource reservation ordering change after a commit
> that shouldn't lead to such changes.  Investigation led to the
> conclusion that the problem happened because acpi_reserve_resources()
> was executed at the device_initcall() stage of system initialization
> which wasn't strictly ordered with respect to driver initialization
> (and with respect to the initialization of the pcieport driver in
> particular), so a random change causing the device initcalls to be
> run in a different order might break things.
>
> The response to that was to attempt to run acpi_reserve_resources()
> as soon as we knew that ACPI would be in use (commit b9a5e5e18fbf).
> However, that turned out to be too early, because it caused resource
> reservations made by the PNP system driver to fail on at least one
> system and that failure was addressed by commit 0f1b414d1907.
>
> That fix still turned out to be insufficient, though, because
> calling acpi_reserve_resources() before the fs_initcall stage of
> system initialization caused a boot regression to happen on the
> eCAFE EC-800-H20G/S netbook.  That meant that we only could call
> acpi_reserve_resources() at the fs_initcall initialization stage
> or later, but then we might just as well call it after the PNP
> initalization in which case commit 0f1b414d1907 wouldn't be
> necessary any more.
>
> For this reason, the changes made by commit 0f1b414d1907 are reverted
> (along with a memory leak fixup on top of that commit), the changes
> made by commit b9a5e5e18fbf that went too far are reverted too and
> acpi_reserve_resources() is changed into fs_initcall_sync, which
> will cause it to be executed after the PNP subsystem initialization
> (which is an fs_initcall) and before device initcalls (including
> the pcieport driver initialization) which should avoid the initial
> issue.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=100581
> Link: http://marc.info/?t=14309238462=1=2
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=99831
> Link: http://marc.info/?t=14338940261=1=2
> Fixes: b9a5e5e18fbf "ACPI / init: Fix the ordering of 
> acpi_reserve_resources()"
> Reported-by: Roland Dreier 
> Reported-by-and-tested-by: 
> Signed-off-by: Rafael J. Wysocki 
> ---
>  drivers/acpi/osl.c  |   12 ++-
>  drivers/acpi/resource.c |  162 
> 
>  drivers/pnp/system.c|   35 ++
>  include/linux/acpi.h|   10 --
>  4 files changed, 18 insertions(+), 201 deletions(-)
>
> Index: linux-pm/drivers/acpi/resource.c
> ===
> --- linux-pm.orig/drivers/acpi/resource.c
> +++ linux-pm/drivers/acpi/resource.c
> @@ -26,7 +26,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>
>  #ifdef CONFIG_X86
> @@ -622,164 +621,3 @@ int acpi_dev_filter_resource_type(struct
> return (type & types) ? 0 : 1;
>  }
>  EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type);
> -
> -struct reserved_region {
> -   struct list_head node;
> -   u64 start;
> -   u64 end;
> -};
> -
> -static LIST_HEAD(reserved_io_regions);
> -static LIST_HEAD(reserved_mem_regions);
> -
> -static int request_range(u64 start, u64 end, u8 space_id, unsigned long 
> flag

Re: [PATCH] ACPI / PNP: Reserve ACPI resources at the fs_initcall_sync stage

2015-09-16 Thread George McCollister
Unfortunately I just got around to trying linux 4.1.6 (which contains
this commit) on the Versalogic Tiger (VL-EPM-24)
http://www.versalogic.com/tiger and this commit breaks it, seems to be
back to the old behavior reported here:

http://marc.info/?t=14309238462=1=2

Before reversing the commit it shows:
pci :00:1c.0: BAR 13: assigned [io  0x2000-0x2fff]

After reversing the commit it shows:
pci :00:1c.0: BAR 13: assigned [io  0x3000-0x3fff]

I don't have a solution to propose at this point and haven't tried the
latest upstream so I'll just be building with this commit reversed
(which solves the problem) until I have a chance to look into this
further.

Regards,
George McCollister

On Fri, Jul 3, 2015 at 8:09 PM, Rafael J. Wysocki <r...@rjwysocki.net> wrote:
> From: Rafael J. Wysocki <rafael.j.wyso...@intel.com>
>
> This effectively reverts the following three commits:
>
>  7bc10388ccdd ACPI / resources: free memory on error in add_region_before()
>  0f1b414d1907 ACPI / PNP: Avoid conflicting resource reservations
>  b9a5e5e18fbf ACPI / init: Fix the ordering of acpi_reserve_resources()
>
> (commit b9a5e5e18fbf introduced regressions some of which, but not
> all, were addressed by commit 0f1b414d1907 and commit 7bc10388ccdd
> was a fixup on top of the latter) and causes ACPI fixed hardware
> resources to be reserved at the fs_initcall_sync stage of system
> initialization.
>
> The story is as follows.  First, a boot regression was reported due
> to an apparent resource reservation ordering change after a commit
> that shouldn't lead to such changes.  Investigation led to the
> conclusion that the problem happened because acpi_reserve_resources()
> was executed at the device_initcall() stage of system initialization
> which wasn't strictly ordered with respect to driver initialization
> (and with respect to the initialization of the pcieport driver in
> particular), so a random change causing the device initcalls to be
> run in a different order might break things.
>
> The response to that was to attempt to run acpi_reserve_resources()
> as soon as we knew that ACPI would be in use (commit b9a5e5e18fbf).
> However, that turned out to be too early, because it caused resource
> reservations made by the PNP system driver to fail on at least one
> system and that failure was addressed by commit 0f1b414d1907.
>
> That fix still turned out to be insufficient, though, because
> calling acpi_reserve_resources() before the fs_initcall stage of
> system initialization caused a boot regression to happen on the
> eCAFE EC-800-H20G/S netbook.  That meant that we only could call
> acpi_reserve_resources() at the fs_initcall initialization stage
> or later, but then we might just as well call it after the PNP
> initalization in which case commit 0f1b414d1907 wouldn't be
> necessary any more.
>
> For this reason, the changes made by commit 0f1b414d1907 are reverted
> (along with a memory leak fixup on top of that commit), the changes
> made by commit b9a5e5e18fbf that went too far are reverted too and
> acpi_reserve_resources() is changed into fs_initcall_sync, which
> will cause it to be executed after the PNP subsystem initialization
> (which is an fs_initcall) and before device initcalls (including
> the pcieport driver initialization) which should avoid the initial
> issue.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=100581
> Link: http://marc.info/?t=14309238462=1=2
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=99831
> Link: http://marc.info/?t=14338940261=1=2
> Fixes: b9a5e5e18fbf "ACPI / init: Fix the ordering of 
> acpi_reserve_resources()"
> Reported-by: Roland Dreier <rol...@purestorage.com>
> Reported-by-and-tested-by: <g5983...@trbvm.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wyso...@intel.com>
> ---
>  drivers/acpi/osl.c  |   12 ++-
>  drivers/acpi/resource.c |  162 
> 
>  drivers/pnp/system.c|   35 ++
>  include/linux/acpi.h|   10 --
>  4 files changed, 18 insertions(+), 201 deletions(-)
>
> Index: linux-pm/drivers/acpi/resource.c
> ===
> --- linux-pm.orig/drivers/acpi/resource.c
> +++ linux-pm/drivers/acpi/resource.c
> @@ -26,7 +26,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>
>  #ifdef CONFIG_X86
> @@ -622,164 +621,3 @@ int acpi_dev_filter_resource_type(struct
> return (type & types) ? 0 : 1;
>  }
>  EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type);
> -
> -struct reserved_region {
> -   struct list_head node;
> -   u64 start;
> -   u64 end;
> -};
> -
> -static LIST_H

[PATCH v2] USB: serial: add nt124 usb to serial driver

2015-03-03 Thread George McCollister
This driver is for the NovaTech 124 4x serial expansion board for the
NovaTech OrionLXm.

Firmware source code can be found here:
https://github.com/novatechweb/nt124

Signed-off-by: George McCollister 
---
Changes to v1:
  - Added description after nt124.c on line 2.
  - Removed DRIVER_AUTHOR and DRIVER_DESC, use MODULE macros directly.
  - Removed some unnecessary new lines and comments.
  - Removed __packed from struct nt124_line_coding.
  - Added locking around ctrlin and ctrlout.
  - Switch ctrlin and ctrlout from unsigned int to u16.
  - Removed serial_transmit and added tx_empty. Use a hybrid
notification/polling method to accurately determine when transmission is
finished while minimizing bus traffic (see comments in the code for
details).
  - Removed flowctrl from struct nt124_line_coding.
  - Use u16 for request and value, size_t for len arguments of nt124_ctrl_msg()
  - Use USB_CTRL_SET_TIMEOUT instead of 5000.
  - Use %04x for 16-bit variables and %zu for size_t variables in dev_dbg() and
dev_err().
  - Removed use of ?: constructs.
  - Removed nt124_set_control, nt124_set_line, nt124_send_break and
  - nt124_set_flowctrl macros in favor of calling nt124_ctrl_msg() directly.
  - Renamed nt124_process_notify() to nt124_process_status().
  - Call usb_serial_handle_dcd_change() unconditionally when DCD has changed.
  - Removed in argument list assignments.
  - Use usb_translate_errors() in nt124_port_tiocmset().
  - Use C_CSTOPB, C_CSIZE, C_PARENB, C_CMSPAR, C_PARODD, C_CRTSCTS macros.
  - Raise/lower RTS on !B0/B0.
  - Added NT124_BREAK_ON and NT124_BREAK_OFF #defines.
  - Change nt124_open() to just call nt124_set_termios() followed by
usb_serial_generic_open().
  - Don't set bulk_in_size and bulk_out_size.
  - Performed thorough testing.

 drivers/usb/serial/Kconfig  |   9 +
 drivers/usb/serial/Makefile |   1 +
 drivers/usb/serial/nt124.c  | 501 
 3 files changed, 511 insertions(+)
 create mode 100644 drivers/usb/serial/nt124.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index b7cf198..677a26a 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -510,6 +510,15 @@ config USB_SERIAL_NAVMAN
  To compile this driver as a module, choose M here: the
  module will be called navman.
 
+config USB_SERIAL_NT124
+   tristate "USB NovaTech 124 Serial Driver"
+   help
+ Say Y here if you want to use the NovaTech 124 4x USB to serial
+ board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called nt124.
+
 config USB_SERIAL_PL2303
tristate "USB Prolific 2303 Single Port Serial Driver"
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 349d9df..f88eaab 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)  += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)   += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)   += mxuport.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o
+obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)   += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)   += opticon.o
 obj-$(CONFIG_USB_SERIAL_OPTION)+= option.o
diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
new file mode 100644
index 000..d837593
--- /dev/null
+++ b/drivers/usb/serial/nt124.c
@@ -0,0 +1,501 @@
+/*
+ * nt124.c - Driver for nt124 4x serial board based on STM32F103
+ *
+ * Copyright (c) 2014 - 2015 NovaTech LLC
+ *
+ * Portions derived from the cdc-acm driver
+ *
+ * The original intention was to implement a cdc-acm compliant
+ * 4x USB to serial converter in the STM32F103 however several problems arose.
+ *   The STM32F103 didn't have enough end points to implement 4 ports.
+ *   CTS control was required by the application.
+ *   Accurate notification of transmission completion was required.
+ *   RTSCTS flow control support was required.
+ *
+ * The interrupt endpoint was eliminated and the control line information
+ * was moved to the first two bytes of the bulk in endpoint message. CTS
+ * control and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
+ * information were added.
+ *
+ * Firmware source code can be found here:
+ * https://github.com/novatechweb/nt124
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 

[PATCH v2] USB: serial: add nt124 usb to serial driver

2015-03-03 Thread George McCollister
This driver is for the NovaTech 124 4x serial expansion board for the
NovaTech OrionLXm.

Firmware source code can be found here:
https://github.com/novatechweb/nt124

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
Changes to v1:
  - Added description after nt124.c on line 2.
  - Removed DRIVER_AUTHOR and DRIVER_DESC, use MODULE macros directly.
  - Removed some unnecessary new lines and comments.
  - Removed __packed from struct nt124_line_coding.
  - Added locking around ctrlin and ctrlout.
  - Switch ctrlin and ctrlout from unsigned int to u16.
  - Removed serial_transmit and added tx_empty. Use a hybrid
notification/polling method to accurately determine when transmission is
finished while minimizing bus traffic (see comments in the code for
details).
  - Removed flowctrl from struct nt124_line_coding.
  - Use u16 for request and value, size_t for len arguments of nt124_ctrl_msg()
  - Use USB_CTRL_SET_TIMEOUT instead of 5000.
  - Use %04x for 16-bit variables and %zu for size_t variables in dev_dbg() and
dev_err().
  - Removed use of ?: constructs.
  - Removed nt124_set_control, nt124_set_line, nt124_send_break and
  - nt124_set_flowctrl macros in favor of calling nt124_ctrl_msg() directly.
  - Renamed nt124_process_notify() to nt124_process_status().
  - Call usb_serial_handle_dcd_change() unconditionally when DCD has changed.
  - Removed in argument list assignments.
  - Use usb_translate_errors() in nt124_port_tiocmset().
  - Use C_CSTOPB, C_CSIZE, C_PARENB, C_CMSPAR, C_PARODD, C_CRTSCTS macros.
  - Raise/lower RTS on !B0/B0.
  - Added NT124_BREAK_ON and NT124_BREAK_OFF #defines.
  - Change nt124_open() to just call nt124_set_termios() followed by
usb_serial_generic_open().
  - Don't set bulk_in_size and bulk_out_size.
  - Performed thorough testing.

 drivers/usb/serial/Kconfig  |   9 +
 drivers/usb/serial/Makefile |   1 +
 drivers/usb/serial/nt124.c  | 501 
 3 files changed, 511 insertions(+)
 create mode 100644 drivers/usb/serial/nt124.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index b7cf198..677a26a 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -510,6 +510,15 @@ config USB_SERIAL_NAVMAN
  To compile this driver as a module, choose M here: the
  module will be called navman.
 
+config USB_SERIAL_NT124
+   tristate USB NovaTech 124 Serial Driver
+   help
+ Say Y here if you want to use the NovaTech 124 4x USB to serial
+ board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called nt124.
+
 config USB_SERIAL_PL2303
tristate USB Prolific 2303 Single Port Serial Driver
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 349d9df..f88eaab 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)  += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)   += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)   += mxuport.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o
+obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)   += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)   += opticon.o
 obj-$(CONFIG_USB_SERIAL_OPTION)+= option.o
diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
new file mode 100644
index 000..d837593
--- /dev/null
+++ b/drivers/usb/serial/nt124.c
@@ -0,0 +1,501 @@
+/*
+ * nt124.c - Driver for nt124 4x serial board based on STM32F103
+ *
+ * Copyright (c) 2014 - 2015 NovaTech LLC
+ *
+ * Portions derived from the cdc-acm driver
+ *
+ * The original intention was to implement a cdc-acm compliant
+ * 4x USB to serial converter in the STM32F103 however several problems arose.
+ *   The STM32F103 didn't have enough end points to implement 4 ports.
+ *   CTS control was required by the application.
+ *   Accurate notification of transmission completion was required.
+ *   RTSCTS flow control support was required.
+ *
+ * The interrupt endpoint was eliminated and the control line information
+ * was moved to the first two bytes of the bulk in endpoint message. CTS
+ * control and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
+ * information were added.
+ *
+ * Firmware source code can be found here:
+ * https://github.com/novatechweb/nt124
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See

[PATCH] ARM: dts: am335x-lxm: Use rmii-clock-ext

2015-02-26 Thread George McCollister
Use external clock for RMII since the internal clock doesn't meet the
jitter requirements.

Signed-off-by: George McCollister 
---
 arch/arm/boot/dts/am335x-lxm.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
index 7266a00..5c5667a 100644
--- a/arch/arm/boot/dts/am335x-lxm.dts
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -328,6 +328,10 @@
dual_emac_res_vlan = <3>;
 };
 
+_sel {
+   rmii-clock-ext;
+};
+
  {
pinctrl-names = "default", "sleep";
pinctrl-0 = <_default>;
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: dts: am335x-lxm: Use rmii-clock-ext

2015-02-26 Thread George McCollister
Use external clock for RMII since the internal clock doesn't meet the
jitter requirements.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 arch/arm/boot/dts/am335x-lxm.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
index 7266a00..5c5667a 100644
--- a/arch/arm/boot/dts/am335x-lxm.dts
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -328,6 +328,10 @@
dual_emac_res_vlan = 3;
 };
 
+phy_sel {
+   rmii-clock-ext;
+};
+
 mac {
pinctrl-names = default, sleep;
pinctrl-0 = cpsw_default;
-- 
2.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-15 Thread George McCollister
On Mon, Dec 15, 2014 at 3:52 AM, Johan Hovold  wrote:
> On Sun, Dec 14, 2014 at 11:51:11AM -0600, George McCollister wrote:
>> Johan,
>>
>> While working on the tx_empty changes you suggested it occurred to me
>> that it might not be obvious to others that the firmware doesn't send
>> a packet with the NT124_CTRL_TXEMPTY flag cleared when it begins
>> transmitting. The practical implication is that if the driver sets
>> tx_empty = true when it sees NT124_CTRL_TXEMPTY, tx_empty must be
>> reset to false somewhere when more data is transmitted. Perhaps I
>> could add prepare_write_buffer and do it in there before calling
>> usb_serial_generic_prepare_write_buffer(). Does that sound acceptable?
>
> Hmm. There's no way to query that flag? And the status is sent (as bulk
> in data) periodically or only when data has been received? And not when
> the actual status changes?
The bulk in packets are not sent periodically only on TXEMPTY, other
line change or received data. There's no way to query the flag, though
we're still at the stage we can make modifications to the firmware if
there's justification. One of the design goals is to minimize
unnecessary USB traffic so if there's a place to clear the flag in the
driver without querying it would be preferable.
>
> A potential problem with using prepare_write_buffer would be on failures
> to submit the write urb, in which case this flag might never be cleared.
Yes, this could be a problem though I wonder how many (if any)
recoverable situations this would happen in that didn't eventually
lead to a transmission. Adding a timer with a long timeout that set
tx_empty  = true crossed my mind but that doesn't really seem any less
error prone than the original issue. I could of course duplicate a
bunch of code from generic.c and make a few minor changes to set
tx_empty = true but that obviously isn't desirable either.

If none of the above solutions sound acceptable, let me know I and I
guess I'll change the firmware to allow polling of TXEMPTY with a
control message and remove it from the bulk in packet.

Thanks again,
George

> Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-15 Thread George McCollister
On Mon, Dec 15, 2014 at 3:52 AM, Johan Hovold jo...@kernel.org wrote:
 On Sun, Dec 14, 2014 at 11:51:11AM -0600, George McCollister wrote:
 Johan,

 While working on the tx_empty changes you suggested it occurred to me
 that it might not be obvious to others that the firmware doesn't send
 a packet with the NT124_CTRL_TXEMPTY flag cleared when it begins
 transmitting. The practical implication is that if the driver sets
 tx_empty = true when it sees NT124_CTRL_TXEMPTY, tx_empty must be
 reset to false somewhere when more data is transmitted. Perhaps I
 could add prepare_write_buffer and do it in there before calling
 usb_serial_generic_prepare_write_buffer(). Does that sound acceptable?

 Hmm. There's no way to query that flag? And the status is sent (as bulk
 in data) periodically or only when data has been received? And not when
 the actual status changes?
The bulk in packets are not sent periodically only on TXEMPTY, other
line change or received data. There's no way to query the flag, though
we're still at the stage we can make modifications to the firmware if
there's justification. One of the design goals is to minimize
unnecessary USB traffic so if there's a place to clear the flag in the
driver without querying it would be preferable.

 A potential problem with using prepare_write_buffer would be on failures
 to submit the write urb, in which case this flag might never be cleared.
Yes, this could be a problem though I wonder how many (if any)
recoverable situations this would happen in that didn't eventually
lead to a transmission. Adding a timer with a long timeout that set
tx_empty  = true crossed my mind but that doesn't really seem any less
error prone than the original issue. I could of course duplicate a
bunch of code from generic.c and make a few minor changes to set
tx_empty = true but that obviously isn't desirable either.

If none of the above solutions sound acceptable, let me know I and I
guess I'll change the firmware to allow polling of TXEMPTY with a
control message and remove it from the bulk in packet.

Thanks again,
George

 Johan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-14 Thread George McCollister
Johan,

While working on the tx_empty changes you suggested it occurred to me
that it might not be obvious to others that the firmware doesn't send
a packet with the NT124_CTRL_TXEMPTY flag cleared when it begins
transmitting. The practical implication is that if the driver sets
tx_empty = true when it sees NT124_CTRL_TXEMPTY, tx_empty must be
reset to false somewhere when more data is transmitted. Perhaps I
could add prepare_write_buffer and do it in there before calling
usb_serial_generic_prepare_write_buffer(). Does that sound acceptable?
If so I'll also initialize tx_empty = true in nt124_port_probe.

Regards,
George
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-14 Thread George McCollister
Johan,

While working on the tx_empty changes you suggested it occurred to me
that it might not be obvious to others that the firmware doesn't send
a packet with the NT124_CTRL_TXEMPTY flag cleared when it begins
transmitting. The practical implication is that if the driver sets
tx_empty = true when it sees NT124_CTRL_TXEMPTY, tx_empty must be
reset to false somewhere when more data is transmitted. Perhaps I
could add prepare_write_buffer and do it in there before calling
usb_serial_generic_prepare_write_buffer(). Does that sound acceptable?
If so I'll also initialize tx_empty = true in nt124_port_probe.

Regards,
George
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-12 Thread George McCollister
Johan,

Thanks for the thorough review.

On Wed, Dec 10, 2014 at 7:04 AM, Johan Hovold  wrote:
> On Mon, Dec 08, 2014 at 05:24:17PM -0600, George McCollister wrote:
>> This driver is for the NovaTech 124 4x serial expansion board for the
>> NovaTech OrionLXm.
>>
>> Firmware source code can be found here:
>> https://github.com/novatechweb/nt124
>
> Great, and thanks for the patch!
>
>> Signed-off-by: George McCollister 
>> ---
>>  drivers/usb/serial/Kconfig  |   9 +
>>  drivers/usb/serial/Makefile |   1 +
>>  drivers/usb/serial/nt124.c  | 429 
>> 
>>  3 files changed, 439 insertions(+)
>>  create mode 100644 drivers/usb/serial/nt124.c
>>
>> diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
>> index a69f7cd..6dfc340 100644
>> --- a/drivers/usb/serial/Kconfig
>> +++ b/drivers/usb/serial/Kconfig
>> @@ -509,6 +509,15 @@ config USB_SERIAL_NAVMAN
>> To compile this driver as a module, choose M here: the
>> module will be called navman.
>>
>> +config USB_SERIAL_NT124
>> + tristate "USB nt124 serial device"
>
> USB NovaTech 124 Serial Driver (or NovaTech nt124)
I'll use USB NovaTech 124 Serial Driver
>
>> + help
>> +   Say Y here if you want to use the NovaTech 124 4x USB to serial
>> +   board.
>> +
>> +   To compile this driver as a module, choose M here: the
>> +   module will be called nt124.
>> +
>>  config USB_SERIAL_PL2303
>>   tristate "USB Prolific 2303 Single Port Serial Driver"
>>   help
>> diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
>> index 349d9df..f88eaab 100644
>> --- a/drivers/usb/serial/Makefile
>> +++ b/drivers/usb/serial/Makefile
>> @@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)+= mos7720.o
>>  obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
>>  obj-$(CONFIG_USB_SERIAL_MXUPORT) += mxuport.o
>>  obj-$(CONFIG_USB_SERIAL_NAVMAN)  += navman.o
>> +obj-$(CONFIG_USB_SERIAL_NT124)   += nt124.o
>>  obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
>>  obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o
>>  obj-$(CONFIG_USB_SERIAL_OPTION)  += option.o
>> diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
>> new file mode 100644
>> index 000..d7557ff
>> --- /dev/null
>> +++ b/drivers/usb/serial/nt124.c
>> @@ -0,0 +1,429 @@
>> +/*
>> + * nt124.c
>
> Put a brief description here instead.
Okay
>
>> + *
>> + * Copyright (c) 2014 NovaTech LLC
>> + *
>> + * Driver for nt124 4x serial board based on STM32F103
>
> For example use something like this above.
Okay
>
>> + *
>> + * Portions derived from the cdc-acm driver
>> + *
>> + * The original intention was to implement a cdc-acm compliant
>> + * 4x USB to serial converter in the STM32F103 however several problems 
>> arose.
>> + *   The STM32F103 didn't have enough end points to implement 4 ports.
>> + *   CTS control was required by the application.
>> + *   Accurate notification of transmission completion was required.
>> + *   RTSCTS flow control support was required.
>> + *
>> + * The interrupt endpoint was eliminated and the control line information
>> + * was moved to the first two bytes of the in endpoint message. CTS control
>
> bulk in endpoint
Okay
>
>> + * and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
>> + * information were added.
>> + *
>> + * Firmware source code can be found here:
>> + * https://github.com/novatechweb/nt124
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define NT124_VID0x2aeb
>> +#define NT124_USB_PID124
>> +
>&

Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-12 Thread George McCollister
Johan,

Thanks for the thorough review.

On Wed, Dec 10, 2014 at 7:04 AM, Johan Hovold jo...@kernel.org wrote:
 On Mon, Dec 08, 2014 at 05:24:17PM -0600, George McCollister wrote:
 This driver is for the NovaTech 124 4x serial expansion board for the
 NovaTech OrionLXm.

 Firmware source code can be found here:
 https://github.com/novatechweb/nt124

 Great, and thanks for the patch!

 Signed-off-by: George McCollister george.mccollis...@gmail.com
 ---
  drivers/usb/serial/Kconfig  |   9 +
  drivers/usb/serial/Makefile |   1 +
  drivers/usb/serial/nt124.c  | 429 
 
  3 files changed, 439 insertions(+)
  create mode 100644 drivers/usb/serial/nt124.c

 diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
 index a69f7cd..6dfc340 100644
 --- a/drivers/usb/serial/Kconfig
 +++ b/drivers/usb/serial/Kconfig
 @@ -509,6 +509,15 @@ config USB_SERIAL_NAVMAN
 To compile this driver as a module, choose M here: the
 module will be called navman.

 +config USB_SERIAL_NT124
 + tristate USB nt124 serial device

 USB NovaTech 124 Serial Driver (or NovaTech nt124)
I'll use USB NovaTech 124 Serial Driver

 + help
 +   Say Y here if you want to use the NovaTech 124 4x USB to serial
 +   board.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called nt124.
 +
  config USB_SERIAL_PL2303
   tristate USB Prolific 2303 Single Port Serial Driver
   help
 diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
 index 349d9df..f88eaab 100644
 --- a/drivers/usb/serial/Makefile
 +++ b/drivers/usb/serial/Makefile
 @@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)+= mos7720.o
  obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
  obj-$(CONFIG_USB_SERIAL_MXUPORT) += mxuport.o
  obj-$(CONFIG_USB_SERIAL_NAVMAN)  += navman.o
 +obj-$(CONFIG_USB_SERIAL_NT124)   += nt124.o
  obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
  obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o
  obj-$(CONFIG_USB_SERIAL_OPTION)  += option.o
 diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
 new file mode 100644
 index 000..d7557ff
 --- /dev/null
 +++ b/drivers/usb/serial/nt124.c
 @@ -0,0 +1,429 @@
 +/*
 + * nt124.c

 Put a brief description here instead.
Okay

 + *
 + * Copyright (c) 2014 NovaTech LLC
 + *
 + * Driver for nt124 4x serial board based on STM32F103

 For example use something like this above.
Okay

 + *
 + * Portions derived from the cdc-acm driver
 + *
 + * The original intention was to implement a cdc-acm compliant
 + * 4x USB to serial converter in the STM32F103 however several problems 
 arose.
 + *   The STM32F103 didn't have enough end points to implement 4 ports.
 + *   CTS control was required by the application.
 + *   Accurate notification of transmission completion was required.
 + *   RTSCTS flow control support was required.
 + *
 + * The interrupt endpoint was eliminated and the control line information
 + * was moved to the first two bytes of the in endpoint message. CTS control

 bulk in endpoint
Okay

 + * and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
 + * information were added.
 + *
 + * Firmware source code can be found here:
 + * https://github.com/novatechweb/nt124
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/kernel.h
 +#include linux/slab.h
 +#include linux/tty.h
 +#include linux/tty_driver.h
 +#include linux/tty_flip.h
 +#include linux/module.h
 +#include linux/usb.h
 +#include linux/usb/serial.h
 +#include asm/unaligned.h
 +
 +#define NT124_VID0x2aeb
 +#define NT124_USB_PID124
 +
 +#define DRIVER_AUTHOR George McCollister george.mccollis...@gmail.com
 +#define DRIVER_DESC nt124 USB serial driver

 Just use the MODULE macros directly (at the end of the file), no need
 for the defines.
Okay

 +
 +static const struct usb_device_id id_table[] = {
 + { USB_DEVICE(NT124_VID, NT124_USB_PID) },
 + { },
 +};
 +
 +MODULE_DEVICE_TABLE(usb, id_table);
 +
 +/*
 + * Output control lines.
 + */
 +

 No new line.
Okay

 +#define NT124_CTRL_DTR   0x01
 +#define NT124_CTRL_RTS   0x02
 +
 +/*
 + * Input control lines and line errors.
 + */
 +

 Same here.
Okay

 +#define NT124_CTRL_DCD   0x01
 +#define NT124_CTRL_DSR   0x02
 +#define NT124_CTRL_BRK   0x04

Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-08 Thread George McCollister
Thanks for the review.

I didn't update the MAINTAINERS file because I looked in it and didn't
see any other individual usb/serial drivers listed with maintainers.

-George

On Mon, Dec 8, 2014 at 6:29 PM, Jeremiah Mahler  wrote:
> George,
>
> On Mon, Dec 08, 2014 at 05:24:17PM -0600, George McCollister wrote:
>> This driver is for the NovaTech 124 4x serial expansion board for the
>> NovaTech OrionLXm.
>>
>> Firmware source code can be found here:
>> https://github.com/novatechweb/nt124
>>
>> Signed-off-by: George McCollister 
>> ---
>>  drivers/usb/serial/Kconfig  |   9 +
>>  drivers/usb/serial/Makefile |   1 +
>>  drivers/usb/serial/nt124.c  | 429 
>> 
>>  3 files changed, 439 insertions(+)
>>  create mode 100644 drivers/usb/serial/nt124.c
>>
>> diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
> [...]
>
> It applies to next without any errors, there are no checkpatch issues
> other than recommending updating the MAINTAINERS file, and I can't find
> any other obvious problems.  Looks good to me.
>
> Reviewed-by: Jeremiah Mahler 
>
> --
> - Jeremiah Mahler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] USB: serial: add nt124 usb to serial driver

2014-12-08 Thread George McCollister
This driver is for the NovaTech 124 4x serial expansion board for the
NovaTech OrionLXm.

Firmware source code can be found here:
https://github.com/novatechweb/nt124

Signed-off-by: George McCollister 
---
 drivers/usb/serial/Kconfig  |   9 +
 drivers/usb/serial/Makefile |   1 +
 drivers/usb/serial/nt124.c  | 429 
 3 files changed, 439 insertions(+)
 create mode 100644 drivers/usb/serial/nt124.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index a69f7cd..6dfc340 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -509,6 +509,15 @@ config USB_SERIAL_NAVMAN
  To compile this driver as a module, choose M here: the
  module will be called navman.
 
+config USB_SERIAL_NT124
+   tristate "USB nt124 serial device"
+   help
+ Say Y here if you want to use the NovaTech 124 4x USB to serial
+ board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called nt124.
+
 config USB_SERIAL_PL2303
tristate "USB Prolific 2303 Single Port Serial Driver"
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 349d9df..f88eaab 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)  += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)   += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)   += mxuport.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o
+obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)   += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)   += opticon.o
 obj-$(CONFIG_USB_SERIAL_OPTION)+= option.o
diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
new file mode 100644
index 000..d7557ff
--- /dev/null
+++ b/drivers/usb/serial/nt124.c
@@ -0,0 +1,429 @@
+/*
+ * nt124.c
+ *
+ * Copyright (c) 2014 NovaTech LLC
+ *
+ * Driver for nt124 4x serial board based on STM32F103
+ *
+ * Portions derived from the cdc-acm driver
+ *
+ * The original intention was to implement a cdc-acm compliant
+ * 4x USB to serial converter in the STM32F103 however several problems arose.
+ *   The STM32F103 didn't have enough end points to implement 4 ports.
+ *   CTS control was required by the application.
+ *   Accurate notification of transmission completion was required.
+ *   RTSCTS flow control support was required.
+ *
+ * The interrupt endpoint was eliminated and the control line information
+ * was moved to the first two bytes of the in endpoint message. CTS control
+ * and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
+ * information were added.
+ *
+ * Firmware source code can be found here:
+ * https://github.com/novatechweb/nt124
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NT124_VID  0x2aeb
+#define NT124_USB_PID  124
+
+#define DRIVER_AUTHOR "George McCollister "
+#define DRIVER_DESC "nt124 USB serial driver"
+
+static const struct usb_device_id id_table[] = {
+   { USB_DEVICE(NT124_VID, NT124_USB_PID) },
+   { },
+};
+
+MODULE_DEVICE_TABLE(usb, id_table);
+
+/*
+ * Output control lines.
+ */
+
+#define NT124_CTRL_DTR 0x01
+#define NT124_CTRL_RTS 0x02
+
+/*
+ * Input control lines and line errors.
+ */
+
+#define NT124_CTRL_DCD 0x01
+#define NT124_CTRL_DSR 0x02
+#define NT124_CTRL_BRK 0x04
+#define NT124_CTRL_RI  0x08
+#define NT124_CTRL_FRAMING 0x10
+#define NT124_CTRL_PARITY  0x20
+#define NT124_CTRL_OVERRUN 0x40
+#define NT124_CTRL_TXEMPTY 0x80
+#define NT124_CTRL_CTS 0x100
+
+#define USB_NT124_REQ_SET_LINE_CODING  0x20
+#define USB_NT124_REQ_SET_CONTROL_LINE_STATE   0x22
+#define USB_NT124_REQ_SEND_BREAK   0x23
+#define USB_NT124_SET_FLOW_CONTROL 0x90
+
+struct nt124_line_coding {
+   __le32  dwDTERate;
+   u8  bCharFormat;
+   u8  bParityType;
+   u8  bDataBits;
+} __packed;
+
+struct nt124_private {
+   /* USB interface */
+   u16 bInterfaceNumber;
+   /* input control lines (DCD, DSR, RI, break, overruns) */
+   unsigned int ctrlin;
+   /* output control lines (DTR, RTS) */
+   

[PATCH] USB: serial: add nt124 usb to serial driver

2014-12-08 Thread George McCollister
This driver is for the NovaTech 124 4x serial expansion board for the
NovaTech OrionLXm.

Firmware source code can be found here:
https://github.com/novatechweb/nt124

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 drivers/usb/serial/Kconfig  |   9 +
 drivers/usb/serial/Makefile |   1 +
 drivers/usb/serial/nt124.c  | 429 
 3 files changed, 439 insertions(+)
 create mode 100644 drivers/usb/serial/nt124.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index a69f7cd..6dfc340 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -509,6 +509,15 @@ config USB_SERIAL_NAVMAN
  To compile this driver as a module, choose M here: the
  module will be called navman.
 
+config USB_SERIAL_NT124
+   tristate USB nt124 serial device
+   help
+ Say Y here if you want to use the NovaTech 124 4x USB to serial
+ board.
+
+ To compile this driver as a module, choose M here: the
+ module will be called nt124.
+
 config USB_SERIAL_PL2303
tristate USB Prolific 2303 Single Port Serial Driver
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 349d9df..f88eaab 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_MOS7720)  += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)   += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)   += mxuport.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)+= navman.o
+obj-$(CONFIG_USB_SERIAL_NT124) += nt124.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)   += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)   += opticon.o
 obj-$(CONFIG_USB_SERIAL_OPTION)+= option.o
diff --git a/drivers/usb/serial/nt124.c b/drivers/usb/serial/nt124.c
new file mode 100644
index 000..d7557ff
--- /dev/null
+++ b/drivers/usb/serial/nt124.c
@@ -0,0 +1,429 @@
+/*
+ * nt124.c
+ *
+ * Copyright (c) 2014 NovaTech LLC
+ *
+ * Driver for nt124 4x serial board based on STM32F103
+ *
+ * Portions derived from the cdc-acm driver
+ *
+ * The original intention was to implement a cdc-acm compliant
+ * 4x USB to serial converter in the STM32F103 however several problems arose.
+ *   The STM32F103 didn't have enough end points to implement 4 ports.
+ *   CTS control was required by the application.
+ *   Accurate notification of transmission completion was required.
+ *   RTSCTS flow control support was required.
+ *
+ * The interrupt endpoint was eliminated and the control line information
+ * was moved to the first two bytes of the in endpoint message. CTS control
+ * and mechanisms to enable RTSCTS flow control and deliver TXEMPTY
+ * information were added.
+ *
+ * Firmware source code can be found here:
+ * https://github.com/novatechweb/nt124
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/kernel.h
+#include linux/slab.h
+#include linux/tty.h
+#include linux/tty_driver.h
+#include linux/tty_flip.h
+#include linux/module.h
+#include linux/usb.h
+#include linux/usb/serial.h
+#include asm/unaligned.h
+
+#define NT124_VID  0x2aeb
+#define NT124_USB_PID  124
+
+#define DRIVER_AUTHOR George McCollister george.mccollis...@gmail.com
+#define DRIVER_DESC nt124 USB serial driver
+
+static const struct usb_device_id id_table[] = {
+   { USB_DEVICE(NT124_VID, NT124_USB_PID) },
+   { },
+};
+
+MODULE_DEVICE_TABLE(usb, id_table);
+
+/*
+ * Output control lines.
+ */
+
+#define NT124_CTRL_DTR 0x01
+#define NT124_CTRL_RTS 0x02
+
+/*
+ * Input control lines and line errors.
+ */
+
+#define NT124_CTRL_DCD 0x01
+#define NT124_CTRL_DSR 0x02
+#define NT124_CTRL_BRK 0x04
+#define NT124_CTRL_RI  0x08
+#define NT124_CTRL_FRAMING 0x10
+#define NT124_CTRL_PARITY  0x20
+#define NT124_CTRL_OVERRUN 0x40
+#define NT124_CTRL_TXEMPTY 0x80
+#define NT124_CTRL_CTS 0x100
+
+#define USB_NT124_REQ_SET_LINE_CODING  0x20
+#define USB_NT124_REQ_SET_CONTROL_LINE_STATE   0x22
+#define USB_NT124_REQ_SEND_BREAK   0x23
+#define USB_NT124_SET_FLOW_CONTROL 0x90
+
+struct nt124_line_coding {
+   __le32  dwDTERate;
+   u8  bCharFormat;
+   u8  bParityType;
+   u8  bDataBits;
+} __packed;
+
+struct nt124_private {
+   /* USB interface */
+   u16 bInterfaceNumber

Re: [PATCH] USB: serial: add nt124 usb to serial driver

2014-12-08 Thread George McCollister
Thanks for the review.

I didn't update the MAINTAINERS file because I looked in it and didn't
see any other individual usb/serial drivers listed with maintainers.

-George

On Mon, Dec 8, 2014 at 6:29 PM, Jeremiah Mahler jmmah...@gmail.com wrote:
 George,

 On Mon, Dec 08, 2014 at 05:24:17PM -0600, George McCollister wrote:
 This driver is for the NovaTech 124 4x serial expansion board for the
 NovaTech OrionLXm.

 Firmware source code can be found here:
 https://github.com/novatechweb/nt124

 Signed-off-by: George McCollister george.mccollis...@gmail.com
 ---
  drivers/usb/serial/Kconfig  |   9 +
  drivers/usb/serial/Makefile |   1 +
  drivers/usb/serial/nt124.c  | 429 
 
  3 files changed, 439 insertions(+)
  create mode 100644 drivers/usb/serial/nt124.c

 diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
 [...]

 It applies to next without any errors, there are no checkpatch issues
 other than recommending updating the MAINTAINERS file, and I can't find
 any other obvious problems.  Looks good to me.

 Reviewed-by: Jeremiah Mahler jmmah...@gmail.com

 --
 - Jeremiah Mahler
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] iio: Add support for waveform output

2014-11-26 Thread George McCollister
Output can be held high or low for a specified period of time.
Support for waveform capture could be added in the future.

Signed-off-by: George McCollister 
---
 Documentation/ABI/testing/sysfs-bus-iio   | 7 +++
 drivers/iio/industrialio-core.c   | 3 +++
 drivers/staging/iio/Documentation/iio_event_monitor.c | 2 ++
 include/linux/iio/types.h | 5 -
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio 
b/Documentation/ABI/testing/sysfs-bus-iio
index d760b02..47df169 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1028,3 +1028,10 @@ Contact: linux-...@vger.kernel.org
 Description:
Raw value of rotation from true/magnetic north measured with
or without compensation from tilt sensors.
+
+What:  /sys/bus/iio/devices/iio:deviceX/out_waveformY_hightime_raw
+What:  /sys/bus/iio/devices/iio:deviceX/out_waveformY_lowtime_raw
+KernelVersion: 3.18
+Contact:   linux-...@vger.kernel.org
+Description:
+   Raw value of time for output to be held high or low.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index af3e76d..343e784 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_CCT] = "cct",
[IIO_PRESSURE] = "pressure",
[IIO_HUMIDITYRELATIVE] = "humidityrelative",
+   [IIO_WAVEFORM] = "waveform",
 };
 
 static const char * const iio_modifier_names[] = {
@@ -91,6 +92,8 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_NORTH_TRUE] = "from_north_true",
[IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
[IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
+   [IIO_MOD_HIGHTIME] = "hightime",
+   [IIO_MOD_LOWTIME] = "lowtime",
 };
 
 /* relies on pairs of these shared then separate */
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c 
b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 569d6f8..690f261 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -49,6 +49,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_CCT] = "cct",
[IIO_PRESSURE] = "pressure",
[IIO_HUMIDITYRELATIVE] = "humidityrelative",
+   [IIO_WAVEFORM] = "waveform",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -108,6 +109,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_CCT:
case IIO_PRESSURE:
case IIO_HUMIDITYRELATIVE:
+   case IIO_WAVEFORM:
break;
default:
return false;
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 4a2af8a..d3b0af1 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -30,6 +30,7 @@ enum iio_chan_type {
IIO_CCT,
IIO_PRESSURE,
IIO_HUMIDITYRELATIVE,
+   IIO_WAVEFORM,
 };
 
 enum iio_modifier {
@@ -59,7 +60,9 @@ enum iio_modifier {
IIO_MOD_NORTH_MAGN,
IIO_MOD_NORTH_TRUE,
IIO_MOD_NORTH_MAGN_TILT_COMP,
-   IIO_MOD_NORTH_TRUE_TILT_COMP
+   IIO_MOD_NORTH_TRUE_TILT_COMP,
+   IIO_MOD_HIGHTIME,
+   IIO_MOD_LOWTIME,
 };
 
 enum iio_event_type {
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] iio: Add nt133 I/O board support

2014-11-26 Thread George McCollister
The NovaTech 133 I/O board is an expansion card for the NovaTech
OrionLXm with 16 digital input channels and 4 digital output channels.

Signed-off-by: George McCollister 
---
 drivers/iio/Kconfig   |   1 +
 drivers/iio/Makefile  |   1 +
 drivers/iio/waveform/Kconfig  |  14 ++
 drivers/iio/waveform/Makefile |   5 +
 drivers/iio/waveform/nt133.c  | 572 ++
 5 files changed, 593 insertions(+)
 create mode 100644 drivers/iio/waveform/Kconfig
 create mode 100644 drivers/iio/waveform/Makefile
 create mode 100644 drivers/iio/waveform/nt133.c

diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 345395e..c0af707 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -77,5 +77,6 @@ endif #IIO_TRIGGER
 source "drivers/iio/pressure/Kconfig"
 source "drivers/iio/proximity/Kconfig"
 source "drivers/iio/temperature/Kconfig"
+source "drivers/iio/waveform/Kconfig"
 
 endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index 698afc2..599e34e 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -27,3 +27,4 @@ obj-y += pressure/
 obj-y += proximity/
 obj-y += temperature/
 obj-y += trigger/
+obj-y += waveform/
diff --git a/drivers/iio/waveform/Kconfig b/drivers/iio/waveform/Kconfig
new file mode 100644
index 000..c97558d
--- /dev/null
+++ b/drivers/iio/waveform/Kconfig
@@ -0,0 +1,14 @@
+#
+# Waveform drivers
+#
+menu "Waveform output"
+
+config NT133
+   tristate "NovaTech 133 I/O board"
+   select IIO_BUFFER
+   select IIO_TRIGGERED_BUFFER
+   depends on USB
+   help
+ Say yes here to build support for NovaTech 133 I/O board.
+
+endmenu
diff --git a/drivers/iio/waveform/Makefile b/drivers/iio/waveform/Makefile
new file mode 100644
index 000..d59887c
--- /dev/null
+++ b/drivers/iio/waveform/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for industrial I/O waveform drivers
+#
+
+obj-$(CONFIG_NT133) += nt133.o
diff --git a/drivers/iio/waveform/nt133.c b/drivers/iio/waveform/nt133.c
new file mode 100644
index 000..8fdf172
--- /dev/null
+++ b/drivers/iio/waveform/nt133.c
@@ -0,0 +1,572 @@
+/*
+ * NovaTech 133 I/O board driver
+ *
+ * Copyright 2014 NovaTech LLC.
+ *
+ * George McCollister 
+ *
+ * Portions derivied from USB Skeleton driver - 2.2
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NT133_DRV_NAME "nt133"
+#define NT133_VENDOR_ID0x2aeb
+#define NT133_PRODUCT_ID   133
+
+#define NT133_USB_REQ_INPUT_STATUS 0x10
+#define NT133_USB_REQ_OUTPUT_STATUS0x11
+#define NT133_USB_REQ_OUTPUT_CTRL  0x12
+#define NT133_USB_REQ_OUTPUT_ENABLE0x13
+
+/* table of devices that work with this driver */
+static const struct usb_device_id nt133_table[] = {
+   { USB_DEVICE(NT133_VENDOR_ID, NT133_PRODUCT_ID) },
+   { } /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, nt133_table);
+
+struct nt133_state {
+   /* the usb device for this device */
+   struct usb_device   *udev;
+   /* the interface for this device */
+   struct usb_interface*interface;
+   /* in case we need to retract our submissions */
+   struct usb_anchor   submitted;
+   /* the urb to read data with */
+   struct urb  *int_in_urb;
+   /* the buffer to receive data */
+   __be16  int_in_data;
+   /* the address of the int in endpoint */
+   __u8int_in_endpointAddr;
+   /* synchronize I/O with disconnect */
+   struct mutexio_mutex;
+   /* Interrupt end point poll interval */
+   u8  bInterval;
+   struct iio_trigger  *trig;
+   u16 *buffer;
+};
+
+#define NT133_IN_CHAN(idx) {   \
+   .type = IIO_VOLTAGE,\
+   .indexed = 1,   \
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),   \
+   .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+   .channel = idx, \
+   .scan_index = idx,  \
+   .scan_type = {  \
+   .sign   = 'u',  \
+   .realbits   = 1,\
+   .storagebits= 16,   \
+   },  \
+}
+
+#define NT133_OUT_CHAN(chan, chan2) {  \
+   .type = IIO_WAVEFORM,   \
+   .indexed = 1,   \
+   .scan_i

[PATCH 2/2] iio: Add nt133 I/O board support

2014-11-26 Thread George McCollister
The NovaTech 133 I/O board is an expansion card for the NovaTech
OrionLXm with 16 digital input channels and 4 digital output channels.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 drivers/iio/Kconfig   |   1 +
 drivers/iio/Makefile  |   1 +
 drivers/iio/waveform/Kconfig  |  14 ++
 drivers/iio/waveform/Makefile |   5 +
 drivers/iio/waveform/nt133.c  | 572 ++
 5 files changed, 593 insertions(+)
 create mode 100644 drivers/iio/waveform/Kconfig
 create mode 100644 drivers/iio/waveform/Makefile
 create mode 100644 drivers/iio/waveform/nt133.c

diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 345395e..c0af707 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -77,5 +77,6 @@ endif #IIO_TRIGGER
 source drivers/iio/pressure/Kconfig
 source drivers/iio/proximity/Kconfig
 source drivers/iio/temperature/Kconfig
+source drivers/iio/waveform/Kconfig
 
 endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index 698afc2..599e34e 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -27,3 +27,4 @@ obj-y += pressure/
 obj-y += proximity/
 obj-y += temperature/
 obj-y += trigger/
+obj-y += waveform/
diff --git a/drivers/iio/waveform/Kconfig b/drivers/iio/waveform/Kconfig
new file mode 100644
index 000..c97558d
--- /dev/null
+++ b/drivers/iio/waveform/Kconfig
@@ -0,0 +1,14 @@
+#
+# Waveform drivers
+#
+menu Waveform output
+
+config NT133
+   tristate NovaTech 133 I/O board
+   select IIO_BUFFER
+   select IIO_TRIGGERED_BUFFER
+   depends on USB
+   help
+ Say yes here to build support for NovaTech 133 I/O board.
+
+endmenu
diff --git a/drivers/iio/waveform/Makefile b/drivers/iio/waveform/Makefile
new file mode 100644
index 000..d59887c
--- /dev/null
+++ b/drivers/iio/waveform/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for industrial I/O waveform drivers
+#
+
+obj-$(CONFIG_NT133) += nt133.o
diff --git a/drivers/iio/waveform/nt133.c b/drivers/iio/waveform/nt133.c
new file mode 100644
index 000..8fdf172
--- /dev/null
+++ b/drivers/iio/waveform/nt133.c
@@ -0,0 +1,572 @@
+/*
+ * NovaTech 133 I/O board driver
+ *
+ * Copyright 2014 NovaTech LLC.
+ *
+ * George McCollister george.mccollis...@gmail.com
+ *
+ * Portions derivied from USB Skeleton driver - 2.2
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include linux/kernel.h
+#include linux/errno.h
+#include linux/slab.h
+#include linux/module.h
+#include linux/uaccess.h
+#include linux/usb.h
+#include linux/mutex.h
+#include linux/iio/iio.h
+#include linux/iio/sysfs.h
+#include linux/iio/trigger.h
+#include linux/iio/trigger_consumer.h
+#include linux/iio/buffer.h
+#include linux/iio/triggered_buffer.h
+
+#define NT133_DRV_NAME nt133
+#define NT133_VENDOR_ID0x2aeb
+#define NT133_PRODUCT_ID   133
+
+#define NT133_USB_REQ_INPUT_STATUS 0x10
+#define NT133_USB_REQ_OUTPUT_STATUS0x11
+#define NT133_USB_REQ_OUTPUT_CTRL  0x12
+#define NT133_USB_REQ_OUTPUT_ENABLE0x13
+
+/* table of devices that work with this driver */
+static const struct usb_device_id nt133_table[] = {
+   { USB_DEVICE(NT133_VENDOR_ID, NT133_PRODUCT_ID) },
+   { } /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, nt133_table);
+
+struct nt133_state {
+   /* the usb device for this device */
+   struct usb_device   *udev;
+   /* the interface for this device */
+   struct usb_interface*interface;
+   /* in case we need to retract our submissions */
+   struct usb_anchor   submitted;
+   /* the urb to read data with */
+   struct urb  *int_in_urb;
+   /* the buffer to receive data */
+   __be16  int_in_data;
+   /* the address of the int in endpoint */
+   __u8int_in_endpointAddr;
+   /* synchronize I/O with disconnect */
+   struct mutexio_mutex;
+   /* Interrupt end point poll interval */
+   u8  bInterval;
+   struct iio_trigger  *trig;
+   u16 *buffer;
+};
+
+#define NT133_IN_CHAN(idx) {   \
+   .type = IIO_VOLTAGE,\
+   .indexed = 1,   \
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),   \
+   .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),   \
+   .channel = idx, \
+   .scan_index = idx,  \
+   .scan_type = {  \
+   .sign   = 'u',  \
+   .realbits   = 1,\
+   .storagebits= 16,   \
+   },  \
+}
+
+#define NT133_OUT_CHAN(chan, chan2

[PATCH 1/2] iio: Add support for waveform output

2014-11-26 Thread George McCollister
Output can be held high or low for a specified period of time.
Support for waveform capture could be added in the future.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 Documentation/ABI/testing/sysfs-bus-iio   | 7 +++
 drivers/iio/industrialio-core.c   | 3 +++
 drivers/staging/iio/Documentation/iio_event_monitor.c | 2 ++
 include/linux/iio/types.h | 5 -
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio 
b/Documentation/ABI/testing/sysfs-bus-iio
index d760b02..47df169 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1028,3 +1028,10 @@ Contact: linux-...@vger.kernel.org
 Description:
Raw value of rotation from true/magnetic north measured with
or without compensation from tilt sensors.
+
+What:  /sys/bus/iio/devices/iio:deviceX/out_waveformY_hightime_raw
+What:  /sys/bus/iio/devices/iio:deviceX/out_waveformY_lowtime_raw
+KernelVersion: 3.18
+Contact:   linux-...@vger.kernel.org
+Description:
+   Raw value of time for output to be held high or low.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index af3e76d..343e784 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -70,6 +70,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_CCT] = cct,
[IIO_PRESSURE] = pressure,
[IIO_HUMIDITYRELATIVE] = humidityrelative,
+   [IIO_WAVEFORM] = waveform,
 };
 
 static const char * const iio_modifier_names[] = {
@@ -91,6 +92,8 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_NORTH_TRUE] = from_north_true,
[IIO_MOD_NORTH_MAGN_TILT_COMP] = from_north_magnetic_tilt_comp,
[IIO_MOD_NORTH_TRUE_TILT_COMP] = from_north_true_tilt_comp,
+   [IIO_MOD_HIGHTIME] = hightime,
+   [IIO_MOD_LOWTIME] = lowtime,
 };
 
 /* relies on pairs of these shared then separate */
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c 
b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 569d6f8..690f261 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -49,6 +49,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_CCT] = cct,
[IIO_PRESSURE] = pressure,
[IIO_HUMIDITYRELATIVE] = humidityrelative,
+   [IIO_WAVEFORM] = waveform,
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -108,6 +109,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_CCT:
case IIO_PRESSURE:
case IIO_HUMIDITYRELATIVE:
+   case IIO_WAVEFORM:
break;
default:
return false;
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 4a2af8a..d3b0af1 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -30,6 +30,7 @@ enum iio_chan_type {
IIO_CCT,
IIO_PRESSURE,
IIO_HUMIDITYRELATIVE,
+   IIO_WAVEFORM,
 };
 
 enum iio_modifier {
@@ -59,7 +60,9 @@ enum iio_modifier {
IIO_MOD_NORTH_MAGN,
IIO_MOD_NORTH_TRUE,
IIO_MOD_NORTH_MAGN_TILT_COMP,
-   IIO_MOD_NORTH_TRUE_TILT_COMP
+   IIO_MOD_NORTH_TRUE_TILT_COMP,
+   IIO_MOD_HIGHTIME,
+   IIO_MOD_LOWTIME,
 };
 
 enum iio_event_type {
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/2] of: Add vendor prefix for NovaTech LLC

2014-11-17 Thread George McCollister
For company details see:
http://www.novatechweb.com

Signed-off-by: George McCollister 
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 723999d..8f1462e 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -105,6 +105,7 @@ netgear NETGEAR
 newhaven   Newhaven Display International
 nintendo   Nintendo
 nokia  Nokia
+novatech   NovaTech LLC
 nvidia NVIDIA
 nxpNXP Semiconductors
 onnn   ON Semiconductor Corp.
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-17 Thread George McCollister
This adds the NovaTech OrionLXm which is based on the AM335x SoC
http://www.novatechweb.com/substation-automation/orionlxm/

RAM: 512MiB
Flash: 4GB eMMC
Ethernet PHYs: 2x Micrel KSZ8041FTLI
USB ports are used internally by the expansion cards.
Internal micro SD slot is available.

Signed-off-by: George McCollister 
---
 .../devicetree/bindings/arm/omap/omap.txt  |   3 +
 arch/arm/boot/dts/Makefile |   3 +-
 arch/arm/boot/dts/am335x-lxm.dts   | 362 +
 3 files changed, 367 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/am335x-lxm.dts

diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt 
b/Documentation/devicetree/bindings/arm/omap/omap.txt
index ddd9bcd..4f6a82c 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -132,6 +132,9 @@ Boards:
 - AM335X Bone : Low cost community board
   compatible = "ti,am335x-bone", "ti,am33xx", "ti,omap3"
 
+- AM335X OrionLXm : Substation Automation Platform
+  compatible = "novatech,am335x-lxm", "ti,am33xx"
+
 - OMAP5 EVM : Evaluation Module
   compatible = "ti,omap5-evm", "ti,omap5"
 
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 38c89ca..454ee6c 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -331,7 +331,8 @@ dtb-$(CONFIG_SOC_AM33XX) += am335x-base0033.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
am335x-nano.dtb \
-   am335x-pepper.dtb
+   am335x-pepper.dtb \
+   am335x-lxm.dtb
 dtb-$(CONFIG_ARCH_OMAP4) += omap4-duovero-parlor.dtb \
omap4-panda.dtb \
omap4-panda-a4.dtb \
diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
new file mode 100644
index 000..7266a00
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2014 NovaTech LLC - http://www.novatechweb.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+
+/ {
+   model = "NovaTech OrionLXm";
+   compatible = "novatech,am335x-lxm", "ti,am33xx";
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = <_reg>;
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x2000>; /* 512 MB */
+   };
+
+   /* Power supply provides a fixed 5V @2A */
+   vbat: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vbat";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-boot-on;
+   };
+
+   /* Power supply provides a fixed 3.3V @3A */
+   vmmcsd_fixed: fixedregulator@1 {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   };
+};
+
+_pinmux {
+   mmc1_pins: pinmux_mmc1_pins {
+   pinctrl-single,pins = <
+   0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
+   0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
+   0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
+   0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
+   0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
+   0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
+   >;
+   };
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = <
+   0x188 (PIN_INPUT | MUX_MODE0)   /* i2c0_sda.i2c0_sda */
+   0x18c (PIN_INPUT | MUX_MODE0)   /* i2c0_scl.i2c0_scl */
+   >;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = <
+   /* Slave 1 */
+   0x64 (PIN_INPUT_PULLDOWN | MUX_MODE7)   /* rmii1_int */
+   0x10c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_crs_dv 
*/
+   0x110 (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rxer */
+   0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_txen */
+   0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td1 */
+   0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td0 */
+   0x13c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rm

[PATCH v2 1/2] of: Add vendor prefix for NovaTech LLC

2014-11-17 Thread George McCollister
For company details see:
http://www.novatechweb.com

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 723999d..8f1462e 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -105,6 +105,7 @@ netgear NETGEAR
 newhaven   Newhaven Display International
 nintendo   Nintendo
 nokia  Nokia
+novatech   NovaTech LLC
 nvidia NVIDIA
 nxpNXP Semiconductors
 onnn   ON Semiconductor Corp.
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-17 Thread George McCollister
This adds the NovaTech OrionLXm which is based on the AM335x SoC
http://www.novatechweb.com/substation-automation/orionlxm/

RAM: 512MiB
Flash: 4GB eMMC
Ethernet PHYs: 2x Micrel KSZ8041FTLI
USB ports are used internally by the expansion cards.
Internal micro SD slot is available.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 .../devicetree/bindings/arm/omap/omap.txt  |   3 +
 arch/arm/boot/dts/Makefile |   3 +-
 arch/arm/boot/dts/am335x-lxm.dts   | 362 +
 3 files changed, 367 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/am335x-lxm.dts

diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt 
b/Documentation/devicetree/bindings/arm/omap/omap.txt
index ddd9bcd..4f6a82c 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -132,6 +132,9 @@ Boards:
 - AM335X Bone : Low cost community board
   compatible = ti,am335x-bone, ti,am33xx, ti,omap3
 
+- AM335X OrionLXm : Substation Automation Platform
+  compatible = novatech,am335x-lxm, ti,am33xx
+
 - OMAP5 EVM : Evaluation Module
   compatible = ti,omap5-evm, ti,omap5
 
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 38c89ca..454ee6c 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -331,7 +331,8 @@ dtb-$(CONFIG_SOC_AM33XX) += am335x-base0033.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
am335x-nano.dtb \
-   am335x-pepper.dtb
+   am335x-pepper.dtb \
+   am335x-lxm.dtb
 dtb-$(CONFIG_ARCH_OMAP4) += omap4-duovero-parlor.dtb \
omap4-panda.dtb \
omap4-panda-a4.dtb \
diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
new file mode 100644
index 000..7266a00
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2014 NovaTech LLC - http://www.novatechweb.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include am33xx.dtsi
+
+/ {
+   model = NovaTech OrionLXm;
+   compatible = novatech,am335x-lxm, ti,am33xx;
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = vdd1_reg;
+   };
+   };
+
+   memory {
+   device_type = memory;
+   reg = 0x8000 0x2000; /* 512 MB */
+   };
+
+   /* Power supply provides a fixed 5V @2A */
+   vbat: fixedregulator@0 {
+   compatible = regulator-fixed;
+   regulator-name = vbat;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   regulator-boot-on;
+   };
+
+   /* Power supply provides a fixed 3.3V @3A */
+   vmmcsd_fixed: fixedregulator@1 {
+   compatible = regulator-fixed;
+   regulator-name = vmmcsd_fixed;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   regulator-boot-on;
+   };
+};
+
+am33xx_pinmux {
+   mmc1_pins: pinmux_mmc1_pins {
+   pinctrl-single,pins = 
+   0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
+   0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
+   0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
+   0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
+   0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
+   0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
+   ;
+   };
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = 
+   0x188 (PIN_INPUT | MUX_MODE0)   /* i2c0_sda.i2c0_sda */
+   0x18c (PIN_INPUT | MUX_MODE0)   /* i2c0_scl.i2c0_scl */
+   ;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = 
+   /* Slave 1 */
+   0x64 (PIN_INPUT_PULLDOWN | MUX_MODE7)   /* rmii1_int */
+   0x10c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_crs_dv 
*/
+   0x110 (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rxer */
+   0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_txen */
+   0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td1 */
+   0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td0 */
+   0x13c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rd1 */
+   0x140 (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rd0 */
+   0x144 (PIN_INPUT_PULLDOWN | MUX_MODE0)  /* rmii1_refclk 
*/
+
+   /* Slave 2

Re: [PATCH 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-14 Thread George McCollister
Felipe,

Thank you for your reply.

>> + vbat: fixedregulator@0 {
>> + compatible = "regulator-fixed";
>> + regulator-name = "vbat";
>> + regulator-min-microvolt = <500>;
>> + regulator-max-microvolt = <500>;
>> + regulator-boot-on;
>> + };
>
> I suppose this is the 5V on a power jack, or something like that ?

It comes with one of three different power supplies (24 - 250VDC, 120
- 240VAC, 12VDC input) all of which ultimately supply a fixed 5V and
3.3V.

>
>> + vmmcsd_fixed: fixedregulator@0 {
>> + compatible = "regulator-fixed";
>> + regulator-name = "vmmcsd_fixed";
>> + regulator-min-microvolt = <330>;
>> + regulator-max-microvolt = <330>;
>
> but this... I know every other board devices this as a fixed regulator,
> but is it really a fixed regulator or is supplied by one of the LDOs on
> the PMIC ?
>

It's actually fixed (not from TP65910).

>> + };
>> +};
>> +
>> +_pinmux {
>> + mmc1_pins: pinmux_mmc1_pins {
>> + pinctrl-single,pins = <
>> + 0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
>> + 0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
>> + 0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
>> + 0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
>> + 0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
>> + 0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
>> + >;
>> + };
>> +
>> + i2c0_pins: pinmux_i2c0_pins {
>> + pinctrl-single,pins = <
>> + 0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* 
>> i2c0_sda.i2c0_sda */
>> + 0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* 
>> i2c0_scl.i2c0_scl */
>> + >;
>> + };
>> +
>> + i2c2_pins: pinmux_i2c2_pins {
>> + pinctrl-single,pins = <
>> + 0x178 (PIN_INPUT_PULLUP | MUX_MODE3)/* 
>> uart1_ctsn.i2c2_sda */
>> + 0x17c (PIN_INPUT_PULLUP | MUX_MODE3)/* 
>> uart1_rtsn.i2c2_scl */
>
> on thing to keep in mind, if you already have external pullups, you
> might not want to add internal pullups as you'd end up with both
> resistors in parallel. For I2C the danger is minimal (unless you have a
> ton of bus capacitance, then it changes high/low time), but it's best to
> write a more "pristine" DTS. (and sure, I know pretty much every board
> makes this mistake, but it's best if we don't proliferate the error)

I'll make sure this is correct and include any required changes in the
next version of the patch series.

>
>> + {
>> + pinctrl-names = "default";
>> + pinctrl-0 = <_pins>;
>> +
>> + status = "okay";
>> + clock-frequency = <40>;
>> +
>> + serial_config1: serial_config1@20 {
>> + compatible = "nxp,pca9539";
>> + reg = <0x20>;
>> + };
>> +
>> + serial_config2: serial_config2@21 {
>> + compatible = "nxp,pca9539";
>> + reg = <0x21>;
>> + };
>> +
>> + tps: tps@2d {
>> + reg = <0x2d>;
>
> which TPS device ? no compatible ?
>
>> +/include/ "tps65910.dtsi"
>
> oh... okay.

I'm assuming that means you're okay with this (if not please elaborate
on how to improve it).

>
>> + {
>> + vcc1-supply = <>;
>> + vcc2-supply = <>;
>> + vcc3-supply = <>;
>> + vcc4-supply = <>;
>> + vcc5-supply = <>;
>> + vcc6-supply = <>;
>> + vcc7-supply = <>;
>> + vccio-supply = <>;
>> +
>> + regulators {
>> + vrtc_reg: regulator@0 {
>> + regulator-always-on;
>
> this should not be always on, you want to pass this as supply to the RTC
> module so it can manage it. It's also best to give names to all
> regulators, so people know what they're used for.

I think we may actually be able to turn this one and possibly two
others off, I will investigate.

I've come up with names for all of the regulators being used and will
include the changes in the next version of the patch series.

>
>> + };
>> +
>> + vio_reg: regulator@1 {
>> + regulator-always-on;
>> + };
>> +
>> + vdd1_reg: regulator@2 {
>> + regulator-name = "vdd_mpu";
>> + regulator-min-microvolt = <60>;
>> + regulator-max-microvolt = <150>;
>> + regulator-boot-on;
>> + regulator-always-on;
>> + };
>> +
>> + vdd2_reg: regulator@3 {
>> + regulator-always-on;
>> + };
>> +
>> + vdd3_reg: regulator@4 {
>> + regulator-always-on;
>> + };
>> +
>> + vdig1_reg: regulator@5 {
>> + regulator-always-on;
>> + };
>> +
>> + 

Re: [PATCH 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-14 Thread George McCollister
Felipe,

Thank you for your reply.

 + vbat: fixedregulator@0 {
 + compatible = regulator-fixed;
 + regulator-name = vbat;
 + regulator-min-microvolt = 500;
 + regulator-max-microvolt = 500;
 + regulator-boot-on;
 + };

 I suppose this is the 5V on a power jack, or something like that ?

It comes with one of three different power supplies (24 - 250VDC, 120
- 240VAC, 12VDC input) all of which ultimately supply a fixed 5V and
3.3V.


 + vmmcsd_fixed: fixedregulator@0 {
 + compatible = regulator-fixed;
 + regulator-name = vmmcsd_fixed;
 + regulator-min-microvolt = 330;
 + regulator-max-microvolt = 330;

 but this... I know every other board devices this as a fixed regulator,
 but is it really a fixed regulator or is supplied by one of the LDOs on
 the PMIC ?


It's actually fixed (not from TP65910).

 + };
 +};
 +
 +am33xx_pinmux {
 + mmc1_pins: pinmux_mmc1_pins {
 + pinctrl-single,pins = 
 + 0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
 + 0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
 + 0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
 + 0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
 + 0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
 + 0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
 + ;
 + };
 +
 + i2c0_pins: pinmux_i2c0_pins {
 + pinctrl-single,pins = 
 + 0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* 
 i2c0_sda.i2c0_sda */
 + 0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* 
 i2c0_scl.i2c0_scl */
 + ;
 + };
 +
 + i2c2_pins: pinmux_i2c2_pins {
 + pinctrl-single,pins = 
 + 0x178 (PIN_INPUT_PULLUP | MUX_MODE3)/* 
 uart1_ctsn.i2c2_sda */
 + 0x17c (PIN_INPUT_PULLUP | MUX_MODE3)/* 
 uart1_rtsn.i2c2_scl */

 on thing to keep in mind, if you already have external pullups, you
 might not want to add internal pullups as you'd end up with both
 resistors in parallel. For I2C the danger is minimal (unless you have a
 ton of bus capacitance, then it changes high/low time), but it's best to
 write a more pristine DTS. (and sure, I know pretty much every board
 makes this mistake, but it's best if we don't proliferate the error)

I'll make sure this is correct and include any required changes in the
next version of the patch series.


 +i2c0 {
 + pinctrl-names = default;
 + pinctrl-0 = i2c0_pins;
 +
 + status = okay;
 + clock-frequency = 40;
 +
 + serial_config1: serial_config1@20 {
 + compatible = nxp,pca9539;
 + reg = 0x20;
 + };
 +
 + serial_config2: serial_config2@21 {
 + compatible = nxp,pca9539;
 + reg = 0x21;
 + };
 +
 + tps: tps@2d {
 + reg = 0x2d;

 which TPS device ? no compatible ?

 +/include/ tps65910.dtsi

 oh... okay.

I'm assuming that means you're okay with this (if not please elaborate
on how to improve it).


 +tps {
 + vcc1-supply = vbat;
 + vcc2-supply = vbat;
 + vcc3-supply = vbat;
 + vcc4-supply = vbat;
 + vcc5-supply = vbat;
 + vcc6-supply = vbat;
 + vcc7-supply = vbat;
 + vccio-supply = vbat;
 +
 + regulators {
 + vrtc_reg: regulator@0 {
 + regulator-always-on;

 this should not be always on, you want to pass this as supply to the RTC
 module so it can manage it. It's also best to give names to all
 regulators, so people know what they're used for.

I think we may actually be able to turn this one and possibly two
others off, I will investigate.

I've come up with names for all of the regulators being used and will
include the changes in the next version of the patch series.


 + };
 +
 + vio_reg: regulator@1 {
 + regulator-always-on;
 + };
 +
 + vdd1_reg: regulator@2 {
 + regulator-name = vdd_mpu;
 + regulator-min-microvolt = 60;
 + regulator-max-microvolt = 150;
 + regulator-boot-on;
 + regulator-always-on;
 + };
 +
 + vdd2_reg: regulator@3 {
 + regulator-always-on;
 + };
 +
 + vdd3_reg: regulator@4 {
 + regulator-always-on;
 + };
 +
 + vdig1_reg: regulator@5 {
 + regulator-always-on;
 + };
 +
 + vdig2_reg: regulator@6 {
 + regulator-always-on;
 + };
 +
 + vpll_reg: regulator@7 {
 + regulator-always-on;
 + };
 +
 + vdac_reg: regulator@8 {
 +   

[PATCH 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-12 Thread George McCollister
This adds the NovaTech OrionLXm which is based on the AM335x SoC
http://www.novatechweb.com/substation-automation/orionlxm/

RAM: 512MiB
Flash: 4GB eMMC
Ethernet PHYs: 2x Micrel KSZ8041FTLI
USB ports are used internally by the expansion cards.
Internal micro SD slot is available.

Signed-off-by: George McCollister 
---
 .../devicetree/bindings/arm/omap/omap.txt  |   3 +
 arch/arm/boot/dts/Makefile |   3 +-
 arch/arm/boot/dts/am335x-lxm.dts   | 354 +
 3 files changed, 359 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/am335x-lxm.dts

diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt 
b/Documentation/devicetree/bindings/arm/omap/omap.txt
index ddd9bcd..4f6a82c 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -132,6 +132,9 @@ Boards:
 - AM335X Bone : Low cost community board
   compatible = "ti,am335x-bone", "ti,am33xx", "ti,omap3"
 
+- AM335X OrionLXm : Substation Automation Platform
+  compatible = "novatech,am335x-lxm", "ti,am33xx"
+
 - OMAP5 EVM : Evaluation Module
   compatible = "ti,omap5-evm", "ti,omap5"
 
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 38c89ca..454ee6c 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -331,7 +331,8 @@ dtb-$(CONFIG_SOC_AM33XX) += am335x-base0033.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
am335x-nano.dtb \
-   am335x-pepper.dtb
+   am335x-pepper.dtb \
+   am335x-lxm.dtb
 dtb-$(CONFIG_ARCH_OMAP4) += omap4-duovero-parlor.dtb \
omap4-panda.dtb \
omap4-panda-a4.dtb \
diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
new file mode 100644
index 000..0f7cbae
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -0,0 +1,354 @@
+/*
+ * Copyright (C) 2014 NovaTech LLC - http://www.novatechweb.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+
+/ {
+   model = "NovaTech OrionLXm";
+   compatible = "novatech,am335x-lxm", "ti,am33xx";
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = <_reg>;
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x2000>; /* 512 MB */
+   };
+
+   vbat: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vbat";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-boot-on;
+   };
+
+   vmmcsd_fixed: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+_pinmux {
+   mmc1_pins: pinmux_mmc1_pins {
+   pinctrl-single,pins = <
+   0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
+   0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
+   0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
+   0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
+   0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
+   0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
+   >;
+   };
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = <
+   0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_sda.i2c0_sda */
+   0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_scl.i2c0_scl */
+   >;
+   };
+
+   i2c2_pins: pinmux_i2c2_pins {
+   pinctrl-single,pins = <
+   0x178 (PIN_INPUT_PULLUP | MUX_MODE3)/* 
uart1_ctsn.i2c2_sda */
+   0x17c (PIN_INPUT_PULLUP | MUX_MODE3)/* 
uart1_rtsn.i2c2_scl */
+   >;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = <
+   /* Slave 1 */
+   0x64 (PIN_INPUT_PULLDOWN | MUX_MODE7)   /* rmii1_int */
+   0x10c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_crs_dv 
*/
+   0x110 (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rxer */
+   0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_txen */
+   0x124 (PIN_OUTPUT_PULLDOWN |

[PATCH 1/2] of: Add vendor prefix for NovaTech LLC

2014-11-12 Thread George McCollister
For company details see:
http://www.novatechweb.com

Signed-off-by: George McCollister 
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 723999d..8f1462e 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -105,6 +105,7 @@ netgear NETGEAR
 newhaven   Newhaven Display International
 nintendo   Nintendo
 nokia  Nokia
+novatech   NovaTech LLC
 nvidia NVIDIA
 nxpNXP Semiconductors
 onnn   ON Semiconductor Corp.
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] of: Add vendor prefix for NovaTech LLC

2014-11-12 Thread George McCollister
For company details see:
http://www.novatechweb.com

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 723999d..8f1462e 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -105,6 +105,7 @@ netgear NETGEAR
 newhaven   Newhaven Display International
 nintendo   Nintendo
 nokia  Nokia
+novatech   NovaTech LLC
 nvidia NVIDIA
 nxpNXP Semiconductors
 onnn   ON Semiconductor Corp.
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] ARM: dts: Add devicetree for NovaTech OrionLXm

2014-11-12 Thread George McCollister
This adds the NovaTech OrionLXm which is based on the AM335x SoC
http://www.novatechweb.com/substation-automation/orionlxm/

RAM: 512MiB
Flash: 4GB eMMC
Ethernet PHYs: 2x Micrel KSZ8041FTLI
USB ports are used internally by the expansion cards.
Internal micro SD slot is available.

Signed-off-by: George McCollister george.mccollis...@gmail.com
---
 .../devicetree/bindings/arm/omap/omap.txt  |   3 +
 arch/arm/boot/dts/Makefile |   3 +-
 arch/arm/boot/dts/am335x-lxm.dts   | 354 +
 3 files changed, 359 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/am335x-lxm.dts

diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt 
b/Documentation/devicetree/bindings/arm/omap/omap.txt
index ddd9bcd..4f6a82c 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -132,6 +132,9 @@ Boards:
 - AM335X Bone : Low cost community board
   compatible = ti,am335x-bone, ti,am33xx, ti,omap3
 
+- AM335X OrionLXm : Substation Automation Platform
+  compatible = novatech,am335x-lxm, ti,am33xx
+
 - OMAP5 EVM : Evaluation Module
   compatible = ti,omap5-evm, ti,omap5
 
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 38c89ca..454ee6c 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -331,7 +331,8 @@ dtb-$(CONFIG_SOC_AM33XX) += am335x-base0033.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
am335x-nano.dtb \
-   am335x-pepper.dtb
+   am335x-pepper.dtb \
+   am335x-lxm.dtb
 dtb-$(CONFIG_ARCH_OMAP4) += omap4-duovero-parlor.dtb \
omap4-panda.dtb \
omap4-panda-a4.dtb \
diff --git a/arch/arm/boot/dts/am335x-lxm.dts b/arch/arm/boot/dts/am335x-lxm.dts
new file mode 100644
index 000..0f7cbae
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-lxm.dts
@@ -0,0 +1,354 @@
+/*
+ * Copyright (C) 2014 NovaTech LLC - http://www.novatechweb.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/dts-v1/;
+
+#include am33xx.dtsi
+
+/ {
+   model = NovaTech OrionLXm;
+   compatible = novatech,am335x-lxm, ti,am33xx;
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = vdd1_reg;
+   };
+   };
+
+   memory {
+   device_type = memory;
+   reg = 0x8000 0x2000; /* 512 MB */
+   };
+
+   vbat: fixedregulator@0 {
+   compatible = regulator-fixed;
+   regulator-name = vbat;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   regulator-boot-on;
+   };
+
+   vmmcsd_fixed: fixedregulator@0 {
+   compatible = regulator-fixed;
+   regulator-name = vmmcsd_fixed;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   };
+};
+
+am33xx_pinmux {
+   mmc1_pins: pinmux_mmc1_pins {
+   pinctrl-single,pins = 
+   0xf0 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat3 */
+   0xf4 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat2 */
+   0xf8 (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat1 */
+   0xfc (PIN_INPUT_PULLUP | MUX_MODE0) /* mmc0_dat0 */
+   0x100 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_clk */
+   0x104 (PIN_INPUT_PULLUP | MUX_MODE0)/* mmc0_cmd */
+   ;
+   };
+
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = 
+   0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_sda.i2c0_sda */
+   0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_scl.i2c0_scl */
+   ;
+   };
+
+   i2c2_pins: pinmux_i2c2_pins {
+   pinctrl-single,pins = 
+   0x178 (PIN_INPUT_PULLUP | MUX_MODE3)/* 
uart1_ctsn.i2c2_sda */
+   0x17c (PIN_INPUT_PULLUP | MUX_MODE3)/* 
uart1_rtsn.i2c2_scl */
+   ;
+   };
+
+   cpsw_default: cpsw_default {
+   pinctrl-single,pins = 
+   /* Slave 1 */
+   0x64 (PIN_INPUT_PULLDOWN | MUX_MODE7)   /* rmii1_int */
+   0x10c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_crs_dv 
*/
+   0x110 (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rxer */
+   0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_txen */
+   0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td1 */
+   0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* rmii1_td0 */
+   0x13c (PIN_INPUT_PULLDOWN | MUX_MODE1)  /* rmii1_rd1 */
+   0x140 (PIN_INPUT_PULLDOWN

[tip:sched/urgent] sched: Fix double normalization of vruntime

2014-02-27 Thread tip-bot for George McCollister
Commit-ID:  791c9e0292671a3bfa95286bb5c08129d8605618
Gitweb: http://git.kernel.org/tip/791c9e0292671a3bfa95286bb5c08129d8605618
Author: George McCollister 
AuthorDate: Tue, 18 Feb 2014 17:56:51 -0600
Committer:  Ingo Molnar 
CommitDate: Thu, 27 Feb 2014 12:29:38 +0100

sched: Fix double normalization of vruntime

dequeue_entity() is called when p->on_rq and sets se->on_rq = 0
which appears to guarentee that the !se->on_rq condition is met.
If the task has done set_current_state(TASK_INTERRUPTIBLE) without
schedule() the second condition will be met and vruntime will be
incorrectly adjusted twice.

In certain cases this can result in the task's vruntime never increasing
past the vruntime of other tasks on the CFS' run queue, starving them of
CPU time.

This patch changes switched_from_fair() to use !p->on_rq instead of
!se->on_rq.

I'm able to cause a task with a priority of 120 to starve all other
tasks with the same priority on an ARM platform running 3.2.51-rt72
PREEMPT RT by writing one character at time to a serial tty (16550 UART)
in a tight loop. I'm also able to verify making this change corrects the
problem on that platform and kernel version.

Signed-off-by: George McCollister 
Signed-off-by: Peter Zijlstra 
Cc: sta...@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1392767811-28916-1-git-send-email-george.mccollis...@gmail.com
Signed-off-by: Ingo Molnar 
---
 kernel/sched/fair.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7815709..9b4c4f3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7001,15 +7001,15 @@ static void switched_from_fair(struct rq *rq, struct 
task_struct *p)
struct cfs_rq *cfs_rq = cfs_rq_of(se);
 
/*
-* Ensure the task's vruntime is normalized, so that when its
+* Ensure the task's vruntime is normalized, so that when it's
 * switched back to the fair class the enqueue_entity(.flags=0) will
 * do the right thing.
 *
-* If it was on_rq, then the dequeue_entity(.flags=0) will already
-* have normalized the vruntime, if it was !on_rq, then only when
+* If it's on_rq, then the dequeue_entity(.flags=0) will already
+* have normalized the vruntime, if it's !on_rq, then only when
 * the task is sleeping will it still have non-normalized vruntime.
 */
-   if (!se->on_rq && p->state != TASK_RUNNING) {
+   if (!p->on_rq && p->state != TASK_RUNNING) {
/*
 * Fix up our vruntime so that the current sleep doesn't
 * cause 'unlimited' sleep bonus.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:sched/urgent] sched: Fix double normalization of vruntime

2014-02-27 Thread tip-bot for George McCollister
Commit-ID:  791c9e0292671a3bfa95286bb5c08129d8605618
Gitweb: http://git.kernel.org/tip/791c9e0292671a3bfa95286bb5c08129d8605618
Author: George McCollister george.mccollis...@gmail.com
AuthorDate: Tue, 18 Feb 2014 17:56:51 -0600
Committer:  Ingo Molnar mi...@kernel.org
CommitDate: Thu, 27 Feb 2014 12:29:38 +0100

sched: Fix double normalization of vruntime

dequeue_entity() is called when p-on_rq and sets se-on_rq = 0
which appears to guarentee that the !se-on_rq condition is met.
If the task has done set_current_state(TASK_INTERRUPTIBLE) without
schedule() the second condition will be met and vruntime will be
incorrectly adjusted twice.

In certain cases this can result in the task's vruntime never increasing
past the vruntime of other tasks on the CFS' run queue, starving them of
CPU time.

This patch changes switched_from_fair() to use !p-on_rq instead of
!se-on_rq.

I'm able to cause a task with a priority of 120 to starve all other
tasks with the same priority on an ARM platform running 3.2.51-rt72
PREEMPT RT by writing one character at time to a serial tty (16550 UART)
in a tight loop. I'm also able to verify making this change corrects the
problem on that platform and kernel version.

Signed-off-by: George McCollister george.mccollis...@gmail.com
Signed-off-by: Peter Zijlstra pet...@infradead.org
Cc: sta...@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1392767811-28916-1-git-send-email-george.mccollis...@gmail.com
Signed-off-by: Ingo Molnar mi...@kernel.org
---
 kernel/sched/fair.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7815709..9b4c4f3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7001,15 +7001,15 @@ static void switched_from_fair(struct rq *rq, struct 
task_struct *p)
struct cfs_rq *cfs_rq = cfs_rq_of(se);
 
/*
-* Ensure the task's vruntime is normalized, so that when its
+* Ensure the task's vruntime is normalized, so that when it's
 * switched back to the fair class the enqueue_entity(.flags=0) will
 * do the right thing.
 *
-* If it was on_rq, then the dequeue_entity(.flags=0) will already
-* have normalized the vruntime, if it was !on_rq, then only when
+* If it's on_rq, then the dequeue_entity(.flags=0) will already
+* have normalized the vruntime, if it's !on_rq, then only when
 * the task is sleeping will it still have non-normalized vruntime.
 */
-   if (!se-on_rq  p-state != TASK_RUNNING) {
+   if (!p-on_rq  p-state != TASK_RUNNING) {
/*
 * Fix up our vruntime so that the current sleep doesn't
 * cause 'unlimited' sleep bonus.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] sched: fix double normalization of vruntime

2014-02-26 Thread George McCollister
On Wed, Feb 26, 2014 at 7:28 AM, Peter Zijlstra  wrote:
> On Tue, Feb 18, 2014 at 05:56:51PM -0600, George McCollister wrote:
>> dequeue_entity() is called when p->on_rq and sets se->on_rq = 0
>> which appears to guarentee that the !se->on_rq condition is met.
>> If the task has done set_current_state(TASK_INTERRUPTIBLE) without
>> schedule() the second condition will be met and vruntime will be
>> incorrectly adjusted twice.
>>
>> In certain cases this can result in the task's vruntime never increasing
>> past the vruntime of other tasks on the CFS' run queue, starving them of
>> CPU time.
>>
>> This patch changes switched_from_fair() to use !p->on_rq instead of
>> !se->on_rq.
>>
>> I'm able to cause a task with a priority of 120 to starve all other
>> tasks with the same priority on an ARM platform running 3.2.51-rt72
>> PREEMPT RT by writing one character at time to a serial tty (16550 UART)
>> in a tight loop. I'm also able to verify making this change corrects the
>> problem on that platform and kernel version.
>>
>> I haven't and not sure I will have an opportunity to get a newer kernel
>> version running on the platform mentioned above and have yet to
>> reproduce the problem on another platform.
>
> Yes, I think you're quite right. Another way to look at this is that
> p->on_rq is the one matching p->state.
Yes, correct

>
> Can I have (or add) your Signed-off-by for this patch?

Go ahead and add my sign off. I didn't want to add it before
discussing the issue with someone.

Thanks,
George McCollister
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] sched: fix double normalization of vruntime

2014-02-26 Thread George McCollister
On Wed, Feb 26, 2014 at 7:28 AM, Peter Zijlstra pet...@infradead.org wrote:
 On Tue, Feb 18, 2014 at 05:56:51PM -0600, George McCollister wrote:
 dequeue_entity() is called when p-on_rq and sets se-on_rq = 0
 which appears to guarentee that the !se-on_rq condition is met.
 If the task has done set_current_state(TASK_INTERRUPTIBLE) without
 schedule() the second condition will be met and vruntime will be
 incorrectly adjusted twice.

 In certain cases this can result in the task's vruntime never increasing
 past the vruntime of other tasks on the CFS' run queue, starving them of
 CPU time.

 This patch changes switched_from_fair() to use !p-on_rq instead of
 !se-on_rq.

 I'm able to cause a task with a priority of 120 to starve all other
 tasks with the same priority on an ARM platform running 3.2.51-rt72
 PREEMPT RT by writing one character at time to a serial tty (16550 UART)
 in a tight loop. I'm also able to verify making this change corrects the
 problem on that platform and kernel version.

 I haven't and not sure I will have an opportunity to get a newer kernel
 version running on the platform mentioned above and have yet to
 reproduce the problem on another platform.

 Yes, I think you're quite right. Another way to look at this is that
 p-on_rq is the one matching p-state.
Yes, correct


 Can I have (or add) your Signed-off-by for this patch?

Go ahead and add my sign off. I didn't want to add it before
discussing the issue with someone.

Thanks,
George McCollister
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched: fix double normalization of vruntime

2014-02-18 Thread George McCollister
dequeue_entity() is called when p->on_rq and sets se->on_rq = 0
which appears to guarentee that the !se->on_rq condition is met.
If the task has done set_current_state(TASK_INTERRUPTIBLE) without
schedule() the second condition will be met and vruntime will be
incorrectly adjusted twice.

In certain cases this can result in the task's vruntime never increasing
past the vruntime of other tasks on the CFS' run queue, starving them of
CPU time.

This patch changes switched_from_fair() to use !p->on_rq instead of
!se->on_rq.

I'm able to cause a task with a priority of 120 to starve all other
tasks with the same priority on an ARM platform running 3.2.51-rt72
PREEMPT RT by writing one character at time to a serial tty (16550 UART)
in a tight loop. I'm also able to verify making this change corrects the
problem on that platform and kernel version.

I haven't and not sure I will have an opportunity to get a newer kernel
version running on the platform mentioned above and have yet to
reproduce the problem on another platform.
---
 kernel/sched/fair.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 966cc2b..fa1c6df 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6999,15 +6999,15 @@ static void switched_from_fair(struct rq *rq, struct 
task_struct *p)
struct cfs_rq *cfs_rq = cfs_rq_of(se);
 
/*
-* Ensure the task's vruntime is normalized, so that when its
+* Ensure the task's vruntime is normalized, so that when it's
 * switched back to the fair class the enqueue_entity(.flags=0) will
 * do the right thing.
 *
-* If it was on_rq, then the dequeue_entity(.flags=0) will already
-* have normalized the vruntime, if it was !on_rq, then only when
+* If it's on_rq, then the dequeue_entity(.flags=0) will already
+* have normalized the vruntime, if it's !on_rq, then only when
 * the task is sleeping will it still have non-normalized vruntime.
 */
-   if (!se->on_rq && p->state != TASK_RUNNING) {
+   if (!p->on_rq && p->state != TASK_RUNNING) {
/*
 * Fix up our vruntime so that the current sleep doesn't
 * cause 'unlimited' sleep bonus.
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched: fix double normalization of vruntime

2014-02-18 Thread George McCollister
dequeue_entity() is called when p-on_rq and sets se-on_rq = 0
which appears to guarentee that the !se-on_rq condition is met.
If the task has done set_current_state(TASK_INTERRUPTIBLE) without
schedule() the second condition will be met and vruntime will be
incorrectly adjusted twice.

In certain cases this can result in the task's vruntime never increasing
past the vruntime of other tasks on the CFS' run queue, starving them of
CPU time.

This patch changes switched_from_fair() to use !p-on_rq instead of
!se-on_rq.

I'm able to cause a task with a priority of 120 to starve all other
tasks with the same priority on an ARM platform running 3.2.51-rt72
PREEMPT RT by writing one character at time to a serial tty (16550 UART)
in a tight loop. I'm also able to verify making this change corrects the
problem on that platform and kernel version.

I haven't and not sure I will have an opportunity to get a newer kernel
version running on the platform mentioned above and have yet to
reproduce the problem on another platform.
---
 kernel/sched/fair.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 966cc2b..fa1c6df 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6999,15 +6999,15 @@ static void switched_from_fair(struct rq *rq, struct 
task_struct *p)
struct cfs_rq *cfs_rq = cfs_rq_of(se);
 
/*
-* Ensure the task's vruntime is normalized, so that when its
+* Ensure the task's vruntime is normalized, so that when it's
 * switched back to the fair class the enqueue_entity(.flags=0) will
 * do the right thing.
 *
-* If it was on_rq, then the dequeue_entity(.flags=0) will already
-* have normalized the vruntime, if it was !on_rq, then only when
+* If it's on_rq, then the dequeue_entity(.flags=0) will already
+* have normalized the vruntime, if it's !on_rq, then only when
 * the task is sleeping will it still have non-normalized vruntime.
 */
-   if (!se-on_rq  p-state != TASK_RUNNING) {
+   if (!p-on_rq  p-state != TASK_RUNNING) {
/*
 * Fix up our vruntime so that the current sleep doesn't
 * cause 'unlimited' sleep bonus.
-- 
1.8.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


setserial -> serial_core / 8250 interaction

2007-07-18 Thread George McCollister
I've recently found (using 2.6.21.4) that configuring a serial ports
(ST16654) which use the 8250 driver using setserial results in the
UART's FIFOs being disabled (unless you specify autoconfig).

The problem is that setserial doesn't fill out xmit_fifo_size when
calling TIOCSSERIAL to set the port type. There doesn't appear to be any
provision to set the port type and have 8250 use the default fifo_size
value for the selected FIFO from uart_config.

The result is that fifo_size remains 0 and the fifo is disabled. So, I
believe that anyone using setserial to configure a serial port (unless
autoconfig is used) will have very poor serial port performance (I did,
thats how I ran across this).

I haven't been able to think of a cure all solution without introducing
some pretty nasty changes. You could argue that setserial should set
xmit_fifo_size, but it seems unnecessary to require a user level program
to have knowledge of the FIFO sizes for all of the different UARTS. I'm
going to change my copy of 8250.c to always use fifo_size from
uart_config, but some people may not find this acceptable.

Maybe I'm missing something here, but I wanted to bring it up in case
its actually affecting other people.

I'm not subscribed to the list so if you reply please CC to my address.

Regards,
George McCollister


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete
the original.  Any other use of the email by you is prohibited.


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete
the original.  Any other use of the email by you is prohibited.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


setserial - serial_core / 8250 interaction

2007-07-18 Thread George McCollister
I've recently found (using 2.6.21.4) that configuring a serial ports
(ST16654) which use the 8250 driver using setserial results in the
UART's FIFOs being disabled (unless you specify autoconfig).

The problem is that setserial doesn't fill out xmit_fifo_size when
calling TIOCSSERIAL to set the port type. There doesn't appear to be any
provision to set the port type and have 8250 use the default fifo_size
value for the selected FIFO from uart_config.

The result is that fifo_size remains 0 and the fifo is disabled. So, I
believe that anyone using setserial to configure a serial port (unless
autoconfig is used) will have very poor serial port performance (I did,
thats how I ran across this).

I haven't been able to think of a cure all solution without introducing
some pretty nasty changes. You could argue that setserial should set
xmit_fifo_size, but it seems unnecessary to require a user level program
to have knowledge of the FIFO sizes for all of the different UARTS. I'm
going to change my copy of 8250.c to always use fifo_size from
uart_config, but some people may not find this acceptable.

Maybe I'm missing something here, but I wanted to bring it up in case
its actually affecting other people.

I'm not subscribed to the list so if you reply please CC to my address.

Regards,
George McCollister


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete
the original.  Any other use of the email by you is prohibited.


This message is for the designated recipient only and may contain
privileged, proprietary, or otherwise private information.  If you have
received it in error, please notify the sender immediately and delete
the original.  Any other use of the email by you is prohibited.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/