Skip to contentSkip to conversation

fit blackfin uart over sport driver into common uart inftrastructure (v2)

PATCH In review sonic zhang 2 participants 5 messages Sep 16, 2009 – Sep 18, 2009 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fit blackfin uart over sport driver into common uart inftrastructure (v2)

Fit blackfin uart over sport driver into common uart inftrastructure.

1. Disable local interrupts in 32-bit reading from SPORT RX MMR to walk around the RX underflow hardware issue when this reading is interrupted by the other IRQ.

2. Enable sport uart driver to change uart baud, data bit, stop bit at runtime.

3. Move most platform data into arch specific board files.

4. Console is registered in sport uart driver as well.

5. Remove 500 us block waiting in sport tx stop code by putting a dummy data into tx fifo to make sure the sport tx stops when all bytes are shifted out except for the dummy data.

6. clean up a bit and fix up coding style.

---
 drivers/serial/Kconfig           |   24 ++
 drivers/serial/bfin_sport_uart.c |  747 ++++++++++++++++++++++++++------------
 drivers/serial/bfin_sport_uart.h |   49 ++-
 3 files changed, 571 insertions(+), 249 deletions(-)
drivers/serial/Kconfig +24 -0
index 03422ce..45f63a8 100644
@@ -1451,6 +1451,30 @@ config SPORT_BAUD_RATE
 	default 19200 if (SERIAL_SPORT_BAUD_RATE_19200)
 	default 9600 if (SERIAL_SPORT_BAUD_RATE_9600)
 
+config SERIAL_BFIN_SPORT0_UART
+	bool "Enable UART over SPORT0"
+	depends on SERIAL_BFIN_SPORT
+	help
+	  Enable UART over SPORT0
+
+config SERIAL_BFIN_SPORT1_UART
+	bool "Enable UART over SPORT1"
+	depends on SERIAL_BFIN_SPORT
+	help
+	  Enable UART over SPORT1
+
+config SERIAL_BFIN_SPORT2_UART
+	bool "Enable UART over SPORT2"
+	depends on SERIAL_BFIN_SPORT && (BF54x || BF538 || BF539)
+	help
+	  Enable UART over SPORT2
+
+config SERIAL_BFIN_SPORT3_UART
+	bool "Enable UART over SPORT3"
+	depends on SERIAL_BFIN_SPORT && (BF54x || BF538 || BF539)
+	help
+	  Enable UART over SPORT3
+
 config SERIAL_TIMBERDALE
 	tristate "Support for timberdale UART"
 	depends on MFD_TIMBERDALE
drivers/serial/bfin_sport_uart.c +519 -228

989 lines not on this page · raw message

drivers/serial/bfin_sport_uart.h +28 -21

67 lines not on this page · raw message

Signature · 1 line
1.6.0
#1 lore raw
Quoted 1 line · sonic zhang

3. Move most platform data into arch specific board files.

might as well do it right now since you've done most of it already. i.e. all of the peripheral logic should be in the boards, not the driver. so the bfin_uart_pin_req_sportx lists should get moved to the platform resources as well as the SPORT base addresses.

then we get proper device bindings between ttySS# and SPORT# by using the .id field. ttySS0 should always be SPORT0, ttySS1 should always be SPORT1, etc...

Quoted 1 line

you shouldnt add s-o-b tags for people who didnt opt for them ... i was sleeping when you wrote, committed, and e-mailed out these changes. i also handt posted these changes yet because i knew there were still issues to be worked out.

drivers/serial/bfin_sport_uart.c line 22

Quoted 4 lines
drivers/serial/bfin_sport_uart.c +2 -0
+#define DRV_NAME "bfin-sport-uart"
+#define DEVICE_NAME    "ttySS"

should really use the dev_* functions for output rather than the pr_* ones, but if you dont do that, you should add before the #include's:
#define pr_fmt(fmt) DRV_NAME ": " fmt

Quoted 4 lines

       tclkdiv = sclk/(2 * baud_rate) - 1;
-       tfsdiv = 12;
-       rclkdiv = sclk/(2 * baud_rate * 3) - 1;
+       rclkdiv = sclk/(2 * baud_rate * 2) - 1;

missing space around the "/"

Quoted 21 lines
drivers/serial/bfin_sport_uart.c +2 -1
-static int sport_uart_suspend(struct platform_device *dev, pm_message_t state)
+#ifdef CONFIG_PM
+static int sport_uart_suspend(struct platform_device *pdev, pm_message_t state)

 {
-       struct sport_uart_port *sport = platform_get_drvdata(dev);
+       struct sport_uart_port *sport = platform_get_drvdata(pdev);

-       pr_debug("%s enter\n", __func__);
+       dev_dbg(&pdev->dev, "%s enter\n", __func__); if (sport)
               uart_suspend_port(&sport_uart_reg, &sport->port);

       return 0;
 }

drivers/serial/bfin_sport_uart.c +1 -1
-static int sport_uart_resume(struct platform_device *dev)
+static int sport_uart_resume(struct platform_device *pdev)

 {
-       struct sport_uart_port *sport = platform_get_drvdata(dev);
+       struct sport_uart_port *sport = platform_get_drvdata(pdev);

Quoted 7 lines

-       pr_debug("%s enter\n", __func__);
+       dev_dbg(&pdev->dev, "%s enter\n", __func__); if (sport)
               uart_resume_port(&sport_uart_reg, &sport->port);

       return 0;
 }

