summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2010-08-04 03:33:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-08-06 19:09:00 +0200
commit873910050ea0efc92db49ed233e70df7276a3f5b (patch)
treebe643e26f9513101b63be4c86bee2cb101b7f5ed /drivers
parent9080a35160e9b4b469c95518b1350cdc77912ecf (diff)
downloadbarebox-873910050ea0efc92db49ed233e70df7276a3f5b.tar.gz
barebox-873910050ea0efc92db49ed233e70df7276a3f5b.tar.xz
at91: implement clock framework
this implementation is based on linux one (v2.6.35-rc5-76-gd0c6f62) it will calculate all the clock dynamically instead of statictly this will use also the new clock framework it will also print the clock status after the console init Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/macb.c11
-rw-r--r--drivers/serial/atmel.c32
2 files changed, 37 insertions, 6 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 4feeed0ba..6864119bd 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -48,7 +48,7 @@
#include <errno.h>
#include <asm/io.h>
#include <mach/board.h>
-#include <mach/clk.h>
+#include <linux/clk.h>
#include "macb.h"
@@ -412,6 +412,9 @@ static int macb_probe(struct device_d *dev)
unsigned long macb_hz;
u32 ncfgr;
struct at91_ether_platform_data *pdata;
+#if defined(CONFIG_ARCH_AT91)
+ struct clk *pclk;
+#endif
if (!dev->platform_data) {
printf("macb: no platform_data\n");
@@ -450,7 +453,13 @@ static int macb_probe(struct device_d *dev)
* Do some basic initialization so that we at least can talk
* to the PHY
*/
+#if defined(CONFIG_ARCH_AT91)
+ pclk = clk_get(dev, "macb_clk");
+ clk_enable(pclk);
+ macb_hz = clk_get_rate(pclk);
+#else
macb_hz = get_macb_pclk_rate(0);
+#endif
if (macb_hz < 20000000)
ncfgr = MACB_BF(CLK, MACB_CLK_DIV8);
else if (macb_hz < 40000000)
diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index e9e811661..b99ec4dac 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -22,7 +22,7 @@
#include <init.h>
#include <malloc.h>
#include <asm/io.h>
-#include <mach/clk.h>
+#include <linux/clk.h>
/* USART3 register offsets */
#define USART3_CR 0x0000
@@ -309,6 +309,21 @@
<< USART3_##name##_OFFSET)) \
| USART3_BF(name,value))
+/*
+ * We wrap our port structure around the generic console_device.
+ */
+struct atmel_uart_port {
+ struct console_device uart; /* uart */
+ struct clk *clk; /* uart clock */
+ u32 uartclk;
+};
+
+static inline struct atmel_uart_port *
+to_atmel_uart_port(struct console_device *uart)
+{
+ return container_of(uart, struct atmel_uart_port, uart);
+}
+
static void atmel_serial_putc(struct console_device *cdev, char c)
{
struct device_d *dev = cdev->dev;
@@ -336,16 +351,15 @@ static int atmel_serial_getc(struct console_device *cdev)
static int atmel_serial_setbaudrate(struct console_device *cdev, int baudrate)
{
struct device_d *dev = cdev->dev;
+ struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
unsigned long divisor;
- unsigned long usart_hz;
/*
* Master Clock
* Baud Rate = --------------
* 16 * CD
*/
- usart_hz = get_usart_clk_rate(0);
- divisor = (usart_hz / 16 + baudrate / 2) / baudrate;
+ divisor = (uart->uartclk / 16 + baudrate / 2) / baudrate;
writel(USART3_BF(CD, divisor), dev->map_base + USART3_BRGR);
return 0;
@@ -359,6 +373,11 @@ static int atmel_serial_setbaudrate(struct console_device *cdev, int baudrate)
static int atmel_serial_init_port(struct console_device *cdev)
{
struct device_d *dev = cdev->dev;
+ struct atmel_uart_port *uart = to_atmel_uart_port(cdev);
+
+ uart->clk = clk_get(dev, "usart");
+ clk_enable(uart->clk);
+ uart->uartclk = clk_get_rate(uart->clk);
writel(USART3_BIT(RSTRX) | USART3_BIT(RSTTX), dev->map_base + USART3_CR);
@@ -376,9 +395,12 @@ static int atmel_serial_init_port(struct console_device *cdev)
static int atmel_serial_probe(struct device_d *dev)
{
+ struct atmel_uart_port *uart;
struct console_device *cdev;
- cdev = malloc(sizeof(struct console_device));
+ uart = malloc(sizeof(struct atmel_uart_port));
+
+ cdev = &uart->uart;
dev->type_data = cdev;
cdev->dev = dev;
cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;