Steven Miao | 12 Jul 12:21 2013
Picon

net: fix kernel 3.10 update

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2a8213b5e9f5e6057e42e3f991636bc9ff287f22 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Steven Miao <realmz6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- include/linux/kernel.h | 14 ++++++-------- net/core/netpoll.c | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index e9ef6d6..3bef14c 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h <at> <at> -193,13 +193,10 <at> <at> extern int _cond_resched(void); (__x < 0) ? -__x : __x; \ }) -#ifdef CONFIG_PROVE_LOCKING +#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) void might_fault(void); #else -static inline void might_fault(void) -{ - might_sleep(); -} +static inline void might_fault(void) { } #endif extern struct atomic_notifier_head panic_notifier_list; <at> <at> -450,6 +447,8 <at> <at> static inline char * __deprecated pack_hex_byte(char *buf, u8 byte) extern int hex_to_bin(char ch); extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); +int mac_pton(const char *s, u8 *mac); + /* * General tracing related utility functions - trace_printk(), * tracing_on/tracing_off and tracing_start()/tracing_stop <at> <at> -562,9 +561,6 <at> <at> int __trace_bprintk(unsigned long ip, const char *fmt, ...); extern __printf(2, 3) int __trace_printk(unsigned long ip, const char *fmt, ...); -extern int __trace_bputs(unsigned long ip, const char *str); -extern int __trace_puts(unsigned long ip, const char *str, int size); - /** * trace_puts - write a string into the ftrace buffer * <at> str: the string to record <at> <at> -600,6 +596,8 <at> <at> extern int __trace_puts(unsigned long ip, const char *str, int size); else \ __trace_puts(_THIS_IP_, str, strlen(str)); \ }) +extern int __trace_bputs(unsigned long ip, const char *str); +extern int __trace_puts(unsigned long ip, const char *str, int size); extern void trace_dump_stack(int skip); diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 66b79e4..28949d2 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c <at> <at> -12,6 +12,7 <at> <at> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/moduleparam.h> +#include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/string.h>
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2a8213b5e9f5e6057e42e3f991636bc9ff287f22
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Steven Miao &lt;realmz6@...&gt;
---
 include/linux/kernel.h |   14 ++++++--------
 net/core/netpoll.c     |    1 +
 2 files changed, 7 insertions(+), 8 deletions(-)

<span>diff --git a/include/linux/kernel.h b/include/linux/kernel.h</span>
<span>index e9ef6d6..3bef14c 100644</span>
<span>--- a/include/linux/kernel.h</span>
<span>+++ b/include/linux/kernel.h</span>
<span> <at>  <at>  -193,13 +193,10  <at>  <at>  extern int _cond_resched(void);</span>
 		(__x &lt; 0) ? -__x : __x;		\
 	})

<span>-#ifdef CONFIG_PROVE_LOCKING</span>
<span>+#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)</span>
 void might_fault(void);
 #else
<span>-static inline void might_fault(void)</span>
<span>-{</span>
<span>-	might_sleep();</span>
<span>-}</span>
<span>+static inline void might_fault(void) { }</span>
 #endif

 extern struct atomic_notifier_head panic_notifier_list;
<span> <at>  <at>  -450,6 +447,8  <at>  <at>  static inline char * __deprecated pack_hex_byte(char *buf, u8 byte)</span>
 extern int hex_to_bin(char ch);
 extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);

<span>+int mac_pton(const char *s, u8 *mac);</span>
<span>+</span>
 /*
  * General tracing related utility functions - trace_printk(),
  * tracing_on/tracing_off and tracing_start()/tracing_stop
<span> <at>  <at>  -562,9 +561,6  <at>  <at>  int __trace_bprintk(unsigned long ip, const char *fmt, ...);</span>
 extern __printf(2, 3)
 int __trace_printk(unsigned long ip, const char *fmt, ...);

<span>-extern int __trace_bputs(unsigned long ip, const char *str);</span>
<span>-extern int __trace_puts(unsigned long ip, const char *str, int size);</span>
<span>-</span>
 /**
  * trace_puts - write a string into the ftrace buffer
  *  <at> str: the string to record
<span> <at>  <at>  -600,6 +596,8  <at>  <at>  extern int __trace_puts(unsigned long ip, const char *str, int size);</span>
 	else								\
 		__trace_puts(_THIS_IP_, str, strlen(str));		\
 })
<span>+extern int __trace_bputs(unsigned long ip, const char *str);</span>
<span>+extern int __trace_puts(unsigned long ip, const char *str, int size);</span>

 extern void trace_dump_stack(int skip);

<span>diff --git a/net/core/netpoll.c b/net/core/netpoll.c</span>
<span>index 66b79e4..28949d2 100644</span>
<span>--- a/net/core/netpoll.c</span>
<span>+++ b/net/core/netpoll.c</span>
<span> <at>  <at>  -12,6 +12,7  <at>  <at> </span>
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

 #include &lt;linux/moduleparam.h&gt;
<span>+#include &lt;linux/kernel.h&gt;</span>
 #include &lt;linux/netdevice.h&gt;
 #include &lt;linux/etherdevice.h&gt;
 #include &lt;linux/string.h&gt;
</div>
Scott Jiang | 9 Jul 02:25 2013
Picon

[#7707] musb: we should not reset endpoint data toggle on bf527

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2c170453dffdb021018856633b8ead5653833567 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/usb/musb/musb_host.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 9d3044b..ba7fd5e 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c <at> <at> -587,7 +587,10 <at> <at> musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep) WARNING("rx%d, packet/%d ready?\n", ep->epnum, musb_readw(ep->regs, MUSB_RXCOUNT)); - musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG); + if (csr & MUSB_TXCSR_MODE) + musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG); + else + musb_h_flush_rxfifo(ep, 0); } /* target addr and (for multipoint) hub addr/port */ <at> <at> -783,7 +786,7 <at> <at> static void musb_ep_program(struct musb *musb, u8 epnum, if (usb_gettoggle(urb->dev, qh->epnum, 1)) csr |= MUSB_TXCSR_H_WR_DATATOGGLE | MUSB_TXCSR_H_DATATOGGLE; - else + else if (csr & MUSB_TXCSR_MODE) csr |= MUSB_TXCSR_CLRDATATOG; }
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2c170453dffdb021018856633b8ead5653833567
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Scott Jiang &lt;scott.jiang.linux@...&gt;
---
 drivers/usb/musb/musb_host.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

<span>diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c</span>
<span>index 9d3044b..ba7fd5e 100644</span>
<span>--- a/drivers/usb/musb/musb_host.c</span>
<span>+++ b/drivers/usb/musb/musb_host.c</span>
<span> <at>  <at>  -587,7 +587,10  <at>  <at>  musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)</span>
 			WARNING("rx%d, packet/%d ready?\n", ep-&gt;epnum,
 				musb_readw(ep-&gt;regs, MUSB_RXCOUNT));

<span>-		musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG);</span>
<span>+		if (csr &amp; MUSB_TXCSR_MODE)</span>
<span>+			musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG);</span>
<span>+		else</span>
<span>+			musb_h_flush_rxfifo(ep, 0);</span>
 	}

 	/* target addr and (for multipoint) hub addr/port */
<span> <at>  <at>  -783,7 +786,7  <at>  <at>  static void musb_ep_program(struct musb *musb, u8 epnum,</span>
 				if (usb_gettoggle(urb-&gt;dev, qh-&gt;epnum, 1))
 					csr |= MUSB_TXCSR_H_WR_DATATOGGLE
 						| MUSB_TXCSR_H_DATATOGGLE;
<span>-				else</span>
<span>+				else if (csr &amp; MUSB_TXCSR_MODE)</span>
 					csr |= MUSB_TXCSR_CLRDATATOG;
 			}

</div>
Steven Miao | 8 Jul 12:05 2013
Picon

