Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EM-2040 i2c fixes DO NOT MERGE #516

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
eebe170
Merge branches 'sunxi/clk-for-4.15', 'sunxi/dt-for-4.15' and 'sunxi/d…
mripard Sep 17, 2017
1718bc7
Merge branch 'sunxi/core-for-4.15' into sunxi/for-next
mripard Sep 22, 2017
3b428b0
Merge branches 'sunxi/dt-for-4.15' and 'sunxi/dt64-for-4.15' into sun…
wens Sep 27, 2017
67bf861
Merge branches 'sunxi/clk-for-4.15' and 'sunxi/dt64-for-4.15' into su…
wens Sep 29, 2017
bba731a
Merge branch 'sunxi/clk-for-4.15' into sunxi/for-next
mripard Oct 6, 2017
42d7dbe
Merge branches 'sunxi/clk-for-4.15' and 'sunxi/dt-for-4.15' into sunx…
wens Oct 11, 2017
be2aeaf
Merge branch 'sunxi/for-next', remote-tracking branch 'drm-misc/drm-m…
wens Oct 11, 2017
2960446
Merge remote-tracking branch 'regulator/topic/axp20x' into sunxi-next
wens Oct 11, 2017
10d1bcf
Merge branches 'sunxi/clk-for-4.15' and 'sunxi/dt-for-4.15' into sunx…
mripard Oct 13, 2017
3be7629
Merge branch 'sunxi/for-next' into sunxi-next
wens Oct 13, 2017
9221d86
Merge remote-tracking branch 'bluetooth-next/master' into sunxi-next
wens Oct 16, 2017
36680a7
Merge branches 'sunxi/clk-for-4.15' and 'sunxi/dt-for-4.15' into sunx…
wens Oct 18, 2017
217a487
Merge branch 'sunxi/for-next' into sunxi-next
wens Oct 18, 2017
8c95670
Merge remote-tracking branch 'drm-misc/drm-misc-next' into sunxi-next
wens Oct 18, 2017
8c05c03
Merge branch 'sunxi/dt-for-4.15' into sunxi/for-next
wens Oct 22, 2017
54c9bca
Merge branch 'sunxi/for-next' into sunxi-next
wens Oct 22, 2017
dad1b42
Merge remote-tracking branch 'slave-dma/topic/sun' into sunxi-next
wens Oct 23, 2017
b599669
Merge branches 'sunxi/dt-for-4.15' and 'sunxi/dt64-for-4.15' into sun…
mripard Nov 2, 2017
9dad3f6
Merge remote-tracking branch 'mfd/for-mfd-next' into sunxi-next
wens Nov 2, 2017
f9a642e
Merge remote-tracking branch 'sunxi-korg/sunxi/for-next' into sunxi-next
wens Nov 2, 2017
c3d8195
Merge remote-tracking branch 'asoc/topic/sunxi' into sunxi-next
wens Nov 9, 2017
c74b34f
fbdev: ssd1306: abort probe if we cannot talk to the display
oliv3r Aug 8, 2017
0bed2fc
fbdev: ssd1307: rename i2c device ids
oliv3r Dec 19, 2017
3b4ca60
fbdev: ssd1306: make output a little more consistent
oliv3r Dec 18, 2017
bc8c3e6
fbdev: ssd1306: use ratelimited error printing
oliv3r Dec 18, 2017
e19c8b8
leds: pca963x: abort probe if device is not connected
oliv3r Aug 8, 2017
683f502
leds: pca963x: alphabetize headers
May 29, 2015
e516b80
leds: pca963x: add defines and remove some magic values
oliv3r Dec 16, 2015
4121ef1
leds: pca963x: save mode when setting power_state
oliv3r Oct 4, 2017
10fd376
leds: pca963x: refactor initial led output a little
oliv3r Oct 4, 2017
1568dc6
leds: pca963x: remove whitespace and checkpatch problems
oliv3r Apr 5, 2016
acf0551
leds: pca963x: set DMBLNK as default during probe
oliv3r Mar 17, 2017
ed038f4
mfd: axp20x: fixup includes
oliv3r Jan 3, 2017
4a4efcf
mfd: axp20x: use explicit bit defines
Oct 4, 2017
03ce04d
power: suppy: axp20x: add missing include bitops.h
oliv3r Jan 3, 2017
dd35aa4
power: suppy: axp288: use the BIT() macro
oliv3r Jan 3, 2017
13b162f
regulator: axp20x: use defines for masks
oliv3r Jan 3, 2017
bb946f3
regulator: axp20x: name voltage ramping define properly
oliv3r Oct 9, 2017
27bef6e
regulator: enable power later when setting up constraints
Mar 6, 2017
c4c4e61
regulator: axp20x: AXP209: add support for set_ramp_delay
oliv3r Mar 2, 2017
aee0eb0
regulator: axp20x: add software based soft_start for LDO3
oliv3r Mar 2, 2017
eedcd47
arm: dts: sunxi: enable soft-start and ramp delay for the OLinuXino L…
oliv3r Mar 3, 2017
2d11ed2
dts: sunxi: Lime2: add full voltage range to LDO4
oliv3r Dec 11, 2017
d2ab365
dts: sunxi: OLinuXino Lime2: set proper lradc vref
oliv3r Dec 18, 2017
aeea6b1
pwm: core: do not block apply->state on period
oliv3r Mar 8, 2017
ed71150
input: of_touchscreen: fix whitespace
oliv3r Dec 11, 2017
de61fc5
input: of_touchscreen: shorten variable names
oliv3r Dec 11, 2017
3d28f05
input: of_touchscreen: rename touchscreen-size-[xy]
oliv3r Dec 11, 2017
fe30204
input: of_touchscreen: add support for minimum sizes
oliv3r Dec 13, 2017
688d6e2
input: edt-ft5x06: add support for the ft5426 controller
oliv3r Dec 13, 2017
0d4e3e7
input: edt-ft5x06: cleanup headers
oliv3r Dec 13, 2017
c957a5d
input: edt-ft5x06: only enable the irq when needed
oliv3r Dec 13, 2017
fb86a27
input: edt-ft5x06: fix some whitespace/ident issues
oliv3r Dec 14, 2017
d862555
input: edt-ft5x06: minor consistency cleanup/line length reduction
oliv3r Dec 14, 2017
5f01050
input: edt-ft5x06: shorten defines
oliv3r Dec 14, 2017
992e1c7
input: edt-ft5x06: use less magic and more defines
oliv3r Dec 15, 2017
046c810
input: edt-ft5x06: silence deferral error
oliv3r Dec 15, 2017
7207bb7
input: edt-ft5x06: sanity check on input
oliv3r Dec 18, 2017
b68c90b
input: edt-ft5x06: fix multi-touch handling
oliv3r Dec 18, 2017
cb474ef
input: edt-ft5x06: take into account the number of fingers
oliv3r Dec 18, 2017
15ecee1
input: edt-ft5x06: add polldev as an option
oliv3r Dec 18, 2017
5777ab1
input: edt-ft5x06: group r, w and rw functions
oliv3r Dec 19, 2017
4f8b339
input: edt-ft5x06: Force touchscreen to remain active
oliv3r Dec 19, 2017
93bf96d
input: ar1021: fix typo in define
oliv3r Oct 19, 2017
35ba713
gpio: pca953x: add support for the NXP pca9570
oliv3r Dec 18, 2017
8872877
ASoC: sun4i-is: also check for NULL on reset pin request
oliv3r Oct 9, 2017
b126923
serial: 8250_dw: minor code cleanup
oliv3r Mar 29, 2017
40d3e78
serial: do not treat the IIR register as a bitfield
oliv3r Mar 29, 2017
6b66bba
serial: tegra: map the iir register to default defines
oliv3r Mar 29, 2017
0365eb6
serial work
oliv3r Apr 21, 2017
7d6eb22
drm/sun4i: i2c: consolidate ddc items
oliv3r Sep 4, 2017
0200fbe
drm: sun4i: fix indenting
oliv3r Oct 10, 2017
80e9170
wip hdmi-i2c, TODO: legacy clocks not working
oliv3r Oct 20, 2017
beb2e13
fix whitespace (kconfig)
oliv3r Feb 6, 2018
6d00bfc
fix hdmi freq divider
oliv3r Feb 6, 2018
795cc47
rtc: sun6i: add missing header
oliv3r Feb 6, 2018
14d6182
of_get_matching_data
oliv3r Feb 6, 2018
ac68ebb
of_reset_control_get_exclusive helper
oliv3r Feb 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
serial: do not treat the IIR register as a bitfield
It seems that at some point, someone made the assumption that the UART
Interrupt ID Register was a bitfield and started to check if certain
bits where set.

