#define SUPPORT_SYSRQ
#endif
+#include <linux/clk.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/device.h>
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
int chiptype = pdev->id_entry->driver_data;
struct sccnxp_pdata *pdata = dev_get_platdata(&pdev->dev);
- int i, ret, fifosize, freq_min, freq_max;
+ int i, ret, fifosize, freq_min, freq_max, uartclk;
struct sccnxp_port *s;
void __iomem *membase;
+ struct clk *clk;
membase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(membase))
} else if (PTR_ERR(s->regulator) == -EPROBE_DEFER)
return -EPROBE_DEFER;
- if (!pdata) {
- dev_warn(&pdev->dev,
- "No platform data supplied, using defaults\n");
- s->pdata.frequency = s->freq_std;
+ clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(clk)) {
+ if (PTR_ERR(clk) == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
+ goto err_out;
+ }
+ dev_notice(&pdev->dev, "Using default clock frequency\n");
+ uartclk = s->freq_std;
} else
+ uartclk = clk_get_rate(clk);
+
+ /* Check input frequency */
+ if ((uartclk < freq_min) || (uartclk > freq_max)) {
+ dev_err(&pdev->dev, "Frequency out of bounds\n");
+ ret = -EINVAL;
+ goto err_out;
+ }
+
+ if (pdata)
memcpy(&s->pdata, pdata, sizeof(struct sccnxp_pdata));
if (s->pdata.poll_time_us) {
}
}
- /* Check input frequency */
- if ((s->pdata.frequency < freq_min) ||
- (s->pdata.frequency > freq_max)) {
- dev_err(&pdev->dev, "Frequency out of bounds\n");
- ret = -EINVAL;
- goto err_out;
- }
-
s->uart.owner = THIS_MODULE;
s->uart.dev_name = "ttySC";
s->uart.major = SCCNXP_MAJOR;
s->port[i].mapbase = res->start;
s->port[i].membase = membase;
s->port[i].regshift = s->pdata.reg_shift;
- s->port[i].uartclk = s->pdata.frequency;
+ s->port[i].uartclk = uartclk;
s->port[i].ops = &sccnxp_ops;
uart_add_one_port(&s->uart, &s->port[i]);
/* Set direction to input */
* };
*
* static struct sccnxp_pdata sc2892_info = {
- * .frequency = 3686400,
* .mctrl_cfg[0] = MCTRL_SIG(DIR_OP, LINE_OP0),
* .mctrl_cfg[1] = MCTRL_SIG(DIR_OP, LINE_OP1),
* };
/* SCCNXP platform data structure */
struct sccnxp_pdata {
- /* Frequency (extrenal clock or crystal) */
- int frequency;
/* Shift for A0 line */
const u8 reg_shift;
/* Modem control lines configuration */