fs: load flat file: fix full data length after update to 3.10

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2711af8014e901e0c8ad26744076fd90011a3c0c branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Steven Miao <realmz6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- fs/binfmt_flat.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index dd913db..f855c9d 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c <at> <at> -446,16 +446,16 <at> <at> static int load_flat_file(struct linux_binprm * bprm, hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */ inode = file_inode(bprm->file); - relocs = ntohl(hdr->reloc_count); - flags = ntohl(hdr->flags); - rev = ntohl(hdr->rev); - full_data = data_len + relocs * sizeof(unsigned long); - text_len = ntohl(hdr->data_start); data_len = ntohl(hdr->data_end) - ntohl(hdr->data_start); bss_len = ntohl(hdr->bss_end) - ntohl(hdr->data_end); stack_len = ntohl(hdr->stack_size); + relocs = ntohl(hdr->reloc_count); + flags = ntohl(hdr->flags); + rev = ntohl(hdr->rev); + full_data = data_len + relocs * sizeof(unsigned long); + if (flags & FLAT_FLAG_L1STK) { #ifdef CONFIG_SMP flags &= ~FLAT_FLAG_L1STK;
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=2711af8014e901e0c8ad26744076fd90011a3c0c
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Steven Miao &lt;realmz6@...&gt;
---
 fs/binfmt_flat.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

<span>diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c</span>
<span>index dd913db..f855c9d 100644</span>
<span>--- a/fs/binfmt_flat.c</span>
<span>+++ b/fs/binfmt_flat.c</span>
<span> <at>  <at>  -446,16 +446,16  <at>  <at>  static int load_flat_file(struct linux_binprm * bprm,</span>
 	hdr = ((struct flat_hdr *) bprm-&gt;buf);		/* exec-header */
 	inode = file_inode(bprm-&gt;file);

<span>-	relocs    = ntohl(hdr-&gt;reloc_count);</span>
<span>-	flags     = ntohl(hdr-&gt;flags);</span>
<span>-	rev       = ntohl(hdr-&gt;rev);</span>
<span>-	full_data = data_len + relocs * sizeof(unsigned long);</span>
<span>-</span>
 	text_len  = ntohl(hdr-&gt;data_start);
 	data_len  = ntohl(hdr-&gt;data_end) - ntohl(hdr-&gt;data_start);
 	bss_len   = ntohl(hdr-&gt;bss_end) - ntohl(hdr-&gt;data_end);
 	stack_len = ntohl(hdr-&gt;stack_size);

<span>+	relocs    = ntohl(hdr-&gt;reloc_count);</span>
<span>+	flags     = ntohl(hdr-&gt;flags);</span>
<span>+	rev       = ntohl(hdr-&gt;rev);</span>
<span>+	full_data = data_len + relocs * sizeof(unsigned long);</span>
<span>+</span>
 	if (flags &amp; FLAT_FLAG_L1STK) {
 #ifdef CONFIG_SMP
 		flags &amp;= ~FLAT_FLAG_L1STK;
</div>
Steven Miao | 5 Jul 08:36 2013
Picon

clock: add stmmac clock for ethernet driver

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=e7ff31bef3cf9242ace8c5f5012e8e925397ece6 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Steven Miao <realmz6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- arch/blackfin/mach-bf609/clock.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c index 437d56c..dab8849 100644 --- a/arch/blackfin/mach-bf609/clock.c +++ b/arch/blackfin/mach-bf609/clock.c <at> <at> -220,6 +220,12 <at> <at> unsigned long sys_clk_get_rate(struct clk *clk) } } +unsigned long dummy_get_rate(struct clk *clk) +{ + clk->parent->rate = clk_get_rate(clk->parent); + return clk->parent->rate; +} + unsigned long sys_clk_round_rate(struct clk *clk, unsigned long rate) { unsigned long max_rate; <at> <at> -283,6 +289,10 <at> <at> static struct clk_ops sys_clk_ops = { .round_rate = sys_clk_round_rate, }; +static struct clk_ops dummy_clk_ops = { + .get_rate = dummy_get_rate, +}; + static struct clk sys_clkin = { .name = "SYS_CLKIN", .rate = CONFIG_CLKIN_HZ, <at> <at> -364,6 +374,12 <at> <at> static struct clk oclk = { .parent = &pll_clk, }; +static struct clk ethclk = { + .name = "stmmaceth", + .parent = &sclk0, + .ops = &dummy_clk_ops, +}; + static struct clk_lookup bf609_clks[] = { CLK(sys_clkin, NULL, "SYS_CLKIN"), CLK(pll_clk, NULL, "PLLCLK"), <at> <at> -375,6 +391,7 <at> <at> static struct clk_lookup bf609_clks[] = { CLK(sclk1, NULL, "SCLK1"), CLK(dclk, NULL, "DCLK"), CLK(oclk, NULL, "OCLK"), + CLK(ethclk, NULL, "stmmaceth"), }; int __init clk_init(void)
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=e7ff31bef3cf9242ace8c5f5012e8e925397ece6
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Steven Miao &lt;realmz6@...&gt;
---
 arch/blackfin/mach-bf609/clock.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

<span>diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c</span>
<span>index 437d56c..dab8849 100644</span>
<span>--- a/arch/blackfin/mach-bf609/clock.c</span>
<span>+++ b/arch/blackfin/mach-bf609/clock.c</span>
<span> <at>  <at>  -220,6 +220,12  <at>  <at>  unsigned long sys_clk_get_rate(struct clk *clk)</span>
 	}
 }

<span>+unsigned long dummy_get_rate(struct clk *clk)</span>
<span>+{</span>
<span>+	clk-&gt;parent-&gt;rate = clk_get_rate(clk-&gt;parent);</span>
<span>+	return clk-&gt;parent-&gt;rate;</span>
<span>+}</span>
<span>+</span>
 unsigned long sys_clk_round_rate(struct clk *clk, unsigned long rate)
 {
 	unsigned long max_rate;
<span> <at>  <at>  -283,6 +289,10  <at>  <at>  static struct clk_ops sys_clk_ops = {</span>
 	.round_rate = sys_clk_round_rate,
 };

<span>+static struct clk_ops dummy_clk_ops = {</span>
<span>+	.get_rate = dummy_get_rate,</span>
<span>+};</span>
<span>+</span>
 static struct clk sys_clkin = {
 	.name       = "SYS_CLKIN",
 	.rate       = CONFIG_CLKIN_HZ,
<span> <at>  <at>  -364,6 +374,12  <at>  <at>  static struct clk oclk = {</span>
 	.parent     = &amp;pll_clk,
 };

<span>+static struct clk ethclk = {</span>
<span>+	.name       = "stmmaceth",</span>
<span>+	.parent     = &amp;sclk0,</span>
<span>+	.ops	    = &amp;dummy_clk_ops,</span>
<span>+};</span>
<span>+</span>
 static struct clk_lookup bf609_clks[] = {
 	CLK(sys_clkin, NULL, "SYS_CLKIN"),
 	CLK(pll_clk, NULL, "PLLCLK"),
<span> <at>  <at>  -375,6 +391,7  <at>  <at>  static struct clk_lookup bf609_clks[] = {</span>
 	CLK(sclk1, NULL, "SCLK1"),
 	CLK(dclk, NULL, "DCLK"),
 	CLK(oclk, NULL, "OCLK"),
<span>+	CLK(ethclk, NULL, "stmmaceth"),</span>
 };

 int __init clk_init(void)
</div>
Sonic Zhang | 3 Jul 11:58 2013

Blackfin: bfin_gpio: Use proper mask for comparing pfunc

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=054586e3e88da3f33cde9af6adaf518cec78b348 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk For BF537_FAMILY, when offset != 1, the mask is 1. Thus add proper mask for comparing pfunc with function. Also has small refactor for better readability. In portmux_setup(), it looks odd having "pmux &= ~(3 << 1);" while in current code we do pmux |= (function << offset);. Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> --- arch/blackfin/kernel/bfin_gpio.c | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index a56356b..a017359 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c <at> <at> -227,7 +227,7 <at> <at> static int portmux_group_check(unsigned short per) u16 ident = P_IDENT(per); u16 function = P_FUNCT2MUX(per); s8 offset = port_mux[ident]; - u16 m, pmux, pfunc; + u16 m, pmux, pfunc, mask; if (offset < 0) return 0; <at> <at> -242,10 +242,12 <at> <at> static int portmux_group_check(unsigned short per) continue; if (offset == 1) - pfunc = (pmux >> offset) & 3; + mask = 3; else - pfunc = (pmux >> offset) & 1; - if (pfunc != function) { + mask = 1; + + pfunc = (pmux >> offset) & mask; + if (pfunc != (function & mask)) { pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n", ident, function, m, pfunc); return -EINVAL; <at> <at> -260,17 +262,20 <at> <at> static void portmux_setup(unsigned short per) u16 ident = P_IDENT(per); u16 function = P_FUNCT2MUX(per); s8 offset = port_mux[ident]; - u16 pmux; + u16 pmux, mask; if (offset == -1) return; pmux = bfin_read_PORT_MUX(); - if (offset != 1) - pmux &= ~(1 << offset); + if (offset == 1) + mask = 3; else - pmux &= ~(3 << 1); - pmux |= (function << offset); + mask = 1; + + pmux &= ~(mask << offset); + pmux |= ((function & mask) << offset); + bfin_write_PORT_MUX(pmux); } #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=054586e3e88da3f33cde9af6adaf518cec78b348
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

For BF537_FAMILY, when offset != 1, the mask is 1.
Thus add proper mask for comparing pfunc with function.

Also has small refactor for better readability.
In portmux_setup(), it looks odd having "pmux &amp;= ~(3 &lt;&lt; 1);"
while in current code we do pmux |= (function &lt;&lt; offset);.

Signed-off-by: Axel Lin &lt;axel.lin@...&gt;
Signed-off-by: Sonic Zhang &lt;sonic.zhang@...&gt;
---
 arch/blackfin/kernel/bfin_gpio.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

<span>diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c</span>
<span>index a56356b..a017359 100644</span>
<span>--- a/arch/blackfin/kernel/bfin_gpio.c</span>
<span>+++ b/arch/blackfin/kernel/bfin_gpio.c</span>
<span> <at>  <at>  -227,7 +227,7  <at>  <at>  static int portmux_group_check(unsigned short per)</span>
 	u16 ident = P_IDENT(per);
 	u16 function = P_FUNCT2MUX(per);
 	s8 offset = port_mux[ident];
<span>-	u16 m, pmux, pfunc;</span>
<span>+	u16 m, pmux, pfunc, mask;</span>

 	if (offset &lt; 0)
 		return 0;
<span> <at>  <at>  -242,10 +242,12  <at>  <at>  static int portmux_group_check(unsigned short per)</span>
 			continue;

 		if (offset == 1)
<span>-			pfunc = (pmux &gt;&gt; offset) &amp; 3;</span>
<span>+			mask = 3;</span>
 		else
<span>-			pfunc = (pmux &gt;&gt; offset) &amp; 1;</span>
<span>-		if (pfunc != function) {</span>
<span>+			mask = 1;</span>
<span>+</span>
<span>+		pfunc = (pmux &gt;&gt; offset) &amp; mask;</span>
<span>+		if (pfunc != (function &amp; mask)) {</span>
 			pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n",
 				ident, function, m, pfunc);
 			return -EINVAL;
<span> <at>  <at>  -260,17 +262,20  <at>  <at>  static void portmux_setup(unsigned short per)</span>
 	u16 ident = P_IDENT(per);
 	u16 function = P_FUNCT2MUX(per);
 	s8 offset = port_mux[ident];
<span>-	u16 pmux;</span>
<span>+	u16 pmux, mask;</span>

 	if (offset == -1)
 		return;

 	pmux = bfin_read_PORT_MUX();
<span>-	if (offset != 1)</span>
<span>-		pmux &amp;= ~(1 &lt;&lt; offset);</span>
<span>+	if (offset == 1)</span>
<span>+		mask = 3;</span>
 	else
<span>-		pmux &amp;= ~(3 &lt;&lt; 1);</span>
<span>-	pmux |= (function &lt;&lt; offset);</span>
<span>+		mask = 1;</span>
<span>+</span>
<span>+	pmux &amp;= ~(mask &lt;&lt; offset);</span>
<span>+	pmux |= ((function &amp; mask) &lt;&lt; offset);</span>
<span>+</span>
 	bfin_write_PORT_MUX(pmux);
 }
 #elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
</div>
Scott Jiang | 26 Jun 23:28 2013
Picon

bf609: update default config for spi

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=511408711526aac48555eae4ef3f5729d3d3f739 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- arch/blackfin/configs/BF609-EZKIT_defconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/blackfin/configs/BF609-EZKIT_defconfig b/arch/blackfin/configs/BF609-EZKIT_defconfig index 432a692..3c938e9 100644 --- a/arch/blackfin/configs/BF609-EZKIT_defconfig +++ b/arch/blackfin/configs/BF609-EZKIT_defconfig <at> <at> -102,7 +102,7 <at> <at> CONFIG_I2C_CHARDEV=y CONFIG_I2C_BLACKFIN_TWI=y CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100 CONFIG_SPI=y -CONFIG_SPI_BFIN6XX=y +CONFIG_SPI_BFIN_V3=y CONFIG_PPS=y CONFIG_PTP_1588_CLOCK=y CONFIG_GPIOLIB=y
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=511408711526aac48555eae4ef3f5729d3d3f739
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Scott Jiang &lt;scott.jiang.linux@...&gt;
---
 arch/blackfin/configs/BF609-EZKIT_defconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

<span>diff --git a/arch/blackfin/configs/BF609-EZKIT_defconfig b/arch/blackfin/configs/BF609-EZKIT_defconfig</span>
<span>index 432a692..3c938e9 100644</span>
<span>--- a/arch/blackfin/configs/BF609-EZKIT_defconfig</span>
<span>+++ b/arch/blackfin/configs/BF609-EZKIT_defconfig</span>
<span> <at>  <at>  -102,7 +102,7  <at>  <at>  CONFIG_I2C_CHARDEV=y</span>
 CONFIG_I2C_BLACKFIN_TWI=y
 CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
 CONFIG_SPI=y
<span>-CONFIG_SPI_BFIN6XX=y</span>
<span>+CONFIG_SPI_BFIN_V3=y</span>
 CONFIG_PPS=y
 CONFIG_PTP_1588_CLOCK=y
 CONFIG_GPIOLIB=y
</div>
Scott Jiang | 26 Jun 21:42 2013
Picon

bf609: rename bfin6xx_spi to bfin_spi3

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=cb4235762982a77ab1ed793e0a5beb45358238c1 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- .../include/asm/{bfin6xx_spi.h => bfin_spi3.h} | 4 ++-- arch/blackfin/mach-bf609/boards/ezkit.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/blackfin/include/asm/bfin6xx_spi.h b/arch/blackfin/include/asm/bfin_spi3.h similarity index 99% rename from arch/blackfin/include/asm/bfin6xx_spi.h rename to arch/blackfin/include/asm/bfin_spi3.h index 89370b6..0957e65 100644 --- a/arch/blackfin/include/asm/bfin6xx_spi.h +++ b/arch/blackfin/include/asm/bfin_spi3.h <at> <at> -240,7 +240,7 <at> <at> struct bfin_spi_regs { #define MAX_CTRL_CS 8 /* cs in spi controller */ /* device.platform_data for SSP controller devices */ -struct bfin6xx_spi_master { +struct bfin_spi3_master { u16 num_chipselect; u16 pin_req[7]; }; <at> <at> -248,7 +248,7 <at> <at> struct bfin6xx_spi_master { /* spi_board_info.controller_data for SPI slave devices, * copied to spi_device.platform_data ... mostly for dma tuning */ -struct bfin6xx_spi_chip { +struct bfin_spi3_chip { u32 control; u16 cs_chg_udelay; /* Some devices require 16-bit delays */ u32 tx_dummy_val; /* tx value for rx only transfer */ diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c index 4034262..20c7c6d 100644 --- a/arch/blackfin/mach-bf609/boards/ezkit.c +++ b/arch/blackfin/mach-bf609/boards/ezkit.c <at> <at> -18,7 +18,7 <at> <at> #include <linux/interrupt.h> #include <linux/usb/musb.h> #include <linux/platform_data/gpio-adi2.h> -#include <asm/bfin6xx_spi.h> +#include <asm/bfin_spi3.h> #include <asm/dma.h> #include <asm/gpio.h> #include <asm/nand.h> <at> <at> -764,13 +764,13 <at> <at> static struct flash_platform_data bfin_spi_flash_data = { .type = "w25q32", }; -static struct bfin6xx_spi_chip spi_flash_chip_info = { +static struct bfin_spi3_chip spi_flash_chip_info = { .enable_dma = true, /* use dma transfer with this chip*/ }; #endif #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) -static struct bfin6xx_spi_chip spidev_chip_info = { +static struct bfin_spi3_chip spidev_chip_info = { .enable_dma = true, }; #endif <at> <at> -1787,7 +1787,7 <at> <at> static struct spi_board_info bfin_spi_board_info[] __initdata = { }, #endif }; -#if defined(CONFIG_SPI_BFIN6XX) || defined(CONFIG_SPI_BFIN6XX_MODULE) +#if IS_ENABLED(CONFIG_SPI_BFIN_V3) /* SPI (0) */ static struct resource bfin_spi0_resource[] = { { <at> <at> -1828,13 +1828,13 <at> <at> static struct resource bfin_spi1_resource[] = { }; /* SPI controller data */ -static struct bfin6xx_spi_master bf60x_spi_master_info0 = { +static struct bfin_spi3_master bf60x_spi_master_info0 = { .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, }; static struct platform_device bf60x_spi_master0 = { - .name = "bfin-spi", + .name = "bfin-spi3", .id = 0, /* Bus number */ .num_resources = ARRAY_SIZE(bfin_spi0_resource), .resource = bfin_spi0_resource, <at> <at> -1843,13 +1843,13 <at> <at> static struct platform_device bf60x_spi_master0 = { }, }; -static struct bfin6xx_spi_master bf60x_spi_master_info1 = { +static struct bfin_spi3_master bf60x_spi_master_info1 = { .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, }; static struct platform_device bf60x_spi_master1 = { - .name = "bfin-spi", + .name = "bfin-spi3", .id = 1, /* Bus number */ .num_resources = ARRAY_SIZE(bfin_spi1_resource), .resource = bfin_spi1_resource, <at> <at> -2040,7 +2040,7 <at> <at> static struct platform_device *ezkit_devices[] __initdata = { &bfin_sdh_device, #endif -#if defined(CONFIG_SPI_BFIN6XX) || defined(CONFIG_SPI_BFIN6XX_MODULE) +#if IS_ENABLED(CONFIG_SPI_BFIN_V3) &bf60x_spi_master0, &bf60x_spi_master1, #endif
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=cb4235762982a77ab1ed793e0a5beb45358238c1
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Scott Jiang &lt;scott.jiang.linux@...&gt;
---
 .../include/asm/{bfin6xx_spi.h =&gt; bfin_spi3.h}     |    4 ++--
 arch/blackfin/mach-bf609/boards/ezkit.c            |   18 +++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

<span>diff --git a/arch/blackfin/include/asm/bfin6xx_spi.h b/arch/blackfin/include/asm/bfin_spi3.h</span>
similarity index 99%
rename from arch/blackfin/include/asm/bfin6xx_spi.h
rename to arch/blackfin/include/asm/bfin_spi3.h
<span>index 89370b6..0957e65 100644</span>
<span>--- a/arch/blackfin/include/asm/bfin6xx_spi.h</span>
<span>+++ b/arch/blackfin/include/asm/bfin_spi3.h</span>
<span> <at>  <at>  -240,7 +240,7  <at>  <at>  struct bfin_spi_regs {</span>
 #define MAX_CTRL_CS          8  /* cs in spi controller */

 /* device.platform_data for SSP controller devices */
<span>-struct bfin6xx_spi_master {</span>
<span>+struct bfin_spi3_master {</span>
 	u16 num_chipselect;
 	u16 pin_req[7];
 };
<span> <at>  <at>  -248,7 +248,7  <at>  <at>  struct bfin6xx_spi_master {</span>
 /* spi_board_info.controller_data for SPI slave devices,
  * copied to spi_device.platform_data ... mostly for dma tuning
  */
<span>-struct bfin6xx_spi_chip {</span>
<span>+struct bfin_spi3_chip {</span>
 	u32 control;
 	u16 cs_chg_udelay; /* Some devices require 16-bit delays */
 	u32 tx_dummy_val; /* tx value for rx only transfer */
<span>diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c</span>
<span>index 4034262..20c7c6d 100644</span>
<span>--- a/arch/blackfin/mach-bf609/boards/ezkit.c</span>
<span>+++ b/arch/blackfin/mach-bf609/boards/ezkit.c</span>
<span> <at>  <at>  -18,7 +18,7  <at>  <at> </span>
 #include &lt;linux/interrupt.h&gt;
 #include &lt;linux/usb/musb.h&gt;
 #include &lt;linux/platform_data/gpio-adi2.h&gt;
<span>-#include &lt;asm/bfin6xx_spi.h&gt;</span>
<span>+#include &lt;asm/bfin_spi3.h&gt;</span>
 #include &lt;asm/dma.h&gt;
 #include &lt;asm/gpio.h&gt;
 #include &lt;asm/nand.h&gt;
<span> <at>  <at>  -764,13 +764,13  <at>  <at>  static struct flash_platform_data bfin_spi_flash_data = {</span>
 	.type = "w25q32",
 };

<span>-static struct bfin6xx_spi_chip spi_flash_chip_info = {</span>
<span>+static struct bfin_spi3_chip spi_flash_chip_info = {</span>
 	.enable_dma = true,         /* use dma transfer with this chip*/
 };
 #endif

 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
<span>-static struct bfin6xx_spi_chip spidev_chip_info = {</span>
<span>+static struct bfin_spi3_chip spidev_chip_info = {</span>
 	.enable_dma = true,
 };
 #endif
<span> <at>  <at>  -1787,7 +1787,7  <at>  <at>  static struct spi_board_info bfin_spi_board_info[] __initdata = {</span>
 	},
 #endif
 };
<span>-#if defined(CONFIG_SPI_BFIN6XX) || defined(CONFIG_SPI_BFIN6XX_MODULE)</span>
<span>+#if IS_ENABLED(CONFIG_SPI_BFIN_V3)</span>
 /* SPI (0) */
 static struct resource bfin_spi0_resource[] = {
 	{
<span> <at>  <at>  -1828,13 +1828,13  <at>  <at>  static struct resource bfin_spi1_resource[] = {</span>
 };

 /* SPI controller data */
<span>-static struct bfin6xx_spi_master bf60x_spi_master_info0 = {</span>
<span>+static struct bfin_spi3_master bf60x_spi_master_info0 = {</span>
 	.num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
 	.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
 };

 static struct platform_device bf60x_spi_master0 = {
<span>-	.name = "bfin-spi",</span>
<span>+	.name = "bfin-spi3",</span>
 	.id = 0, /* Bus number */
 	.num_resources = ARRAY_SIZE(bfin_spi0_resource),
 	.resource = bfin_spi0_resource,
<span> <at>  <at>  -1843,13 +1843,13  <at>  <at>  static struct platform_device bf60x_spi_master0 = {</span>
 	},
 };

<span>-static struct bfin6xx_spi_master bf60x_spi_master_info1 = {</span>
<span>+static struct bfin_spi3_master bf60x_spi_master_info1 = {</span>
 	.num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
 	.pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
 };

 static struct platform_device bf60x_spi_master1 = {
<span>-	.name = "bfin-spi",</span>
<span>+	.name = "bfin-spi3",</span>
 	.id = 1, /* Bus number */
 	.num_resources = ARRAY_SIZE(bfin_spi1_resource),
 	.resource = bfin_spi1_resource,
<span> <at>  <at>  -2040,7 +2040,7  <at>  <at>  static struct platform_device *ezkit_devices[] __initdata = {</span>
 	&amp;bfin_sdh_device,
 #endif

<span>-#if defined(CONFIG_SPI_BFIN6XX) || defined(CONFIG_SPI_BFIN6XX_MODULE)</span>
<span>+#if IS_ENABLED(CONFIG_SPI_BFIN_V3)</span>
 	&amp;bf60x_spi_master0,
 	&amp;bf60x_spi_master1,
 #endif
</div>
Scott Jiang | 26 Jun 21:22 2013
Picon

spi: rename spi-bfin6xx to spi-bfin-v3

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=ae3e8676c5814c38f8e43ab600422414bf496382 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/spi/Kconfig | 7 ++++--- drivers/spi/Makefile | 2 +- drivers/spi/{spi-bfin6xx.c => spi-bfin-v3.c} | 16 +++++++--------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index b50348d..7f4cf97 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig <at> <at> -87,11 +87,12 <at> <at> config SPI_BFIN5XX help This is the SPI controller master driver for Blackfin 5xx processor. -config SPI_BFIN6XX - tristate "SPI controller driver for ADI Blackfin6xx" +config SPI_BFIN_V3 + tristate "SPI controller v3 for Blackfin" depends on BLACKFIN && BF60x help - This is the SPI controller master driver for Blackfin 6xx processor. + This is the SPI controller v3 master driver + found on Blackfin 60x processor. config SPI_BFIN_SPORT tristate "SPI bus via Blackfin SPORT" diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 869719f..7d5dfb1 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile <at> <at> -16,7 +16,7 <at> <at> obj-$(CONFIG_SPI_ATH79) += spi-ath79.o obj-$(CONFIG_SPI_AU1550) += spi-au1550.o obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o -obj-$(CONFIG_SPI_BFIN6XX) += spi-bfin6xx.o +obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o diff --git a/drivers/spi/spi-bfin6xx.c b/drivers/spi/spi-bfin-v3.c similarity index 98% rename from drivers/spi/spi-bfin6xx.c rename to drivers/spi/spi-bfin-v3.c index aac10dd..2cc081d 100644 --- a/drivers/spi/spi-bfin6xx.c +++ b/drivers/spi/spi-bfin-v3.c <at> <at> -28,7 +28,7 <at> <at> #include <linux/spi/spi.h> #include <linux/types.h> -#include <asm/bfin6xx_spi.h> +#include <asm/bfin_spi3.h> #include <asm/cacheflush.h> #include <asm/dma.h> #include <asm/portmux.h> <at> <at> -649,7 +649,7 <at> <at> static int bfin_spi_setup(struct spi_device *spi) } if (!chip) { - struct bfin6xx_spi_chip *chip_info = spi->controller_data; + struct bfin_spi3_chip *chip_info = spi->controller_data; chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (!chip) { <at> <at> -784,7 +784,7 <at> <at> static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) static int bfin_spi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct bfin6xx_spi_master *info = dev->platform_data; + struct bfin_spi3_master *info = dev->platform_data; struct spi_master *master; struct bfin_spi_master *drv_data; struct resource *mem, *res; <at> <at> -870,7 +870,7 <at> <at> static int bfin_spi_probe(struct platform_device *pdev) set_dma_callback(drv_data->rx_dma, bfin_spi_rx_dma_isr, drv_data); /* request CLK, MOSI and MISO */ - ret = peripheral_request_list(drv_data->pin_req, "bfin-spi"); + ret = peripheral_request_list(drv_data->pin_req, "bfin-spi3"); if (ret < 0) { dev_err(dev, "can not request spi pins\n"); goto err_free_rx_dma; <at> <at> -961,19 +961,17 <at> <at> static int bfin_spi_resume(struct device *dev) return ret; } +#endif static const struct dev_pm_ops bfin_spi_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume) }; -#endif /* CONFIG_PM */ -MODULE_ALIAS("platform:bfin-spi"); +MODULE_ALIAS("platform:bfin-spi3"); static struct platform_driver bfin_spi_driver = { .driver = { - .name = "bfin-spi", + .name = "bfin-spi3", .owner = THIS_MODULE, -#ifdef CONFIG_PM .pm = &bfin_spi_pm_ops, -#endif }, .remove = bfin_spi_remove, };
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=ae3e8676c5814c38f8e43ab600422414bf496382
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Scott Jiang &lt;scott.jiang.linux@...&gt;
---
 drivers/spi/Kconfig                          |    7 ++++---
 drivers/spi/Makefile                         |    2 +-
 drivers/spi/{spi-bfin6xx.c =&gt; spi-bfin-v3.c} |   16 +++++++---------
 3 files changed, 12 insertions(+), 13 deletions(-)

<span>diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig</span>
<span>index b50348d..7f4cf97 100644</span>
<span>--- a/drivers/spi/Kconfig</span>
<span>+++ b/drivers/spi/Kconfig</span>
<span> <at>  <at>  -87,11 +87,12  <at>  <at>  config SPI_BFIN5XX</span>
 	help
 	  This is the SPI controller master driver for Blackfin 5xx processor.

<span>-config SPI_BFIN6XX</span>
<span>-	tristate "SPI controller driver for ADI Blackfin6xx"</span>
<span>+config SPI_BFIN_V3</span>
<span>+	tristate "SPI controller v3 for Blackfin"</span>
 	depends on BLACKFIN &amp;&amp; BF60x
 	help
<span>-	  This is the SPI controller master driver for Blackfin 6xx processor.</span>
<span>+	  This is the SPI controller v3 master driver</span>
<span>+	  found on Blackfin 60x processor.</span>

 config SPI_BFIN_SPORT
 	tristate "SPI bus via Blackfin SPORT"
<span>diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile</span>
<span>index 869719f..7d5dfb1 100644</span>
<span>--- a/drivers/spi/Makefile</span>
<span>+++ b/drivers/spi/Makefile</span>
<span> <at>  <at>  -16,7 +16,7  <at>  <at>  obj-$(CONFIG_SPI_ATH79)			+= spi-ath79.o</span>
 obj-$(CONFIG_SPI_AU1550)		+= spi-au1550.o
 obj-$(CONFIG_SPI_BCM63XX)		+= spi-bcm63xx.o
 obj-$(CONFIG_SPI_BFIN5XX)		+= spi-bfin5xx.o
<span>-obj-$(CONFIG_SPI_BFIN6XX)               += spi-bfin6xx.o</span>
<span>+obj-$(CONFIG_SPI_BFIN_V3)               += spi-bfin-v3.o</span>
 obj-$(CONFIG_SPI_BFIN_SPORT)		+= spi-bfin-sport.o
 obj-$(CONFIG_SPI_BITBANG)		+= spi-bitbang.o
 obj-$(CONFIG_SPI_BUTTERFLY)		+= spi-butterfly.o
<span>diff --git a/drivers/spi/spi-bfin6xx.c b/drivers/spi/spi-bfin-v3.c</span>
similarity index 98%
rename from drivers/spi/spi-bfin6xx.c
rename to drivers/spi/spi-bfin-v3.c
<span>index aac10dd..2cc081d 100644</span>
<span>--- a/drivers/spi/spi-bfin6xx.c</span>
<span>+++ b/drivers/spi/spi-bfin-v3.c</span>
<span> <at>  <at>  -28,7 +28,7  <at>  <at> </span>
 #include &lt;linux/spi/spi.h&gt;
 #include &lt;linux/types.h&gt;

<span>-#include &lt;asm/bfin6xx_spi.h&gt;</span>
<span>+#include &lt;asm/bfin_spi3.h&gt;</span>
 #include &lt;asm/cacheflush.h&gt;
 #include &lt;asm/dma.h&gt;
 #include &lt;asm/portmux.h&gt;
<span> <at>  <at>  -649,7 +649,7  <at>  <at>  static int bfin_spi_setup(struct spi_device *spi)</span>
 	}

 	if (!chip) {
<span>-		struct bfin6xx_spi_chip *chip_info = spi-&gt;controller_data;</span>
<span>+		struct bfin_spi3_chip *chip_info = spi-&gt;controller_data;</span>

 		chip = kzalloc(sizeof(*chip), GFP_KERNEL);
 		if (!chip) {
<span> <at>  <at>  -784,7 +784,7  <at>  <at>  static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id)</span>
 static int bfin_spi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &amp;pdev-&gt;dev;
<span>-	struct bfin6xx_spi_master *info = dev-&gt;platform_data;</span>
<span>+	struct bfin_spi3_master *info = dev-&gt;platform_data;</span>
 	struct spi_master *master;
 	struct bfin_spi_master *drv_data;
 	struct resource *mem, *res;
<span> <at>  <at>  -870,7 +870,7  <at>  <at>  static int bfin_spi_probe(struct platform_device *pdev)</span>
 	set_dma_callback(drv_data-&gt;rx_dma, bfin_spi_rx_dma_isr, drv_data);

 	/* request CLK, MOSI and MISO */
<span>-	ret = peripheral_request_list(drv_data-&gt;pin_req, "bfin-spi");</span>
<span>+	ret = peripheral_request_list(drv_data-&gt;pin_req, "bfin-spi3");</span>
 	if (ret &lt; 0) {
 		dev_err(dev, "can not request spi pins\n");
 		goto err_free_rx_dma;
<span> <at>  <at>  -961,19 +961,17  <at>  <at>  static int bfin_spi_resume(struct device *dev)</span>

 	return ret;
 }
<span>+#endif</span>
 static const struct dev_pm_ops bfin_spi_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume)
 };
<span>-#endif /* CONFIG_PM */</span>

<span>-MODULE_ALIAS("platform:bfin-spi");</span>
<span>+MODULE_ALIAS("platform:bfin-spi3");</span>
 static struct platform_driver bfin_spi_driver = {
 	.driver	= {
<span>-		.name	= "bfin-spi",</span>
<span>+		.name	= "bfin-spi3",</span>
 		.owner	= THIS_MODULE,
<span>-#ifdef CONFIG_PM</span>
 		.pm     = &amp;bfin_spi_pm_ops,
<span>-#endif</span>
 	},
 	.remove		= bfin_spi_remove,
 };
</div>
Scott Jiang | 26 Jun 01:53 2013
Picon

spi: convert to use SET_SYSTEM_SLEEP_PM_OPS

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=8284839e13a9d205a8e6d80be336101683640714 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Scott Jiang <scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/spi/spi-bfin6xx.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-bfin6xx.c b/drivers/spi/spi-bfin6xx.c index 6c9bae3..480bc82 100644 --- a/drivers/spi/spi-bfin6xx.c +++ b/drivers/spi/spi-bfin6xx.c <at> <at> -728,8 +728,9 <at> <at> static void bfin_spi_cleanup(struct spi_device *spi) peripheral_free(ssel[spi->master->bus_num] [chip->cs-1]); bfin_spi_cs_disable(drv_data, chip); - } else + } else { gpio_free(chip->cs_gpio); + } kfree(chip); spi_set_ctldata(spi, NULL); <at> <at> -849,7 +850,6 <at> <at> static int bfin_spi_probe(struct platform_device *pdev) drv_data->regs = devm_ioremap_resource(dev, mem); if (IS_ERR(drv_data->regs)) { - dev_err(dev, "can not map register memory\n"); ret = PTR_ERR(drv_data->regs); goto err_put_master; } <at> <at> -962,8 +962,7 <at> <at> static int bfin_spi_resume(struct device *dev) return ret; } static const struct dev_pm_ops bfin_spi_pm_ops = { - .suspend = bfin_spi_suspend, - .resume = bfin_spi_resume, + SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume) }; #endif /* CONFIG_PM */
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=8284839e13a9d205a8e6d80be336101683640714
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Scott Jiang &lt;scott.jiang.linux@...&gt;
---
 drivers/spi/spi-bfin6xx.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

<span>diff --git a/drivers/spi/spi-bfin6xx.c b/drivers/spi/spi-bfin6xx.c</span>
<span>index 6c9bae3..480bc82 100644</span>
<span>--- a/drivers/spi/spi-bfin6xx.c</span>
<span>+++ b/drivers/spi/spi-bfin6xx.c</span>
<span> <at>  <at>  -728,8 +728,9  <at>  <at>  static void bfin_spi_cleanup(struct spi_device *spi)</span>
 		peripheral_free(ssel[spi-&gt;master-&gt;bus_num]
 					[chip-&gt;cs-1]);
 		bfin_spi_cs_disable(drv_data, chip);
<span>-	} else</span>
<span>+	} else {</span>
 		gpio_free(chip-&gt;cs_gpio);
<span>+	}</span>

 	kfree(chip);
 	spi_set_ctldata(spi, NULL);
<span> <at>  <at>  -849,7 +850,6  <at>  <at>  static int bfin_spi_probe(struct platform_device *pdev)</span>

 	drv_data-&gt;regs = devm_ioremap_resource(dev, mem);
 	if (IS_ERR(drv_data-&gt;regs)) {
<span>-		dev_err(dev, "can not map register memory\n");</span>
 		ret = PTR_ERR(drv_data-&gt;regs);
 		goto err_put_master;
 	}
<span> <at>  <at>  -962,8 +962,7  <at>  <at>  static int bfin_spi_resume(struct device *dev)</span>
 	return ret;
 }
 static const struct dev_pm_ops bfin_spi_pm_ops = {
<span>-	.suspend = bfin_spi_suspend,</span>
<span>-	.resume  = bfin_spi_resume,</span>
<span>+	SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume)</span>
 };
 #endif /* CONFIG_PM */

</div>
Sonic Zhang | 25 Jun 06:02 2013

gpio:gpio-adi2: mainline feedback

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=c11f1561a148eead0f59247845d745519440aa78 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk - Change bit variables into bool variables. - Change register type from unsigned type into uX. - Write proper kerneldoc instead of inline comments. - Define GPIO offset as u8. - No need for a simple helper, inline it. - Avoid forward-declarations - Skip large boilerplate function description - Remove irq enable status check in irq_chip operation. - Access device registers by read[l|w|b] and write[l|w|b]. Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> --- drivers/gpio/gpio-adi2.c | 495 +++++++++++++++---------------- include/linux/platform_data/gpio-adi2.h | 26 ++- 2 files changed, 254 insertions(+), 267 deletions(-) diff --git a/drivers/gpio/gpio-adi2.c b/drivers/gpio/gpio-adi2.c index c1b9102..da2d18e 100644 --- a/drivers/gpio/gpio-adi2.c +++ b/drivers/gpio/gpio-adi2.c <at> <at> -3,7 +3,7 <at> <at> * * Copyright 2007-2013 Analog Devices Inc. * - * Licensed under the GPL-2 or later + * Licensed under the GPLv2 or later */ #include <linux/delay.h> <at> <at> -26,29 +26,62 <at> <at> static LIST_HEAD(adi_pint_list); #define RSV_INT 2 #define RSV_PERI 3 +/** + * struct gpio_reserve_map - a GPIO map structure containing the + * reservation status of each PIN. + * + * <at> owner: who request the reservation + * <at> rsv_gpio: if this pin is reserved as GPIO + * <at> rsv_int: if this pin is reserved as interrupt + * <at> rsv_peri: if this pin is reserved as part of a peripheral device + */ struct gpio_reserve_map { unsigned char owner[RESOURCE_LABEL_SIZE]; - unsigned char irq_enabled:1; - unsigned char rsv_gpio:1; - unsigned char rsv_int:1; - unsigned char rsv_peri:1; + bool rsv_gpio; + bool rsv_int; + bool rsv_peri; }; +/** + * struct gpio_port_saved - GPIO port registers that should be saved between + * power suspend and resume operations. + * + * <at> fer: PORTx_FER register + * <at> data: PORTx_DATA register + * <at> dir: PORTx_DIR register + * <at> inen: PORTx_INEN register + * <at> mux: PORTx_MUX register + */ struct gpio_port_saved { - unsigned short fer; - unsigned short data; - unsigned short dir; - unsigned short inen; - unsigned int mux; + u16 fer; + u16 data; + u16 dir; + u16 inen; + u32 mux; }; +/** + * struct gpio_pint - GPIO interrupt controller device. Multiple ADI GPIO + * banks can be mapped into one GPIO interrupt controller. + * + * <at> node: All gpio_pint instances are added to a global list. + * <at> base: GPIO PINT device register base address + * <at> irq: IRQ of the GPIO PINT device, it is the parent IRQ of all + * GPIO IRQs mapping to this device. + * <at> gpio_irq_base: [0] means gpio irq base is in low 16-bit registers. + * [1] means gpio irq base is in high 16-bit registers. + * <at> regs: address pointer to the GPIO PINT device + * <at> map_count: No more than 2 GPIO banks can be mapped to this PINT device. + * <at> lock: This lock make sure the irq_chip operations to one GPIO PINT device + * for different GPIO interrrupts are atomic. + * <at> pint_map_port: Set up the mapping between one GPIO PINT device and + * multiple GPIO banks. + */ struct gpio_pint { struct list_head node; - void __iomem *base; /* Port interrupt controller MMR base */ - int irq; /* Port interrupt controller demux IRQ */ - int gpio_irq_base[2]; /* [0] is gpio irq base in low 16 bit pint. - * [1] is gpio irq base in high 16 bit pint. - */ + void __iomem *base; + int irq; + int gpio_irq_base[2]; struct gpio_pint_regs *regs; struct adi_pm_pint_save saved_data; int map_count; <at> <at> -58,21 +91,41 <at> <at> struct gpio_pint { u8 map, int irq_base); }; +/** + * struct gpio_pint - GPIO bank device. Multiple ADI GPIO banks can be mapped + * into one GPIO interrupt controller. + * + * <at> node: All gpio_pint instances are added to a global list. + * <at> base: GPIO bank device register base address + * <at> pin_base: base global GPIO pin index of the GPIO bank device + * <at> irq_base: base IRQ of the GPIO bank device + * <at> width: PIN number of the GPIO bank device + * <at> regs: address pointer to the GPIO bank device + * <at> saved_data: registers that should be saved between PM operations. + * <at> dev: device structure of this GPIO bank + * <at> pint: GPIO PINT device that this GPIO bank mapped to + * <at> pint_map: GIOP bank mapping code in PINT device + * <at> pint_assign: The 32-bit GPIO PINT registers can be divided into 2 parts. A + * GPIO bank can be mapped into either low 16 bits[0] or high 16 + * bits[1] of each PINT register. + * <at> lock: This lock make sure the irq_chip operations to one GPIO PINT device + * for different GPIO interrrupts are atomic. + * <at> chip: abstract a GPIO controller + * <at> rsvmap: Reservation map array for each pin in the GPIO bank + */ struct gpio_port { struct list_head node; void __iomem *base; - int pin_base; - int irq_base; - int width; + unsigned int pin_base; + unsigned int irq_base; + unsigned int width; struct gpio_port_t *regs; struct gpio_port_saved saved_data; struct device *dev; struct gpio_pint *pint; - u8 pint_map; /* port mapping mask in pint */ - u8 pint_assign; /* 0 - assgin to pint 1ow 16 bits - * 1 - assign to pint high 16 bits - */ + u8 pint_map; + u8 pint_assign; spinlock_t lock; struct gpio_chip chip; <at> <at> -80,17 +133,17 <at> <at> struct gpio_port { struct gpio_reserve_map rsvmap[]; }; -static inline unsigned offset_to_gpio(struct gpio_port *port, unsigned offset) +static inline unsigned offset_to_gpio(struct gpio_port *port, u8 offset) { return offset + port->chip.base; } -static inline unsigned gpio_to_offset(struct gpio_port *port, unsigned gpio) +static inline u8 gpio_to_offset(struct gpio_port *port, unsigned gpio) { return gpio - port->chip.base; } -static inline unsigned irq_to_offset(struct gpio_port *port, int irq) +static inline u8 irq_to_offset(struct gpio_port *port, int irq) { int offset; <at> <at> -106,12 +159,6 <at> <at> static inline unsigned irq_to_pintbit(struct gpio_port *port, int irq) return (1 << irq_to_offset(port, irq)) << (port->pint_assign * 16); } -static void gpio_error(struct gpio_port *port, unsigned offset) -{ - dev_err(port->dev, "gpio-adi2: GPIO %d wasn't requested!\n", - offset_to_gpio(port, offset)); -} - static void set_label(struct gpio_port *port, unsigned offset, const char *label) { <at> <at> -143,32 +190,16 <at> <at> static int cmp_label(struct gpio_port *port, unsigned offset, const char *label) return -EINVAL; } -static inline unsigned int is_gpio_irq_enabled(struct gpio_port *port, - unsigned offset) -{ - return port->rsvmap[offset].irq_enabled; -} - -static inline void enable_gpio_irq(struct gpio_port *port, unsigned offset) -{ - port->rsvmap[offset].irq_enabled = 1; -} - -static inline void disable_gpio_irq(struct gpio_port *port, unsigned offset) -{ - port->rsvmap[offset].irq_enabled = 0; -} - static inline unsigned int is_reserved(struct gpio_port *port, char type, unsigned offset) { switch (type) { case RSV_GPIO: - return port->rsvmap[offset].rsv_gpio == 1; + return port->rsvmap[offset].rsv_gpio == true; case RSV_INT: - return port->rsvmap[offset].rsv_int == 1; + return port->rsvmap[offset].rsv_int == true; case RSV_PERI: - return port->rsvmap[offset].rsv_peri == 1; + return port->rsvmap[offset].rsv_peri == true; } return 0; <at> <at> -178,13 +209,13 <at> <at> static inline void reserve(struct gpio_port *port, char type, unsigned offset) { switch (type) { case RSV_GPIO: - port->rsvmap[offset].rsv_gpio = 1; + port->rsvmap[offset].rsv_gpio = true; break; case RSV_INT: - port->rsvmap[offset].rsv_int = 1; + port->rsvmap[offset].rsv_int = true; break; case RSV_PERI: - port->rsvmap[offset].rsv_peri = 1; + port->rsvmap[offset].rsv_peri = true; break; } } <at> <at> -193,13 +224,13 <at> <at> static inline void unreserve(struct gpio_port *port, char type, unsigned offset) { switch (type) { case RSV_GPIO: - port->rsvmap[offset].rsv_gpio = 0; + port->rsvmap[offset].rsv_gpio = false; break; case RSV_INT: - port->rsvmap[offset].rsv_int = 0; + port->rsvmap[offset].rsv_int = false; break; case RSV_PERI: - port->rsvmap[offset].rsv_peri = 0; + port->rsvmap[offset].rsv_peri = false; break; } } <at> <at> -236,11 +267,89 <at> <at> static struct gpio_pint *find_gpio_pint(unsigned pint_id) return NULL; } +static inline void port_setup(struct gpio_port *port, unsigned offset, + unsigned short usage) +{ + struct gpio_port_t *regs = port->regs; + + if (usage == GPIO_USAGE) + writew(readw(&regs->port_fer) & ~(1 << offset), + &regs->port_fer); + else + writew(readw(&regs->port_fer) | (1 << offset), &regs->port_fer); +} + +static inline void portmux_setup(struct gpio_port *port, unsigned offset, + unsigned short function) +{ + struct gpio_port_t *regs = port->regs; + u32 pmux; + + pmux = readl(&regs->port_mux); + + pmux &= ~(0x3 << (2 * offset)); + pmux |= (function & 0x3) << (2 * offset); + + writel(pmux, &regs->port_mux); +} + +static inline u16 get_portmux(struct gpio_port *port, unsigned offset) +{ + struct gpio_port_t *regs = port->regs; + u32 pmux = readl(&regs->port_mux); + + return pmux >> (2 * offset) & 0x3; +} + + +static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset) +{ + struct gpio_port_t *regs = port->regs; + + port_setup(port, offset, GPIO_USAGE); + + writew(1 << offset, &regs->dir_clear); + writew(readw(&regs->inen) | (1 << offset), &regs->inen); +} -static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset); static int __adi_gpio_irq_request(struct gpio_port *port, unsigned offset, - const char *label); -static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset); + const char *label) +{ + if (unlikely(is_reserved(port, RSV_PERI, offset))) { + if (system_state == SYSTEM_BOOTING) + dump_stack(); + + dev_err(port->dev, + "gpio-adi2: GPIO %d is already reserved as Peripheral by %s !\n", + offset_to_gpio(port, offset), get_label(port, offset)); + return -EBUSY; + } + if (unlikely(is_reserved(port, RSV_GPIO, offset))) + dev_err(port->dev, + "gpio-adi2: GPIO %d is already reserved by %s!\n", + offset_to_gpio(port, offset), get_label(port, offset)); + + reserve(port, RSV_INT, offset); + set_label(port, offset, label); + port_setup(port, offset, GPIO_USAGE); + + return 0; +} + +static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset) +{ + if (unlikely(!is_reserved(port, RSV_INT, offset))) { + if (system_state == SYSTEM_BOOTING) + dump_stack(); + + dev_err(port->dev, "gpio-adi2: GPIO %d wasn't requested!\n", + offset_to_gpio(port, offset)); + return; + } + + unreserve(port, RSV_INT, offset); + set_label(port, offset, "free"); +} static void adi_gpio_ack_irq(struct irq_data *d) { <at> <at> -253,13 +362,13 <at> <at> static void adi_gpio_ack_irq(struct irq_data *d) spin_lock_irqsave(&port->pint->lock, flags); if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { - if (regs->invert_set & pintbit) - regs->invert_clear = pintbit; + if (readl(&regs->invert_set) & pintbit) + writel(pintbit, &regs->invert_clear); else - regs->invert_set = pintbit; + writel(pintbit, &regs->invert_set); } - regs->request = pintbit; + writel(pintbit, &regs->request); spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); <at> <at> -276,58 +385,44 <at> <at> static void adi_gpio_mask_ack_irq(struct irq_data *d) spin_lock_irqsave(&port->pint->lock, flags); if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { - if (regs->invert_set & pintbit) - regs->invert_clear = pintbit; + if (readl(&regs->invert_set) & pintbit) + writel(pintbit, &regs->invert_clear); else - regs->invert_set = pintbit; + writel(pintbit, &regs->invert_set); } - regs->request = pintbit; - regs->mask_clear = pintbit; + writel(pintbit, &regs->request); + writel(pintbit, &regs->mask_clear); spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); } -static void __adi_gpio_mask_irq(struct gpio_port *port, int irq) -{ - struct gpio_pint_regs *regs = port->pint->regs; - unsigned pintbit = irq_to_pintbit(port, irq); - - regs->mask_clear = pintbit; -} - static void adi_gpio_mask_irq(struct irq_data *d) { unsigned long flags; struct gpio_port *port = irq_data_get_irq_chip_data(d); + struct gpio_pint_regs *regs = port->pint->regs; spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->pint->lock, flags); - __adi_gpio_mask_irq(port, d->irq); + writel(irq_to_pintbit(port, d->irq), &regs->mask_clear); spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); } -static void __adi_gpio_unmask_irq(struct gpio_port *port, int irq) -{ - struct gpio_pint_regs *regs = port->pint->regs; - unsigned pintbit = irq_to_pintbit(port, irq); - - regs->mask_set = pintbit; -} - static void adi_gpio_unmask_irq(struct irq_data *d) { unsigned long flags; struct gpio_port *port = irq_data_get_irq_chip_data(d); + struct gpio_pint_regs *regs = port->pint->regs; spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->pint->lock, flags); - __adi_gpio_unmask_irq(port, d->irq); + writel(irq_to_pintbit(port, d->irq), &regs->mask_set); spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); <at> <at> -337,6 +432,7 <at> <at> static unsigned int adi_gpio_irq_startup(struct irq_data *d) { unsigned long flags; struct gpio_port *port = irq_data_get_irq_chip_data(d); + struct gpio_pint_regs *regs = port->pint->regs; unsigned offset = irq_to_offset(port, d->irq); if (!port) { <at> <at> -347,12 +443,8 <at> <at> static unsigned int adi_gpio_irq_startup(struct irq_data *d) spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->pint->lock, flags); - if (!is_gpio_irq_enabled(port, offset)) { - enable_gpio_irq(port, offset); - __adi_gpio_irq_prepare(port, offset); - } - - __adi_gpio_unmask_irq(port, d->irq); + __adi_gpio_irq_prepare(port, offset); + writel(irq_to_pintbit(port, d->irq), &regs->mask_set); spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); <at> <at> -364,13 +456,13 <at> <at> static void adi_gpio_irq_shutdown(struct irq_data *d) { unsigned long flags; struct gpio_port *port = irq_data_get_irq_chip_data(d); + struct gpio_pint_regs *regs = port->pint->regs; unsigned offset = irq_to_offset(port, d->irq); spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->pint->lock, flags); - __adi_gpio_mask_irq(port, d->irq); - disable_gpio_irq(port, offset); + writel(irq_to_pintbit(port, d->irq), &regs->mask_clear); __adi_gpio_irq_free(port, offset); spin_unlock_irqrestore(&port->pint->lock, flags); <at> <at> -384,7 +476,7 <at> <at> static int adi_gpio_irq_type(struct irq_data *d, unsigned int type) struct gpio_pint_regs *pint_regs = port->pint->regs; unsigned offset, pintmask; unsigned int irq = d->irq; - int ret; + int ret = 0; char buf[16]; if (!port) { <at> <at> -398,55 +490,45 <at> <at> static int adi_gpio_irq_type(struct irq_data *d, unsigned int type) spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->pint->lock, flags); - if (type == IRQ_TYPE_PROBE) { - /* only probe unenabled GPIO interrupt lines */ - if (is_gpio_irq_enabled(port, offset)) - return 0; + if (type == IRQ_TYPE_PROBE) type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; - } if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { snprintf(buf, 16, "gpio-irq%d", irq); ret = __adi_gpio_irq_request(port, offset, buf); if (ret) - return ret; - - if (!is_gpio_irq_enabled(port, offset)) { - enable_gpio_irq(port, offset); - __adi_gpio_irq_prepare(port, offset); - } - } else { - disable_gpio_irq(port, offset); - return 0; - } + goto out; + } else + goto out; if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW))) /* low or falling edge denoted by one */ - pint_regs->invert_set = pintmask; + writel(pintmask, &pint_regs->invert_set); else /* high or rising edge denoted by zero */ - pint_regs->invert_clear = pintmask; + writel(pintmask, &pint_regs->invert_clear); if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { if (gpio_get_value(offset_to_gpio(port, offset))) - pint_regs->invert_set = pintmask; + writel(pintmask, &pint_regs->invert_set); else - pint_regs->invert_clear = pintmask; + writel(pintmask, &pint_regs->invert_clear); } if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { - pint_regs->edge_set = pintmask; + writel(pintmask, &pint_regs->edge_set); __irq_set_handler_locked(irq, handle_edge_irq); } else { - pint_regs->edge_clear = pintmask; + writel(pintmask, &pint_regs->edge_clear); __irq_set_handler_locked(irq, handle_level_irq); } +out: spin_unlock_irqrestore(&port->pint->lock, flags); spin_unlock_irqrestore(&port->lock, flags); - return 0; + return ret; } #ifdef CONFIG_PM <at> <at> -469,10 +551,10 <at> <at> static int adi_pint_suspend(void) struct gpio_pint *pint; list_for_each_entry(pint, &adi_pint_list, node) { - pint->regs->mask_clear = 0xffffffff; - pint->saved_data.assign = pint->regs->assign; - pint->saved_data.edge_set = pint->regs->edge_set; - pint->saved_data.invert_set = pint->regs->invert_set; + writel(0xffffffff, &pint->regs->mask_clear); + pint->saved_data.assign = readl(&pint->regs->assign); + pint->saved_data.edge_set = readl(&pint->regs->edge_set); + pint->saved_data.invert_set = readl(&pint->regs->invert_set); } return 0; <at> <at> -483,9 +565,9 <at> <at> static void adi_pint_resume(void) struct gpio_pint *pint; list_for_each_entry(pint, &adi_pint_list, node) { - pint->regs->assign = pint->saved_data.assign; - pint->regs->edge_set = pint->saved_data.edge_set; - pint->regs->invert_set = pint->saved_data.invert_set; + writel(pint->saved_data.assign, &pint->regs->assign); + writel(pint->saved_data.edge_set, &pint->regs->edge_set); + writel(pint->saved_data.invert_set, &pint->regs->invert_set); } } <at> <at> -494,11 +576,11 <at> <at> static int adi_gpio_suspend(void) struct gpio_port *port; list_for_each_entry(port, &adi_gpio_list, node) { - port->saved_data.fer = (u16)port->regs->port_fer; - port->saved_data.mux = port->regs->port_mux; - port->saved_data.data = (u16)port->regs->data; - port->saved_data.inen = (u16)port->regs->inen; - port->saved_data.dir = (u16)port->regs->dir_set; + port->saved_data.fer = readw(&port->regs->port_fer); + port->saved_data.mux = readl(&port->regs->port_mux); + port->saved_data.data = readw(&port->regs->data); + port->saved_data.inen = readw(&port->regs->inen); + port->saved_data.dir = readw(&port->regs->dir_set); } return adi_pint_suspend(); <at> <at> -511,12 +593,12 <at> <at> static void adi_gpio_resume(void) adi_pint_resume(); list_for_each_entry(port, &adi_gpio_list, node) { - port->regs->port_mux = port->saved_data.mux; - port->regs->port_fer = port->saved_data.fer; - port->regs->inen = port->saved_data.inen; - port->regs->data_set = port->saved_data.data & - port->saved_data.dir; - port->regs->dir_set = port->saved_data.dir; + writel(port->saved_data.mux, &port->regs->port_mux); + writew(port->saved_data.fer, &port->regs->port_fer); + writew(port->saved_data.inen, &port->regs->inen); + writew(port->saved_data.data & port->saved_data.dir, + &port->regs->data_set); + writew(port->saved_data.dir, &port->regs->dir_set); } } <at> <at> -547,8 +629,8 <at> <at> static void adi_demux_gpio_irq(unsigned int inta_irq, chip->irq_ack(&desc->irq_data); } - request = regs->request; - level_mask = regs->edge_set & request; + request = readl(&regs->request); + level_mask = readl(&regs->edge_set) & request; pintbit = 0; irq = 0; <at> <at> -587,52 +669,6 <at> <at> static struct irq_chip adi_gpio_irqchip = { .irq_set_wake = adi_gpio_set_wake, }; - -static inline void port_setup(struct gpio_port *port, unsigned offset, - unsigned short usage) -{ - struct gpio_port_t *regs = port->regs; - - if (usage == GPIO_USAGE) - regs->port_fer &= ~(1 << offset); - else - regs->port_fer |= 1 << offset; -} - -static inline void portmux_setup(struct gpio_port *port, unsigned offset, - unsigned short function) -{ - struct gpio_port_t *regs = port->regs; - u32 pmux; - - pmux = regs->port_mux; - - pmux &= ~(0x3 << (2 * offset)); - pmux |= (function & 0x3) << (2 * offset); - - regs->port_mux = pmux; -} - -static inline u16 get_portmux(struct gpio_port *port, unsigned offset) -{ - struct gpio_port_t *regs = port->regs; - u32 pmux = regs->port_mux; - - return pmux >> (2 * offset) & 0x3; -} - -/*********************************************************** -* -* FUNCTIONS: ADI Processor Peripheral Resource Allocation -* and PortMux Setup -* -* INPUTS/OUTPUTS: -* per Peripheral Identifier -* label String -* -* DESCRIPTION: ADI Processor Peripheral Resource Allocation and Setup API -**************************************************************/ - int peripheral_request(unsigned short per, const char *label) { unsigned long flags; <at> <at> -779,17 +815,6 <at> <at> void peripheral_free_list(const unsigned short per[]) } EXPORT_SYMBOL(peripheral_free_list); -/*********************************************************** -* -* FUNCTIONS: ADI Processor GPIO Driver -* -* INPUTS/OUTPUTS: -* gpio PIO Number between 0 and MAX_GPIOS -* label String -* -* DESCRIPTION: ADI Processor GPIO Driver API -**************************************************************/ - static int adi_gpio_request(struct gpio_chip *chip, unsigned offset) { struct gpio_port *port; <at> <at> -856,7 +881,9 <at> <at> static void adi_gpio_free(struct gpio_chip *chip, unsigned offset) if (unlikely(!is_reserved(port, RSV_GPIO, offset))) { if (system_state == SYSTEM_BOOTING) dump_stack(); - gpio_error(port, offset); + + dev_err(port->dev, "gpio-adi2: GPIO %d wasn't requested!\n", + offset_to_gpio(port, offset)); spin_unlock_irqrestore(&port->lock, flags); return; } <at> <at> -868,52 +895,6 <at> <at> static void adi_gpio_free(struct gpio_chip *chip, unsigned offset) spin_unlock_irqrestore(&port->lock, flags); } -static int __adi_gpio_irq_request(struct gpio_port *port, unsigned offset, - const char *label) -{ - if (unlikely(is_reserved(port, RSV_PERI, offset))) { - if (system_state == SYSTEM_BOOTING) - dump_stack(); - dev_err(port->dev, - "gpio-adi2: GPIO %d is already reserved as Peripheral by %s !\n", - offset_to_gpio(port, offset), get_label(port, offset)); - return -EBUSY; - } - if (unlikely(is_reserved(port, RSV_GPIO, offset))) - dev_err(port->dev, - "gpio-adi2: GPIO %d is already reserved by %s!\n", - offset_to_gpio(port, offset), get_label(port, offset)); - - reserve(port, RSV_INT, offset); - set_label(port, offset, label); - - port_setup(port, offset, GPIO_USAGE); - return 0; -} - -static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset) -{ - if (unlikely(!is_reserved(port, RSV_INT, offset))) { - if (system_state == SYSTEM_BOOTING) - dump_stack(); - gpio_error(port, offset); - return; - } - - unreserve(port, RSV_INT, offset); - - set_label(port, offset, "free"); -} - -static inline void __adi_gpio_direction_input(struct gpio_port *port, - unsigned offset) -{ - struct gpio_port_t *regs = port->regs; - - regs->dir_clear = 1 << offset; - regs->inen |= 1 << offset; -} - static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { struct gpio_port *port; <at> <at> -924,25 +905,20 <at> <at> static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset) spin_lock_irqsave(&port->lock, flags); if (unlikely(!is_reserved(port, RSV_GPIO, offset))) { - gpio_error(port, offset); + dev_err(port->dev, "gpio-adi2: GPIO %d wasn't requested!\n", + offset_to_gpio(port, offset)); spin_unlock_irqrestore(&port->lock, flags); return -EINVAL; } - __adi_gpio_direction_input(port, offset); + writew(1 << offset, &port->regs->dir_clear); + writew(readw(&port->regs->inen) | (1 << offset), &port->regs->inen); spin_unlock_irqrestore(&port->lock, flags); return 0; } -static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset) -{ - port_setup(port, offset, GPIO_USAGE); - - __adi_gpio_direction_input(port, offset); -} - static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset, int value) { <at> <at> -953,9 +929,9 <at> <at> static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset, spin_lock_irqsave(&port->lock, flags); if (value) - regs->data_set = 1 << offset; + writew(1 << offset, &regs->data_set); else - regs->data_clear = 1 << offset; + writew(1 << offset, &regs->data_clear); spin_unlock_irqrestore(&port->lock, flags); } <at> <at> -970,14 +946,15 <at> <at> static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset, spin_lock_irqsave(&port->lock, flags); if (unlikely(!is_reserved(port, RSV_GPIO, offset))) { - gpio_error(port, offset); + dev_err(port->dev, "gpio-adi2: GPIO %d wasn't requested!\n", + offset_to_gpio(port, offset)); spin_unlock_irqrestore(&port->lock, flags); return -EINVAL; } - regs->inen &= ~(1 << offset); + writew(readw(&regs->inen) & ~(1 << offset), &regs->inen); adi_gpio_set_value(chip, offset, value); - regs->dir_set = 1 << offset; + writew(1 << offset, &regs->dir_set); spin_unlock_irqrestore(&port->lock, flags); <at> <at> -993,7 +970,7 <at> <at> static int adi_gpio_get_value(struct gpio_chip *chip, unsigned offset) spin_lock_irqsave(&port->lock, flags); - ret = (1 & (regs->data >> offset)); + ret = 1 & (readw(&regs->data) >> offset); spin_unlock_irqrestore(&port->lock, flags); <at> <at> -1013,7 +990,7 <at> <at> static inline unsigned short get_gpio_dir(struct gpio_port *port, { struct gpio_port_t *regs = port->regs; - return 0x01 & (regs->dir_clear >> offset); + return 1 & (readw(&regs->dir_clear) >> offset); } static int gpio_proc_show(struct seq_file *m, void *v) <at> <at> -1078,8 +1055,8 <at> <at> static int adi_pint_map_port(struct gpio_pint *pint, u8 assign, u8 map, pint->map_count++; - regs->assign = (regs->assign & (0xFFFF << !assign * 16)) | - (((map << 8) | map) << assign * 16); + writel((readl(&regs->assign) & (0xFFFF << !assign * 16)) | + (((map << 8) | map) << assign * 16), &regs->assign); pint->gpio_irq_base[assign] = irq_base; diff --git a/include/linux/platform_data/gpio-adi2.h b/include/linux/platform_data/gpio-adi2.h index 2b6efee..195e52c 100644 --- a/include/linux/platform_data/gpio-adi2.h +++ b/include/linux/platform_data/gpio-adi2.h <at> <at> -3,7 +3,7 <at> <at> * * Copyright 2007-2013 Analog Devices Inc. * - * Licensed under the GPL-2 or later + * Licensed under the GPLv2 or later */ <at> <at> -13,14 +13,24 <at> <at> #include <linux/io.h> #include <linux/platform_device.h> +/** + * struct adi_gpio_platform_data - GPIO platform data for ADI GPIO2 device. + * + * <at> port_pin_base: Optional global GPIO index of the GPIO bank. + * 0 means driver decides. + * <at> port_width: PIN number of the GPIO bank device + * <at> pint_id: GPIO PINT device id that this GPIO bank should map to. + * <at> pint_assign: The 32-bit GPIO PINT registers can be divided into 2 parts. A + * GPIO bank can be mapped into either low 16 bits[0] or high 16 + * bits[1] of each PINT register. + * <at> pint_map: GIOP bank mapping code in PINT device + */ struct adi_gpio_platform_data { - int port_pin_base; /* optional, 0 - driver decides */ - int port_width; - u8 pint_id; /* which pint to map the gpio port */ - u8 pint_assign; /* 0 - assgin to 1ow 16 bits - * 1 - assign to high 16 bits - */ - u8 pint_map; /* port mapping mask in pint */ + unsigned int port_pin_base; + unsigned int port_width; + u8 pint_id; + u8 pint_assign; + u8 pint_map; }; #endif
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=c11f1561a148eead0f59247845d745519440aa78
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

- Change bit variables into bool variables.
- Change register type from unsigned type into uX.
- Write proper kerneldoc instead of inline comments.
- Define GPIO offset as u8.
- No need for a simple helper, inline it.
- Avoid forward-declarations
- Skip large boilerplate function description
- Remove irq enable status check in irq_chip operation.
- Access device registers by read[l|w|b] and write[l|w|b].

Signed-off-by: Sonic Zhang &lt;sonic.zhang@...&gt;
---
 drivers/gpio/gpio-adi2.c                |  495 +++++++++++++++----------------
 include/linux/platform_data/gpio-adi2.h |   26 ++-
 2 files changed, 254 insertions(+), 267 deletions(-)

<span>diff --git a/drivers/gpio/gpio-adi2.c b/drivers/gpio/gpio-adi2.c</span>
<span>index c1b9102..da2d18e 100644</span>
<span>--- a/drivers/gpio/gpio-adi2.c</span>
<span>+++ b/drivers/gpio/gpio-adi2.c</span>
<span> <at>  <at>  -3,7 +3,7  <at>  <at> </span>
  *
  * Copyright 2007-2013 Analog Devices Inc.
  *
<span>- * Licensed under the GPL-2 or later</span>
<span>+ * Licensed under the GPLv2 or later</span>
  */

 #include &lt;linux/delay.h&gt;
<span> <at>  <at>  -26,29 +26,62  <at>  <at>  static LIST_HEAD(adi_pint_list);</span>
 #define RSV_INT		2
 #define RSV_PERI	3

<span>+/**≤/span>
<span>+ * struct gpio_reserve_map - a GPIO map structure containing the</span>
<span>+ * reservation status of each PIN.</span>
<span>+ *</span>
<span>+ *  <at> owner: who request the reservation</span>
<span>+ *  <at> rsv_gpio: if this pin is reserved as GPIO</span>
<span>+ *  <at> rsv_int: if this pin is reserved as interrupt</span>
<span>+ *  <at> rsv_peri: if this pin is reserved as part of a peripheral device</span>
<span>+ */</span>
 struct gpio_reserve_map {
 	unsigned char owner[RESOURCE_LABEL_SIZE];
<span>-	unsigned char irq_enabled:1;</span>
<span>-	unsigned char rsv_gpio:1;</span>
<span>-	unsigned char rsv_int:1;</span>
<span>-	unsigned char rsv_peri:1;</span>
<span>+	bool rsv_gpio;</span>
<span>+	bool rsv_int;</span>
<span>+	bool rsv_peri;</span>
 };

<span>+/**≤/span>
<span>+ * struct gpio_port_saved - GPIO port registers that should be saved between</span>
<span>+ * power suspend and resume operations.</span>
<span>+ *</span>
<span>+ *  <at> fer: PORTx_FER register</span>
<span>+ *  <at> data: PORTx_DATA register</span>
<span>+ *  <at> dir: PORTx_DIR register</span>
<span>+ *  <at> inen: PORTx_INEN register</span>
<span>+ *  <at> mux: PORTx_MUX register</span>
<span>+ */</span>
 struct gpio_port_saved {
<span>-	unsigned short fer;</span>
<span>-	unsigned short data;</span>
<span>-	unsigned short dir;</span>
<span>-	unsigned short inen;</span>
<span>-	unsigned int mux;</span>
<span>+	u16 fer;</span>
<span>+	u16 data;</span>
<span>+	u16 dir;</span>
<span>+	u16 inen;</span>
<span>+	u32 mux;</span>
 };

<span>+/**≤/span>
<span>+ * struct gpio_pint - GPIO interrupt controller device. Multiple ADI GPIO</span>
<span>+ * banks can be mapped into one GPIO interrupt controller.</span>
<span>+ *</span>
<span>+ *  <at> node: All gpio_pint instances are added to a global list.</span>
<span>+ *  <at> base: GPIO PINT device register base address</span>
<span>+ *  <at> irq: IRQ of the GPIO PINT device, it is the parent IRQ of all</span>
<span>+ *       GPIO IRQs mapping to this device.</span>
<span>+ *  <at> gpio_irq_base: [0] means gpio irq base is in low 16-bit registers.</span>
<span>+ *                 [1] means gpio irq base is in high 16-bit registers.</span>
<span>+ *  <at> regs: address pointer to the GPIO PINT device</span>
<span>+ *  <at> map_count: No more than 2 GPIO banks can be mapped to this PINT device.</span>
<span>+ *  <at> lock: This lock make sure the irq_chip operations to one GPIO PINT device</span>
<span>+ *        for different GPIO interrrupts are atomic.</span>
<span>+ *  <at> pint_map_port: Set up the mapping between one GPIO PINT device and</span>
<span>+ *                 multiple GPIO banks.</span>
<span>+ */</span>
 struct gpio_pint {
 	struct list_head node;
<span>-	void __iomem *base;	/* Port interrupt controller MMR base */</span>
<span>-	int irq;		/* Port interrupt controller demux IRQ */</span>
<span>-	int gpio_irq_base[2];	/* [0] is gpio irq base in low 16 bit pint.</span>
<span>-				 * [1] is gpio irq base in high 16 bit pint.</span>
<span>-				 */</span>
<span>+	void __iomem *base;</span>
<span>+	int irq;</span>
<span>+	int gpio_irq_base[2];</span>
 	struct gpio_pint_regs *regs;
 	struct adi_pm_pint_save saved_data;
 	int map_count;
<span> <at>  <at>  -58,21 +91,41  <at>  <at>  struct gpio_pint {</span>
 				u8 map, int irq_base);
 };

<span>+/**≤/span>
<span>+ * struct gpio_pint - GPIO bank device. Multiple ADI GPIO banks can be mapped</span>
<span>+ * into one GPIO interrupt controller.</span>
<span>+ *</span>
<span>+ *  <at> node: All gpio_pint instances are added to a global list.</span>
<span>+ *  <at> base: GPIO bank device register base address</span>
<span>+ *  <at> pin_base: base global GPIO pin index of the GPIO bank device</span>
<span>+ *  <at> irq_base: base IRQ of the GPIO bank device</span>
<span>+ *  <at> width: PIN number of the GPIO bank device</span>
<span>+ *  <at> regs: address pointer to the GPIO bank device</span>
<span>+ *  <at> saved_data: registers that should be saved between PM operations.</span>
<span>+ *  <at> dev: device structure of this GPIO bank</span>
<span>+ *  <at> pint: GPIO PINT device that this GPIO bank mapped to</span>
<span>+ *  <at> pint_map: GIOP bank mapping code in PINT device</span>
<span>+ *  <at> pint_assign: The 32-bit GPIO PINT registers can be divided into 2 parts. A</span>
<span>+ *               GPIO bank can be mapped into either low 16 bits[0] or high 16</span>
<span>+ *               bits[1] of each PINT register.</span>
<span>+ *  <at> lock: This lock make sure the irq_chip operations to one GPIO PINT device</span>
<span>+ *        for different GPIO interrrupts are atomic.</span>
<span>+ *  <at> chip: abstract a GPIO controller</span>
<span>+ *  <at> rsvmap: Reservation map array for each pin in the GPIO bank</span>
<span>+ */</span>
 struct gpio_port {
 	struct list_head node;
 	void __iomem *base;
<span>-	int pin_base;</span>
<span>-	int irq_base;</span>
<span>-	int width;</span>
<span>+	unsigned int pin_base;</span>
<span>+	unsigned int irq_base;</span>
<span>+	unsigned int width;</span>
 	struct gpio_port_t *regs;
 	struct gpio_port_saved saved_data;
 	struct device *dev;

 	struct gpio_pint *pint;
<span>-	u8 pint_map;		/* port mapping mask in pint */</span>
<span>-	u8 pint_assign;		/* 0 - assgin to pint 1ow 16 bits</span>
<span>-				 * 1 - assign to pint high 16 bits</span>
<span>-				 */</span>
<span>+	u8 pint_map;</span>
<span>+	u8 pint_assign;</span>

 	spinlock_t lock;
 	struct gpio_chip chip;
<span> <at>  <at>  -80,17 +133,17  <at>  <at>  struct gpio_port {</span>
 	struct gpio_reserve_map rsvmap[];
 };

<span>-static inline unsigned offset_to_gpio(struct gpio_port *port, unsigned offset)</span>
<span>+static inline unsigned offset_to_gpio(struct gpio_port *port, u8 offset)</span>
 {
 	return offset + port-&gt;chip.base;
 }

<span>-static inline unsigned gpio_to_offset(struct gpio_port *port, unsigned gpio)</span>
<span>+static inline u8 gpio_to_offset(struct gpio_port *port, unsigned gpio)</span>
 {
 	return gpio - port-&gt;chip.base;
 }

<span>-static inline unsigned irq_to_offset(struct gpio_port *port, int irq)</span>
<span>+static inline u8 irq_to_offset(struct gpio_port *port, int irq)</span>
 {
 	int offset;

<span> <at>  <at>  -106,12 +159,6  <at>  <at>  static inline unsigned irq_to_pintbit(struct gpio_port *port, int irq)</span>
 	return (1 &lt;&lt; irq_to_offset(port, irq)) &lt;&lt; (port-&gt;pint_assign * 16);
 }

<span>-static void gpio_error(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	dev_err(port-&gt;dev, "gpio-adi2: GPIO %d wasn't requested!\n",</span>
<span>-		offset_to_gpio(port, offset));</span>
<span>-}</span>
<span>-</span>
 static void set_label(struct gpio_port *port, unsigned offset,
 	const char *label)
 {
<span> <at>  <at>  -143,32 +190,16  <at>  <at>  static int cmp_label(struct gpio_port *port, unsigned offset, const char *label)</span>
 		return -EINVAL;
 }

<span>-static inline unsigned int is_gpio_irq_enabled(struct gpio_port *port,</span>
<span>-	unsigned offset)</span>
<span>-{</span>
<span>-	return port-&gt;rsvmap[offset].irq_enabled;</span>
<span>-}</span>
<span>-</span>
<span>-static inline void enable_gpio_irq(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	port-&gt;rsvmap[offset].irq_enabled = 1;</span>
<span>-}</span>
<span>-</span>
<span>-static inline void disable_gpio_irq(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	port-&gt;rsvmap[offset].irq_enabled = 0;</span>
<span>-}</span>
<span>-</span>
 static inline unsigned int is_reserved(struct gpio_port *port, char type,
 	unsigned offset)
 {
 	switch (type) {
 	case RSV_GPIO:
<span>-		return port-&gt;rsvmap[offset].rsv_gpio == 1;</span>
<span>+		return port-&gt;rsvmap[offset].rsv_gpio == true;</span>
 	case RSV_INT:
<span>-		return port-&gt;rsvmap[offset].rsv_int == 1;</span>
<span>+		return port-&gt;rsvmap[offset].rsv_int == true;</span>
 	case RSV_PERI:
<span>-		return port-&gt;rsvmap[offset].rsv_peri == 1;</span>
<span>+		return port-&gt;rsvmap[offset].rsv_peri == true;</span>
 	}

 	return 0;
<span> <at>  <at>  -178,13 +209,13  <at>  <at>  static inline void reserve(struct gpio_port *port, char type, unsigned offset)</span>
 {
 	switch (type) {
 	case RSV_GPIO:
<span>-		port-&gt;rsvmap[offset].rsv_gpio = 1;</span>
<span>+		port-&gt;rsvmap[offset].rsv_gpio = true;</span>
 		break;
 	case RSV_INT:
<span>-		port-&gt;rsvmap[offset].rsv_int = 1;</span>
<span>+		port-&gt;rsvmap[offset].rsv_int = true;</span>
 		break;
 	case RSV_PERI:
<span>-		port-&gt;rsvmap[offset].rsv_peri = 1;</span>
<span>+		port-&gt;rsvmap[offset].rsv_peri = true;</span>
 		break;
 	}
 }
<span> <at>  <at>  -193,13 +224,13  <at>  <at>  static inline void unreserve(struct gpio_port *port, char type, unsigned offset)</span>
 {
 	switch (type) {
 	case RSV_GPIO:
<span>-		port-&gt;rsvmap[offset].rsv_gpio = 0;</span>
<span>+		port-&gt;rsvmap[offset].rsv_gpio = false;</span>
 		break;
 	case RSV_INT:
<span>-		port-&gt;rsvmap[offset].rsv_int = 0;</span>
<span>+		port-&gt;rsvmap[offset].rsv_int = false;</span>
 		break;
 	case RSV_PERI:
<span>-		port-&gt;rsvmap[offset].rsv_peri = 0;</span>
<span>+		port-&gt;rsvmap[offset].rsv_peri = false;</span>
 		break;
 	}
 }
<span> <at>  <at>  -236,11 +267,89  <at>  <at>  static struct gpio_pint *find_gpio_pint(unsigned pint_id)</span>
 		return NULL;
 }

<span>+static inline void port_setup(struct gpio_port *port, unsigned offset,</span>
<span>+	unsigned short usage)</span>
<span>+{</span>
<span>+	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>+</span>
<span>+	if (usage == GPIO_USAGE)</span>
<span>+		writew(readw(&amp;regs-&gt;port_fer) &amp; ~(1 &lt;&lt; offset),</span>
<span>+			&amp;regs-&gt;port_fer);</span>
<span>+	else</span>
<span>+		writew(readw(&amp;regs-&gt;port_fer) | (1 &lt;&lt; offset), &amp;regs-&gt;port_fer);</span>
<span>+}</span>
<span>+</span>
<span>+static inline void portmux_setup(struct gpio_port *port, unsigned offset,</span>
<span>+	unsigned short function)</span>
<span>+{</span>
<span>+	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>+	u32 pmux;</span>
<span>+</span>
<span>+	pmux = readl(&amp;regs-&gt;port_mux);</span>
<span>+</span>
<span>+	pmux &amp;= ~(0x3 &lt;&lt; (2 * offset));</span>
<span>+	pmux |= (function &amp; 0x3) &lt;&lt; (2 * offset);</span>
<span>+</span>
<span>+	writel(pmux, &amp;regs-&gt;port_mux);</span>
<span>+}</span>
<span>+</span>
<span>+static inline u16 get_portmux(struct gpio_port *port, unsigned offset)</span>
<span>+{</span>
<span>+	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>+	u32 pmux = readl(&amp;regs-&gt;port_mux);</span>
<span>+</span>
<span>+	return pmux &gt;&gt; (2 * offset) &amp; 0x3;</span>
<span>+}</span>
<span>+</span>
<span>+</span>
<span>+static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset)</span>
<span>+{</span>
<span>+	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>+</span>
<span>+	port_setup(port, offset, GPIO_USAGE);</span>
<span>+</span>
<span>+	writew(1 &lt;&lt; offset, &amp;regs-&gt;dir_clear);</span>
<span>+	writew(readw(&amp;regs-&gt;inen) | (1 &lt;&lt; offset), &amp;regs-&gt;inen);</span>
<span>+}</span>

<span>-static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset);</span>
 static int __adi_gpio_irq_request(struct gpio_port *port, unsigned offset,
<span>-	const char *label);</span>
<span>-static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset);</span>
<span>+	const char *label)</span>
<span>+{</span>
<span>+	if (unlikely(is_reserved(port, RSV_PERI, offset))) {</span>
<span>+		if (system_state == SYSTEM_BOOTING)</span>
<span>+			dump_stack();</span>
<span>+</span>
<span>+		dev_err(port-&gt;dev,</span>
<span>+		       "gpio-adi2: GPIO %d is already reserved as Peripheral by %s !\n",</span>
<span>+			offset_to_gpio(port, offset), get_label(port, offset));</span>
<span>+		return -EBUSY;</span>
<span>+	}</span>
<span>+	if (unlikely(is_reserved(port, RSV_GPIO, offset)))</span>
<span>+		dev_err(port-&gt;dev,</span>
<span>+			"gpio-adi2: GPIO %d is already reserved by %s!\n",</span>
<span>+			offset_to_gpio(port, offset), get_label(port, offset));</span>
<span>+</span>
<span>+	reserve(port, RSV_INT, offset);</span>
<span>+	set_label(port, offset, label);</span>
<span>+	port_setup(port, offset, GPIO_USAGE);</span>
<span>+</span>
<span>+	return 0;</span>
<span>+}</span>
<span>+</span>
<span>+static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset)</span>
<span>+{</span>
<span>+	if (unlikely(!is_reserved(port, RSV_INT, offset))) {</span>
<span>+		if (system_state == SYSTEM_BOOTING)</span>
<span>+			dump_stack();</span>
<span>+</span>
<span>+		dev_err(port-&gt;dev, "gpio-adi2: GPIO %d wasn't requested!\n",</span>
<span>+			offset_to_gpio(port, offset));</span>
<span>+		return;</span>
<span>+	}</span>
<span>+</span>
<span>+	unreserve(port, RSV_INT, offset);</span>
<span>+	set_label(port, offset, "free");</span>
<span>+}</span>

 static void adi_gpio_ack_irq(struct irq_data *d)
 {
<span> <at>  <at>  -253,13 +362,13  <at>  <at>  static void adi_gpio_ack_irq(struct irq_data *d)</span>
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

 	if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) {
<span>-		if (regs-&gt;invert_set &amp; pintbit)</span>
<span>-			regs-&gt;invert_clear = pintbit;</span>
<span>+		if (readl(&amp;regs-&gt;invert_set) &amp; pintbit)</span>
<span>+			writel(pintbit, &amp;regs-&gt;invert_clear);</span>
 		else
<span>-			regs-&gt;invert_set = pintbit;</span>
<span>+			writel(pintbit, &amp;regs-&gt;invert_set);</span>
 	}

<span>-	regs-&gt;request = pintbit;</span>
<span>+	writel(pintbit, &amp;regs-&gt;request);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
<span> <at>  <at>  -276,58 +385,44  <at>  <at>  static void adi_gpio_mask_ack_irq(struct irq_data *d)</span>
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

 	if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) {
<span>-		if (regs-&gt;invert_set &amp; pintbit)</span>
<span>-			regs-&gt;invert_clear = pintbit;</span>
<span>+		if (readl(&amp;regs-&gt;invert_set) &amp; pintbit)</span>
<span>+			writel(pintbit, &amp;regs-&gt;invert_clear);</span>
 		else
<span>-			regs-&gt;invert_set = pintbit;</span>
<span>+			writel(pintbit, &amp;regs-&gt;invert_set);</span>
 	}

<span>-	regs-&gt;request = pintbit;</span>
<span>-	regs-&gt;mask_clear = pintbit;</span>
<span>+	writel(pintbit, &amp;regs-&gt;request);</span>
<span>+	writel(pintbit, &amp;regs-&gt;mask_clear);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 }

<span>-static void __adi_gpio_mask_irq(struct gpio_port *port, int irq)</span>
<span>-{</span>
<span>-	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>
<span>-	unsigned pintbit = irq_to_pintbit(port, irq);</span>
<span>-</span>
<span>-	regs-&gt;mask_clear = pintbit;</span>
<span>-}</span>
<span>-</span>
 static void adi_gpio_mask_irq(struct irq_data *d)
 {
 	unsigned long flags;
 	struct gpio_port *port = irq_data_get_irq_chip_data(d);
<span>+	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>

 	spin_lock_irqsave(&amp;port-&gt;lock, flags);
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

<span>-	__adi_gpio_mask_irq(port, d-&gt;irq);</span>
<span>+	writel(irq_to_pintbit(port, d-&gt;irq), &amp;regs-&gt;mask_clear);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 }

<span>-static void __adi_gpio_unmask_irq(struct gpio_port *port, int irq)</span>
<span>-{</span>
<span>-	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>
<span>-	unsigned pintbit = irq_to_pintbit(port, irq);</span>
<span>-</span>
<span>-	regs-&gt;mask_set = pintbit;</span>
<span>-}</span>
<span>-</span>
 static void adi_gpio_unmask_irq(struct irq_data *d)
 {
 	unsigned long flags;
 	struct gpio_port *port = irq_data_get_irq_chip_data(d);
<span>+	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>

 	spin_lock_irqsave(&amp;port-&gt;lock, flags);
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

<span>-	__adi_gpio_unmask_irq(port, d-&gt;irq);</span>
<span>+	writel(irq_to_pintbit(port, d-&gt;irq), &amp;regs-&gt;mask_set);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
<span> <at>  <at>  -337,6 +432,7  <at>  <at>  static unsigned int adi_gpio_irq_startup(struct irq_data *d)</span>
 {
 	unsigned long flags;
 	struct gpio_port *port = irq_data_get_irq_chip_data(d);
<span>+	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>
 	unsigned offset = irq_to_offset(port, d-&gt;irq);

 	if (!port) {
<span> <at>  <at>  -347,12 +443,8  <at>  <at>  static unsigned int adi_gpio_irq_startup(struct irq_data *d)</span>
 	spin_lock_irqsave(&amp;port-&gt;lock, flags);
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

<span>-	if (!is_gpio_irq_enabled(port, offset)) {</span>
<span>-		enable_gpio_irq(port, offset);</span>
<span>-		__adi_gpio_irq_prepare(port, offset);</span>
<span>-	}</span>
<span>-</span>
<span>-	__adi_gpio_unmask_irq(port, d-&gt;irq);</span>
<span>+	__adi_gpio_irq_prepare(port, offset);</span>
<span>+	writel(irq_to_pintbit(port, d-&gt;irq), &amp;regs-&gt;mask_set);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
<span> <at>  <at>  -364,13 +456,13  <at>  <at>  static void adi_gpio_irq_shutdown(struct irq_data *d)</span>
 {
 	unsigned long flags;
 	struct gpio_port *port = irq_data_get_irq_chip_data(d);
<span>+	struct gpio_pint_regs *regs = port-&gt;pint-&gt;regs;</span>
 	unsigned offset = irq_to_offset(port, d-&gt;irq);

 	spin_lock_irqsave(&amp;port-&gt;lock, flags);
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

<span>-	__adi_gpio_mask_irq(port, d-&gt;irq);</span>
<span>-	disable_gpio_irq(port, offset);</span>
<span>+	writel(irq_to_pintbit(port, d-&gt;irq), &amp;regs-&gt;mask_clear);</span>
 	__adi_gpio_irq_free(port, offset);

 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
<span> <at>  <at>  -384,7 +476,7  <at>  <at>  static int adi_gpio_irq_type(struct irq_data *d, unsigned int type)</span>
 	struct gpio_pint_regs *pint_regs = port-&gt;pint-&gt;regs;
 	unsigned offset, pintmask;
 	unsigned int irq = d-&gt;irq;
<span>-	int ret;</span>
<span>+	int ret = 0;</span>
 	char buf[16];

 	if (!port) {
<span> <at>  <at>  -398,55 +490,45  <at>  <at>  static int adi_gpio_irq_type(struct irq_data *d, unsigned int type)</span>
 	spin_lock_irqsave(&amp;port-&gt;lock, flags);
 	spin_lock_irqsave(&amp;port-&gt;pint-&gt;lock, flags);

<span>-	if (type == IRQ_TYPE_PROBE) {</span>
<span>-		/* only probe unenabled GPIO interrupt lines */</span>
<span>-		if (is_gpio_irq_enabled(port, offset))</span>
<span>-			return 0;</span>
<span>+	if (type == IRQ_TYPE_PROBE)</span>
 		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
<span>-	}</span>

 	if (type &amp; (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
 		    IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
 		snprintf(buf, 16, "gpio-irq%d", irq);
 		ret = __adi_gpio_irq_request(port, offset, buf);
 		if (ret)
<span>-			return ret;</span>
<span>-</span>
<span>-		if (!is_gpio_irq_enabled(port, offset)) {</span>
<span>-			enable_gpio_irq(port, offset);</span>
<span>-			__adi_gpio_irq_prepare(port, offset);</span>
<span>-		}</span>
<span>-	} else {</span>
<span>-		disable_gpio_irq(port, offset);</span>
<span>-		return 0;</span>
<span>-	}</span>
<span>+			goto out;</span>
<span>+	} else</span>
<span>+		goto out;</span>

 	if ((type &amp; (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)))
 		/* low or falling edge denoted by one */
<span>-		pint_regs-&gt;invert_set = pintmask;</span>
<span>+		writel(pintmask, &amp;pint_regs-&gt;invert_set);</span>
 	else
 		/* high or rising edge denoted by zero */
<span>-		pint_regs-&gt;invert_clear = pintmask;</span>
<span>+		writel(pintmask, &amp;pint_regs-&gt;invert_clear);</span>

 	if ((type &amp; IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
 		if (gpio_get_value(offset_to_gpio(port, offset)))
<span>-			pint_regs-&gt;invert_set = pintmask;</span>
<span>+			writel(pintmask, &amp;pint_regs-&gt;invert_set);</span>
 		else
<span>-			pint_regs-&gt;invert_clear = pintmask;</span>
<span>+			writel(pintmask, &amp;pint_regs-&gt;invert_clear);</span>
 	}

 	if (type &amp; (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
<span>-		pint_regs-&gt;edge_set = pintmask;</span>
<span>+		writel(pintmask, &amp;pint_regs-&gt;edge_set);</span>
 		__irq_set_handler_locked(irq, handle_edge_irq);
 	} else {
<span>-		pint_regs-&gt;edge_clear = pintmask;</span>
<span>+		writel(pintmask, &amp;pint_regs-&gt;edge_clear);</span>
 		__irq_set_handler_locked(irq, handle_level_irq);
 	}

<span>+out:</span>
 	spin_unlock_irqrestore(&amp;port-&gt;pint-&gt;lock, flags);
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);

<span>-	return 0;</span>
<span>+	return ret;</span>
 }

 #ifdef CONFIG_PM
<span> <at>  <at>  -469,10 +551,10  <at>  <at>  static int adi_pint_suspend(void)</span>
 	struct gpio_pint *pint;

 	list_for_each_entry(pint, &amp;adi_pint_list, node) {
<span>-		pint-&gt;regs-&gt;mask_clear = 0xffffffff;</span>
<span>-		pint-&gt;saved_data.assign = pint-&gt;regs-&gt;assign;</span>
<span>-		pint-&gt;saved_data.edge_set = pint-&gt;regs-&gt;edge_set;</span>
<span>-		pint-&gt;saved_data.invert_set = pint-&gt;regs-&gt;invert_set;</span>
<span>+		writel(0xffffffff, &amp;pint-&gt;regs-&gt;mask_clear);</span>
<span>+		pint-&gt;saved_data.assign = readl(&amp;pint-&gt;regs-&gt;assign);</span>
<span>+		pint-&gt;saved_data.edge_set = readl(&amp;pint-&gt;regs-&gt;edge_set);</span>
<span>+		pint-&gt;saved_data.invert_set = readl(&amp;pint-&gt;regs-&gt;invert_set);</span>
 	}

 	return 0;
<span> <at>  <at>  -483,9 +565,9  <at>  <at>  static void adi_pint_resume(void)</span>
 	struct gpio_pint *pint;

 	list_for_each_entry(pint, &amp;adi_pint_list, node) {
<span>-		pint-&gt;regs-&gt;assign = pint-&gt;saved_data.assign;</span>
<span>-		pint-&gt;regs-&gt;edge_set = pint-&gt;saved_data.edge_set;</span>
<span>-		pint-&gt;regs-&gt;invert_set = pint-&gt;saved_data.invert_set;</span>
<span>+		writel(pint-&gt;saved_data.assign, &amp;pint-&gt;regs-&gt;assign);</span>
<span>+		writel(pint-&gt;saved_data.edge_set, &amp;pint-&gt;regs-&gt;edge_set);</span>
<span>+		writel(pint-&gt;saved_data.invert_set, &amp;pint-&gt;regs-&gt;invert_set);</span>
 	}
 }

<span> <at>  <at>  -494,11 +576,11  <at>  <at>  static int adi_gpio_suspend(void)</span>
 	struct gpio_port *port;

 	list_for_each_entry(port, &amp;adi_gpio_list, node) {
<span>-		port-&gt;saved_data.fer = (u16)port-&gt;regs-&gt;port_fer;</span>
<span>-		port-&gt;saved_data.mux = port-&gt;regs-&gt;port_mux;</span>
<span>-		port-&gt;saved_data.data = (u16)port-&gt;regs-&gt;data;</span>
<span>-		port-&gt;saved_data.inen = (u16)port-&gt;regs-&gt;inen;</span>
<span>-		port-&gt;saved_data.dir = (u16)port-&gt;regs-&gt;dir_set;</span>
<span>+		port-&gt;saved_data.fer = readw(&amp;port-&gt;regs-&gt;port_fer);</span>
<span>+		port-&gt;saved_data.mux = readl(&amp;port-&gt;regs-&gt;port_mux);</span>
<span>+		port-&gt;saved_data.data = readw(&amp;port-&gt;regs-&gt;data);</span>
<span>+		port-&gt;saved_data.inen = readw(&amp;port-&gt;regs-&gt;inen);</span>
<span>+		port-&gt;saved_data.dir = readw(&amp;port-&gt;regs-&gt;dir_set);</span>
 	}

 	return adi_pint_suspend();
<span> <at>  <at>  -511,12 +593,12  <at>  <at>  static void adi_gpio_resume(void)</span>
 	adi_pint_resume();

 	list_for_each_entry(port, &amp;adi_gpio_list, node) {
<span>-		port-&gt;regs-&gt;port_mux = port-&gt;saved_data.mux;</span>
<span>-		port-&gt;regs-&gt;port_fer = port-&gt;saved_data.fer;</span>
<span>-		port-&gt;regs-&gt;inen = port-&gt;saved_data.inen;</span>
<span>-		port-&gt;regs-&gt;data_set = port-&gt;saved_data.data &amp;</span>
<span>-					port-&gt;saved_data.dir;</span>
<span>-		port-&gt;regs-&gt;dir_set = port-&gt;saved_data.dir;</span>
<span>+		writel(port-&gt;saved_data.mux, &amp;port-&gt;regs-&gt;port_mux);</span>
<span>+		writew(port-&gt;saved_data.fer, &amp;port-&gt;regs-&gt;port_fer);</span>
<span>+		writew(port-&gt;saved_data.inen, &amp;port-&gt;regs-&gt;inen);</span>
<span>+		writew(port-&gt;saved_data.data &amp; port-&gt;saved_data.dir,</span>
<span>+					&amp;port-&gt;regs-&gt;data_set);</span>
<span>+		writew(port-&gt;saved_data.dir, &amp;port-&gt;regs-&gt;dir_set);</span>
 	}

 }
<span> <at>  <at>  -547,8 +629,8  <at>  <at>  static void adi_demux_gpio_irq(unsigned int inta_irq,</span>
 			chip-&gt;irq_ack(&amp;desc-&gt;irq_data);
 	}

<span>-	request = regs-&gt;request;</span>
<span>-	level_mask = regs-&gt;edge_set &amp; request;</span>
<span>+	request = readl(&amp;regs-&gt;request);</span>
<span>+	level_mask = readl(&amp;regs-&gt;edge_set) &amp; request;</span>

 	pintbit = 0;
 	irq = 0;
<span> <at>  <at>  -587,52 +669,6  <at>  <at>  static struct irq_chip adi_gpio_irqchip = {</span>
 	.irq_set_wake = adi_gpio_set_wake,
 };

<span>-</span>
<span>-static inline void port_setup(struct gpio_port *port, unsigned offset,</span>
<span>-	unsigned short usage)</span>
<span>-{</span>
<span>-	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>-</span>
<span>-	if (usage == GPIO_USAGE)</span>
<span>-		regs-&gt;port_fer &amp;= ~(1 &lt;&lt; offset);</span>
<span>-	else</span>
<span>-		regs-&gt;port_fer |= 1 &lt;&lt; offset;</span>
<span>-}</span>
<span>-</span>
<span>-static inline void portmux_setup(struct gpio_port *port, unsigned offset,</span>
<span>-	unsigned short function)</span>
<span>-{</span>
<span>-	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>-	u32 pmux;</span>
<span>-</span>
<span>-	pmux = regs-&gt;port_mux;</span>
<span>-</span>
<span>-	pmux &amp;= ~(0x3 &lt;&lt; (2 * offset));</span>
<span>-	pmux |= (function &amp; 0x3) &lt;&lt; (2 * offset);</span>
<span>-</span>
<span>-	regs-&gt;port_mux = pmux;</span>
<span>-}</span>
<span>-</span>
<span>-static inline u16 get_portmux(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>-	u32 pmux = regs-&gt;port_mux;</span>
<span>-</span>
<span>-	return pmux &gt;&gt; (2 * offset) &amp; 0x3;</span>
<span>-}</span>
<span>-</span>
<span>-/***********************************************************≤/span>
<span>-*</span>
<span>-* FUNCTIONS:	ADI Processor Peripheral Resource Allocation</span>
<span>-*		and PortMux Setup</span>
<span>-*</span>
<span>-* INPUTS/OUTPUTS:</span>
<span>-* per	Peripheral Identifier</span>
<span>-* label	String</span>
<span>-*</span>
<span>-* DESCRIPTION: ADI Processor Peripheral Resource Allocation and Setup API</span>
<span>-**************************************************************/</span>
<span>-</span>
 int peripheral_request(unsigned short per, const char *label)
 {
 	unsigned long flags;
<span> <at>  <at>  -779,17 +815,6  <at>  <at>  void peripheral_free_list(const unsigned short per[])</span>
 }
 EXPORT_SYMBOL(peripheral_free_list);

<span>-/***********************************************************≤/span>
<span>-*</span>
<span>-* FUNCTIONS: ADI Processor GPIO Driver</span>
<span>-*</span>
<span>-* INPUTS/OUTPUTS:</span>
<span>-* gpio	PIO Number between 0 and MAX_GPIOS</span>
<span>-* label	String</span>
<span>-*</span>
<span>-* DESCRIPTION: ADI Processor GPIO Driver API</span>
<span>-**************************************************************/</span>
<span>-</span>
 static int adi_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_port *port;
<span> <at>  <at>  -856,7 +881,9  <at>  <at>  static void adi_gpio_free(struct gpio_chip *chip, unsigned offset)</span>
 	if (unlikely(!is_reserved(port, RSV_GPIO, offset))) {
 		if (system_state == SYSTEM_BOOTING)
 			dump_stack();
<span>-		gpio_error(port, offset);</span>
<span>+</span>
<span>+		dev_err(port-&gt;dev, "gpio-adi2: GPIO %d wasn't requested!\n",</span>
<span>+			offset_to_gpio(port, offset));</span>
 		spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 		return;
 	}
<span> <at>  <at>  -868,52 +895,6  <at>  <at>  static void adi_gpio_free(struct gpio_chip *chip, unsigned offset)</span>
 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 }

<span>-static int __adi_gpio_irq_request(struct gpio_port *port, unsigned offset,</span>
<span>-	const char *label)</span>
<span>-{</span>
<span>-	if (unlikely(is_reserved(port, RSV_PERI, offset))) {</span>
<span>-		if (system_state == SYSTEM_BOOTING)</span>
<span>-			dump_stack();</span>
<span>-		dev_err(port-&gt;dev,</span>
<span>-		       "gpio-adi2: GPIO %d is already reserved as Peripheral by %s !\n",</span>
<span>-			offset_to_gpio(port, offset), get_label(port, offset));</span>
<span>-		return -EBUSY;</span>
<span>-	}</span>
<span>-	if (unlikely(is_reserved(port, RSV_GPIO, offset)))</span>
<span>-		dev_err(port-&gt;dev,</span>
<span>-			"gpio-adi2: GPIO %d is already reserved by %s!\n",</span>
<span>-			offset_to_gpio(port, offset), get_label(port, offset));</span>
<span>-</span>
<span>-	reserve(port, RSV_INT, offset);</span>
<span>-	set_label(port, offset, label);</span>
<span>-</span>
<span>-	port_setup(port, offset, GPIO_USAGE);</span>
<span>-	return 0;</span>
<span>-}</span>
<span>-</span>
<span>-static void __adi_gpio_irq_free(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	if (unlikely(!is_reserved(port, RSV_INT, offset))) {</span>
<span>-		if (system_state == SYSTEM_BOOTING)</span>
<span>-			dump_stack();</span>
<span>-		gpio_error(port, offset);</span>
<span>-		return;</span>
<span>-	}</span>
<span>-</span>
<span>-	unreserve(port, RSV_INT, offset);</span>
<span>-</span>
<span>-	set_label(port, offset, "free");</span>
<span>-}</span>
<span>-</span>
<span>-static inline void __adi_gpio_direction_input(struct gpio_port *port,</span>
<span>-	unsigned offset)</span>
<span>-{</span>
<span>-	struct gpio_port_t *regs = port-&gt;regs;</span>
<span>-</span>
<span>-	regs-&gt;dir_clear = 1 &lt;&lt; offset;</span>
<span>-	regs-&gt;inen |= 1 &lt;&lt; offset;</span>
<span>-}</span>
<span>-</span>
 static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_port *port;
<span> <at>  <at>  -924,25 +905,20  <at>  <at>  static int adi_gpio_direction_input(struct gpio_chip *chip, unsigned offset)</span>
 	spin_lock_irqsave(&amp;port-&gt;lock, flags);

 	if (unlikely(!is_reserved(port, RSV_GPIO, offset))) {
<span>-		gpio_error(port, offset);</span>
<span>+		dev_err(port-&gt;dev, "gpio-adi2: GPIO %d wasn't requested!\n",</span>
<span>+			offset_to_gpio(port, offset));</span>
 		spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 		return -EINVAL;
 	}

<span>-	__adi_gpio_direction_input(port, offset);</span>
<span>+	writew(1 &lt;&lt; offset, &amp;port-&gt;regs-&gt;dir_clear);</span>
<span>+	writew(readw(&amp;port-&gt;regs-&gt;inen) | (1 &lt;&lt; offset), &amp;port-&gt;regs-&gt;inen);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);

 	return 0;
 }

<span>-static void __adi_gpio_irq_prepare(struct gpio_port *port, unsigned offset)</span>
<span>-{</span>
<span>-	port_setup(port, offset, GPIO_USAGE);</span>
<span>-</span>
<span>-	__adi_gpio_direction_input(port, offset);</span>
<span>-}</span>
<span>-</span>
 static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset,
 	int value)
 {
<span> <at>  <at>  -953,9 +929,9  <at>  <at>  static void adi_gpio_set_value(struct gpio_chip *chip, unsigned offset,</span>
 	spin_lock_irqsave(&amp;port-&gt;lock, flags);

 	if (value)
<span>-		regs-&gt;data_set = 1 &lt;&lt; offset;</span>
<span>+		writew(1 &lt;&lt; offset, &amp;regs-&gt;data_set);</span>
 	else
<span>-		regs-&gt;data_clear = 1 &lt;&lt; offset;</span>
<span>+		writew(1 &lt;&lt; offset, &amp;regs-&gt;data_clear);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 }
<span> <at>  <at>  -970,14 +946,15  <at>  <at>  static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset,</span>
 	spin_lock_irqsave(&amp;port-&gt;lock, flags);

 	if (unlikely(!is_reserved(port, RSV_GPIO, offset))) {
<span>-		gpio_error(port, offset);</span>
<span>+		dev_err(port-&gt;dev, "gpio-adi2: GPIO %d wasn't requested!\n",</span>
<span>+			offset_to_gpio(port, offset));</span>
 		spin_unlock_irqrestore(&amp;port-&gt;lock, flags);
 		return -EINVAL;
 	}

<span>-	regs-&gt;inen &amp;= ~(1 &lt;&lt; offset);</span>
<span>+	writew(readw(&amp;regs-&gt;inen) &amp; ~(1 &lt;&lt; offset), &amp;regs-&gt;inen);</span>
 	adi_gpio_set_value(chip, offset, value);
<span>-	regs-&gt;dir_set = 1 &lt;&lt; offset;</span>
<span>+	writew(1 &lt;&lt; offset, &amp;regs-&gt;dir_set);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);

<span> <at>  <at>  -993,7 +970,7  <at>  <at>  static int adi_gpio_get_value(struct gpio_chip *chip, unsigned offset)</span>

 	spin_lock_irqsave(&amp;port-&gt;lock, flags);

<span>-	ret = (1 &amp; (regs-&gt;data &gt;&gt; offset));</span>
<span>+	ret = 1 &amp; (readw(&amp;regs-&gt;data) &gt;&gt; offset);</span>

 	spin_unlock_irqrestore(&amp;port-&gt;lock, flags);

<span> <at>  <at>  -1013,7 +990,7  <at>  <at>  static inline unsigned short get_gpio_dir(struct gpio_port *port,</span>
 {
 	struct gpio_port_t *regs = port-&gt;regs;

<span>-	return 0x01 &amp; (regs-&gt;dir_clear &gt;&gt; offset);</span>
<span>+	return 1 &amp; (readw(&amp;regs-&gt;dir_clear) &gt;&gt; offset);</span>
 }

 static int gpio_proc_show(struct seq_file *m, void *v)
<span> <at>  <at>  -1078,8 +1055,8  <at>  <at>  static int adi_pint_map_port(struct gpio_pint *pint, u8 assign, u8 map,</span>

 	pint-&gt;map_count++;

<span>-	regs-&gt;assign = (regs-&gt;assign &amp; (0xFFFF &lt;&lt; !assign * 16)) |</span>
<span>-			(((map &lt;&lt; 8) | map) &lt;&lt; assign * 16);</span>
<span>+	writel((readl(&amp;regs-&gt;assign) &amp; (0xFFFF &lt;&lt; !assign * 16)) |</span>
<span>+		(((map &lt;&lt; 8) | map) &lt;&lt; assign * 16), &amp;regs-&gt;assign);</span>

 	pint-&gt;gpio_irq_base[assign] = irq_base;

<span>diff --git a/include/linux/platform_data/gpio-adi2.h b/include/linux/platform_data/gpio-adi2.h</span>
<span>index 2b6efee..195e52c 100644</span>
<span>--- a/include/linux/platform_data/gpio-adi2.h</span>
<span>+++ b/include/linux/platform_data/gpio-adi2.h</span>
<span> <at>  <at>  -3,7 +3,7  <at>  <at> </span>
  *
  * Copyright 2007-2013 Analog Devices Inc.
  *
<span>- * Licensed under the GPL-2 or later</span>
<span>+ * Licensed under the GPLv2 or later</span>
  */

 
<span> <at>  <at>  -13,14 +13,24  <at>  <at> </span>
 #include &lt;linux/io.h&gt;
 #include &lt;linux/platform_device.h&gt;

<span>+/**≤/span>
<span>+ * struct adi_gpio_platform_data - GPIO platform data for ADI GPIO2 device.</span>
<span>+ *</span>
<span>+ *  <at> port_pin_base: Optional global GPIO index of the GPIO bank.</span>
<span>+ *                 0 means driver decides.</span>
<span>+ *  <at> port_width: PIN number of the GPIO bank device</span>
<span>+ *  <at> pint_id: GPIO PINT device id that this GPIO bank should map to.</span>
<span>+ *  <at> pint_assign: The 32-bit GPIO PINT registers can be divided into 2 parts. A</span>
<span>+ *               GPIO bank can be mapped into either low 16 bits[0] or high 16</span>
<span>+ *               bits[1] of each PINT register.</span>
<span>+ *  <at> pint_map: GIOP bank mapping code in PINT device</span>
<span>+ */</span>
 struct adi_gpio_platform_data {
<span>-	int port_pin_base;	/* optional, 0 - driver decides */</span>
<span>-	int port_width;</span>
<span>-	u8 pint_id;		/* which pint to map the gpio port */</span>
<span>-	u8 pint_assign;		/* 0 - assgin to 1ow 16 bits</span>
<span>-				 * 1 - assign to high 16 bits</span>
<span>-				 */</span>
<span>-	u8 pint_map;		/* port mapping mask in pint */</span>
<span>+	unsigned int port_pin_base;</span>
<span>+	unsigned int port_width;</span>
<span>+	u8 pint_id;</span>
<span>+	u8 pint_assign;</span>
<span>+	u8 pint_map;</span>
 };

 #endif
</div>
Sonic Zhang | 20 Jun 08:20 2013

blackfin: gpio: revise the driver description

commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=70697181ed3535a01e0a4ebd4eaca0dc7671e5b6 branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> --- drivers/gpio/gpio-adi2.c | 2 +- include/linux/platform_data/gpio-adi2.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-adi2.c b/drivers/gpio/gpio-adi2.c index 06a86cb..c1b9102 100644 --- a/drivers/gpio/gpio-adi2.c +++ b/drivers/gpio/gpio-adi2.c <at> <at> -1,5 +1,5 <at> <at> /* - * ADI GPIO Abstraction Layer + * GPIO Driver for ADI GPIO2 controller * * Copyright 2007-2013 Analog Devices Inc. * diff --git a/include/linux/platform_data/gpio-adi2.h b/include/linux/platform_data/gpio-adi2.h index f756f64..2b6efee 100644 --- a/include/linux/platform_data/gpio-adi2.h +++ b/include/linux/platform_data/gpio-adi2.h <at> <at> -1,5 +1,5 <at> <at> /* - * ADI GPIO Abstraction Layer + * GPIO Driver for ADI GPIO2 controller * * Copyright 2007-2013 Analog Devices Inc. *
<div>commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=70697181ed3535a01e0a4ebd4eaca0dc7671e5b6
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/trunk

Signed-off-by: Sonic Zhang &lt;sonic.zhang@...&gt;
---
 drivers/gpio/gpio-adi2.c                |    2 +-
 include/linux/platform_data/gpio-adi2.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

<span>diff --git a/drivers/gpio/gpio-adi2.c b/drivers/gpio/gpio-adi2.c</span>
<span>index 06a86cb..c1b9102 100644</span>
<span>--- a/drivers/gpio/gpio-adi2.c</span>
<span>+++ b/drivers/gpio/gpio-adi2.c</span>
<span> <at>  <at>  -1,5 +1,5  <at>  <at> </span>
 /*
<span>- * ADI GPIO Abstraction Layer</span>
<span>+ * GPIO Driver for ADI GPIO2 controller</span>
  *
  * Copyright 2007-2013 Analog Devices Inc.
  *
<span>diff --git a/include/linux/platform_data/gpio-adi2.h b/include/linux/platform_data/gpio-adi2.h</span>
<span>index f756f64..2b6efee 100644</span>
<span>--- a/include/linux/platform_data/gpio-adi2.h</span>
<span>+++ b/include/linux/platform_data/gpio-adi2.h</span>
<span> <at>  <at>  -1,5 +1,5  <at>  <at> </span>
 /*
<span>- * ADI GPIO Abstraction Layer</span>
<span>+ * GPIO Driver for ADI GPIO2 controller</span>
  *
  * Copyright 2007-2013 Analog Devices Inc.
  *
</div>

Gmane