Actually however the register contains interrupt ID's where only the MSB
seems to be used singular and the rest share at least one bit. Thus
doing bitfield operations is wrong.

This patch cleans up the serial_reg include file by ordering it and
replacing the UART_IIR_ID 'mask' with a proper mask for the register.
The OMAP uart appears to have used the two commonly 'reserved' bits 4
and 5 and thus get an UART_IIR_EXT_MASK for these two bits.

This patch then goes over all UART_IIR_* users and changes the code from
bitfield checking, to ID checking instead.

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed Dec 20, 2017
commit 40d3e78bda98d773f5814c0a1e381aedaf5f7606
8 changes: 5 additions & 3 deletions drivers/tty/serial/8250/8250_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static void serial8250_backup_timeout(unsigned long data)
}

iir = serial_in(up, UART_IIR);
iir &= UART_IIR_MASK;

/*
* This should be a safe test for anyone who doesn't trust the
Expand All @@ -297,14 +298,15 @@ static void serial8250_backup_timeout(unsigned long data)
*/
lsr = serial_in(up, UART_LSR);
up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&
if ((iir == UART_IIR_NO_INT) &&
(up->ier & UART_IER_THRI) &&
(!uart_circ_empty(&up->port.state->xmit) || up->port.x_char) &&
(lsr & UART_LSR_THRE)) {
iir &= ~(UART_IIR_ID | UART_IIR_NO_INT);
iir &= ~(UART_IIR_MASK);
iir |= UART_IIR_THRI;
}