these need updating to the new dev_pm_opts structure. see the changes i just did to the adp558-keys driver for a simple example.

drivers/serial/bfin_sport_uart.h

Quoted 2 lines
drivers/serial/bfin_sport_uart.h +0 -0

while you're in here, you might as well add the proper #ifndef header protection -mike
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 7 lines · Mike Frysinger
Quoted 1 line · sonic zhang

3. Move most platform data into arch specific board files.

might as well do it right now since you've done most of it already. i.e. all of the peripheral logic should be in the boards, not the driver.  so the bfin_uart_pin_req_sportx lists should get moved to the platform resources as well as the SPORT base addresses.

No. You can't. Because the console is registered and running much earlier than the platform data is initialized. You have to know the peripheral lists and base address before registering the console.

Quoted 4 lines

then we get proper device bindings between ttySS# and SPORT# by using the .id field.  ttySS0 should always be SPORT0, ttySS1 should always be SPORT1, etc...

You can't either. Because the index of tty devices is increased automatically when you successfully register a uart port. If sport0 is used for devices other than uart, uart over sport1 is always bond to ttySS0.

Quoted 7 lines
Quoted 2 lines

you shouldnt add s-o-b tags for people who didnt opt for them ... i was sleeping when you wrote, committed, and e-mailed out these changes.  i also handt posted these changes yet because i knew there were still issues to be worked out.

OK. I mean you also did some cleanup to this patch.

Quoted 10 lines

drivers/serial/bfin_sport_uart.c line 22

Quoted 5 lines
drivers/serial/bfin_sport_uart.c +2 -0
+#define DRV_NAME "bfin-sport-uart"
+#define DEVICE_NAME    "ttySS"

should really use the dev_* functions for output rather than the pr_* ones, but if you dont do that, you should add before the #include's:
#define pr_fmt(fmt) DRV_NAME ": " fmt

Quoted 7 lines
Quoted 4 lines

       tclkdiv = sclk/(2 * baud_rate) - 1;
-       tfsdiv = 12;
-       rclkdiv = sclk/(2 * baud_rate * 3) - 1;
+       rclkdiv = sclk/(2 * baud_rate * 2) - 1;

missing space around the "/"

OK.

Quoted 26 lines
Quoted 26 lines
drivers/serial/bfin_sport_uart.c +2 -1
-static int sport_uart_suspend(struct platform_device *dev, pm_message_t state)
+#ifdef CONFIG_PM
+static int sport_uart_suspend(struct platform_device *pdev, pm_message_t state)

 {
-       struct sport_uart_port *sport = platform_get_drvdata(dev);
+       struct sport_uart_port *sport = platform_get_drvdata(pdev);

-       pr_debug("%s enter\n", __func__);
+       dev_dbg(&pdev->dev, "%s enter\n", __func__); if (sport)
               uart_suspend_port(&sport_uart_reg, &sport->port);

       return 0;
 }

drivers/serial/bfin_sport_uart.c +1 -1
-static int sport_uart_resume(struct platform_device *dev)
+static int sport_uart_resume(struct platform_device *pdev)

 {
-       struct sport_uart_port *sport = platform_get_drvdata(dev);
+       struct sport_uart_port *sport = platform_get_drvdata(pdev);

-       pr_debug("%s enter\n", __func__);
+       dev_dbg(&pdev->dev, "%s enter\n", __func__); if (sport)
               uart_resume_port(&sport_uart_reg, &sport->port);

Quoted 5 lines
Quoted 2 lines

       return 0;
 }

these need updating to the new dev_pm_opts structure.  see the changes i just did to the adp558-keys driver for a simple example.

OK.

Quoted 7 lines

drivers/serial/bfin_sport_uart.h

Quoted 3 lines
drivers/serial/bfin_sport_uart.h +0 -0

while you're in here, you might as well add the proper #ifndef header protection -mike

OK.

Sonic Zhang
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 12 lines · Sonic Zhang
Quoted 4 lines · Mike Frysinger

then we get proper device bindings between ttySS# and SPORT# by using the .id field.  ttySS0 should always be SPORT0, ttySS1 should always be SPORT1, etc...

You can't either. Because the index of tty devices is increased automatically when you successfully register a uart port.  If sport0 is used for devices other than uart, uart over sport1 is always bond to ttySS0.

OK. This looks possible. I will take a look.

Sonic
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Sonic Zhang
Quoted 4 lines · Sonic Zhang
Quoted 3 lines · Mike Frysinger
Quoted 1 line · sonic zhang

3. Move most platform data into arch specific board files.

Quoted 8 lines
Quoted 4 lines

might as well do it right now since you've done most of it already. i.e. all of the peripheral logic should be in the boards, not the driver.  so the bfin_uart_pin_req_sportx lists should get moved to the platform resources as well as the SPORT base addresses.

No. You can't. Because the console is registered and running much earlier than the platform data is initialized. You have to know the peripheral lists and base address before registering the console.

this is why the early_platform_driver framework was created. i was looking into adding this to the Blackfin serial driver. check out Documentation/driver-model/platform.txt.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

you shouldnt add s-o-b tags for people who didnt opt for them ... i was sleeping when you wrote, committed, and e-mailed out these changes.  i also handt posted these changes yet because i knew there were still issues to be worked out.

OK. I mean you also did some cleanup to this patch.

well once we get these issues hashed out, i'm happy to say the code is good stuff ;)
-mike
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html