if (!(iir & UART_IIR_NO_INT))
if (iir != UART_IIR_NO_INT)
serial8250_tx_chars(up);

if (up->port.irq)
Expand Down
5 changes: 3 additions & 2 deletions drivers/tty/serial/8250/8250_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ static int dw8250_handle_irq(struct uart_port *p)
* This problem has only been observed so far when not in DMA mode
* so we limit the workaround only to non-DMA mode.
*/
if (!up->dma && ((iir & 0x3f) == UART_IIR_RX_TIMEOUT)) {
iir &= UART_IIR_MASK;
if (!up->dma && (iir == UART_IIR_RX_TIMEOUT)) {
spin_lock_irqsave(&p->lock, flags);
status = p->serial_in(p, UART_LSR);

Expand All @@ -230,7 +231,7 @@ static int dw8250_handle_irq(struct uart_port *p)
if (serial8250_handle_irq(p, iir))
return 1;

if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
if (iir == UART_IIR_BUSY) {
/* Clear the USR */
(void)p->serial_in(p, d->usr_reg);

Expand Down
3 changes: 2 additions & 1 deletion drivers/tty/serial/8250/8250_fsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ int fsl8250_handle_irq(struct uart_port *port)
spin_lock_irqsave(&up->port.lock, flags);

iir = port->serial_in(port, UART_IIR);
if (iir & UART_IIR_NO_INT) {
iir &= UART_IIR_MASK;
if (iir == UART_IIR_NO_INT) {
spin_unlock_irqrestore(&up->port.lock, flags);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/serial/8250/8250_omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)

static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir)
{
switch (iir & 0x3f) {
switch (iir & (UART_IIR_MASK | UART_IIR_EXT_MASK)) {
case UART_IIR_RLSI:
case UART_IIR_RX_TIMEOUT:
case UART_IIR_RDI:
Expand All @@ -1044,7 +1044,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port)
serial8250_rpm_get(up);

iir = serial_port_in(port, UART_IIR);
if (iir & UART_IIR_NO_INT) {
if ((iir & UART_IIR_MASK) == UART_IIR_NO_INT) {
serial8250_rpm_put(up);
return 0;
}
Expand Down
11 changes: 6 additions & 5 deletions drivers/tty/serial/8250/8250_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ EXPORT_SYMBOL_GPL(serial8250_modem_status);

static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir)
{
switch (iir & 0x3f) {
switch (iir & UART_IIR_MASK) {
case UART_IIR_RX_TIMEOUT:
serial8250_rx_dma_flush(up);
/* fall-through */
Expand All @@ -1855,7 +1855,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
unsigned long flags;
struct uart_8250_port *up = up_to_u8250p(port);

if (iir & UART_IIR_NO_INT)
if ((iir & UART_IIR_MASK) == UART_IIR_NO_INT)
return 0;

spin_lock_irqsave(&port->lock, flags);
Expand Down Expand Up @@ -1922,7 +1922,7 @@ static int serial8250_tx_threshold_handle_irq(struct uart_port *port)
unsigned int iir = serial_port_in(port, UART_IIR);

/* TX Threshold IRQ triggered so load up FIFO */
if ((iir & UART_IIR_ID) == UART_IIR_THRI) {
if ((iir & UART_IIR_MASK) == UART_IIR_THRI) {
struct uart_8250_port *up = up_to_u8250p(port);

spin_lock_irqsave(&port->lock, flags);
Expand Down Expand Up @@ -2290,7 +2290,8 @@ int serial8250_do_startup(struct uart_port *port)
* don't trust the iir, setup a timer to kick the UART
* on a regular basis.
*/
if ((!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) ||
if ((((iir1 & UART_IIR_MASK) != UART_IIR_NO_INT) &&
((iir & UART_IIR_MASK) == UART_IIR_NO_INT)) ||
up->port.flags & UPF_BUG_THRE) {
up->bugs |= UART_BUG_THRE;
}
Expand Down Expand Up @@ -2341,7 +2342,7 @@ int serial8250_do_startup(struct uart_port *port)
iir = serial_port_in(port, UART_IIR);
serial_port_out(port, UART_IER, 0);

if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) {
if (lsr & UART_LSR_TEMT && ((iir & UART_IIR_MASK) == UART_IIR_NO_INT)) {
if (!(up->bugs & UART_BUG_TXEN)) {
up->bugs |= UART_BUG_TXEN;
pr_debug("ttyS%d - enabling bad tx status workarounds\n",
Expand Down
12 changes: 6 additions & 6 deletions drivers/tty/serial/omap-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
{
struct uart_omap_port *up = dev_id;
unsigned int iir, lsr;
unsigned int type;
irqreturn_t ret = IRQ_NONE;
int max_count = 256;

Expand All @@ -578,16 +577,15 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)

do {
iir = serial_in(up, UART_IIR);
if (iir & UART_IIR_NO_INT)
iir &= (UART_IIR_MASK | UART_IIR_EXT_MASK);
if (iir == UART_IIR_NO_INT)
break;

ret = IRQ_HANDLED;
lsr = serial_in(up, UART_LSR);

/* extract IRQ type from IIR register */
type = iir & 0x3e;

switch (type) {
switch (iir) {
case UART_IIR_MSI:
check_modem_status(up);
break;
Expand All @@ -607,10 +605,12 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
break;
case UART_IIR_XOFF:
/* FALLTHROUGH */
case UART_IIR_BUSY:
/* FALLTHROUGH */
default:
break;
}
} while (!(iir & UART_IIR_NO_INT) && max_count--);
} while ((iir != UART_IIR_NO_INT) && max_count--);

spin_unlock(&up->port.lock);

Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/serial/pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static inline irqreturn_t serial_pxa_irq(int irq, void *dev_id)
unsigned int iir, lsr;

iir = serial_in(up, UART_IIR);
if (iir & UART_IIR_NO_INT)
if ((iir & UART_IIR_MASK) == UART_IIR_NO_INT)
return IRQ_NONE;
spin_lock(&up->port.lock);
lsr = serial_in(up, UART_LSR);
Expand Down
3 changes: 2 additions & 1 deletion drivers/tty/serial/serial-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ static irqreturn_t tegra_uart_isr(int irq, void *data)
spin_lock_irqsave(&u->lock, flags);
while (1) {
iir = tegra_uart_read(tup, UART_IIR);
if (iir & UART_IIR_NO_INT) {
iir &= UART_IIR_MASK;
if (iir == UART_IIR_NO_INT) {
if (is_rx_int) {
tegra_uart_handle_rx_dma(tup);
if (tup->rx_in_progress) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/serial/sunsu.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id)

spin_lock_irqsave(&up->port.lock, flags);

} while (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT));
} while ((serial_in(up, UART_IIR) & UART_IIR_MASK) != UART_IIR_NO_INT);

spin_unlock_irqrestore(&up->port.lock, flags);

Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/serial/vr41xx_siu.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ static irqreturn_t siu_interrupt(int irq, void *dev_id)
port = (struct uart_port *)dev_id;

iir = siu_read(port, UART_IIR);
if (iir & UART_IIR_NO_INT)
if ((iir & UART_IIR_MASK) == UART_IIR_NO_INT)
return IRQ_NONE;

lsr = siu_read(port, UART_LSR);
Expand Down
8 changes: 4 additions & 4 deletions include/uapi/linux/serial_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
#define UART_IERX_SLEEP 0x10 /* Enable sleep mode */

#define UART_IIR 2 /* In: Interrupt ID Register */
#define UART_IIR_NO_INT 0x01 /* No interrupts pending */
#define UART_IIR_ID 0x0e /* Mask for the interrupt ID */
#define UART_IIR_MSI 0x00 /* Modem status interrupt */
#define UART_IIR_NO_INT 0x01 /* No interrupts pending */
#define UART_IIR_THRI 0x02 /* Transmitter holding register empty */
#define UART_IIR_RDI 0x04 /* Receiver data interrupt */
#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */

#define UART_IIR_BUSY 0x07 /* DesignWare APB Busy Detect */
#define UART_IIR_RX_TIMEOUT 0x0c /* DesignWare RX Timeout interrupt */
#define UART_IIR_MASK 0x0f /* DesignWare IIR mask */

#define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */
#define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */
#define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */
#define UART_IIR_EXT_MASK 0x30 /* OMAP extended IIR mask */

#define UART_FCR 2 /* Out: FIFO Control Register */
#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
Expand Down