ptp_qoriq: make structure/function names more consistent
Strings containing "ptp_qoriq" or "qoriq_ptp" which were used for structure/function names were complained by users. Let's just use the unique "ptp_qoriq" to make these names more consistent. This patch is just to unify the names using "ptp_qoriq". It hasn't changed any functions. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4ea7b0cf0d
commit
1e562c815e
|
@ -501,7 +501,7 @@ static int dpaa_get_ts_info(struct net_device *net_dev,
|
|||
struct device_node *mac_node = dev->of_node;
|
||||
struct device_node *fman_node = NULL, *ptp_node = NULL;
|
||||
struct platform_device *ptp_dev = NULL;
|
||||
struct qoriq_ptp *ptp = NULL;
|
||||
struct ptp_qoriq *ptp = NULL;
|
||||
|
||||
info->phc_index = -1;
|
||||
|
||||
|
|
|
@ -1492,7 +1492,7 @@ static int gfar_get_ts_info(struct net_device *dev,
|
|||
struct gfar_private *priv = netdev_priv(dev);
|
||||
struct platform_device *ptp_dev;
|
||||
struct device_node *ptp_node;
|
||||
struct qoriq_ptp *ptp = NULL;
|
||||
struct ptp_qoriq *ptp = NULL;
|
||||
|
||||
info->phc_index = -1;
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
* Register access functions
|
||||
*/
|
||||
|
||||
/* Caller must hold qoriq_ptp->lock. */
|
||||
static u64 tmr_cnt_read(struct qoriq_ptp *qoriq_ptp)
|
||||
/* Caller must hold ptp_qoriq->lock. */
|
||||
static u64 tmr_cnt_read(struct ptp_qoriq *ptp_qoriq)
|
||||
{
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u64 ns;
|
||||
u32 lo, hi;
|
||||
|
||||
|
@ -51,10 +51,10 @@ static u64 tmr_cnt_read(struct qoriq_ptp *qoriq_ptp)
|
|||
return ns;
|
||||
}
|
||||
|
||||
/* Caller must hold qoriq_ptp->lock. */
|
||||
static void tmr_cnt_write(struct qoriq_ptp *qoriq_ptp, u64 ns)
|
||||
/* Caller must hold ptp_qoriq->lock. */
|
||||
static void tmr_cnt_write(struct ptp_qoriq *ptp_qoriq, u64 ns)
|
||||
{
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u32 hi = ns >> 32;
|
||||
u32 lo = ns & 0xffffffff;
|
||||
|
||||
|
@ -62,36 +62,36 @@ static void tmr_cnt_write(struct qoriq_ptp *qoriq_ptp, u64 ns)
|
|||
qoriq_write(®s->ctrl_regs->tmr_cnt_h, hi);
|
||||
}
|
||||
|
||||
/* Caller must hold qoriq_ptp->lock. */
|
||||
static void set_alarm(struct qoriq_ptp *qoriq_ptp)
|
||||
/* Caller must hold ptp_qoriq->lock. */
|
||||
static void set_alarm(struct ptp_qoriq *ptp_qoriq)
|
||||
{
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u64 ns;
|
||||
u32 lo, hi;
|
||||
|
||||
ns = tmr_cnt_read(qoriq_ptp) + 1500000000ULL;
|
||||
ns = tmr_cnt_read(ptp_qoriq) + 1500000000ULL;
|
||||
ns = div_u64(ns, 1000000000UL) * 1000000000ULL;
|
||||
ns -= qoriq_ptp->tclk_period;
|
||||
ns -= ptp_qoriq->tclk_period;
|
||||
hi = ns >> 32;
|
||||
lo = ns & 0xffffffff;
|
||||
qoriq_write(®s->alarm_regs->tmr_alarm1_l, lo);
|
||||
qoriq_write(®s->alarm_regs->tmr_alarm1_h, hi);
|
||||
}
|
||||
|
||||
/* Caller must hold qoriq_ptp->lock. */
|
||||
static void set_fipers(struct qoriq_ptp *qoriq_ptp)
|
||||
/* Caller must hold ptp_qoriq->lock. */
|
||||
static void set_fipers(struct ptp_qoriq *ptp_qoriq)
|
||||
{
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
|
||||
set_alarm(qoriq_ptp);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper1, qoriq_ptp->tmr_fiper1);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper2, qoriq_ptp->tmr_fiper2);
|
||||
set_alarm(ptp_qoriq);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2);
|
||||
}
|
||||
|
||||
static int extts_clean_up(struct qoriq_ptp *qoriq_ptp, int index,
|
||||
static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
|
||||
bool update_event)
|
||||
{
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
struct ptp_clock_event event;
|
||||
void __iomem *reg_etts_l;
|
||||
void __iomem *reg_etts_h;
|
||||
|
@ -122,11 +122,11 @@ static int extts_clean_up(struct qoriq_ptp *qoriq_ptp, int index,
|
|||
if (update_event) {
|
||||
event.timestamp = ((u64) hi) << 32;
|
||||
event.timestamp |= lo;
|
||||
ptp_clock_event(qoriq_ptp->clock, &event);
|
||||
ptp_clock_event(ptp_qoriq->clock, &event);
|
||||
}
|
||||
|
||||
stat = qoriq_read(®s->ctrl_regs->tmr_stat);
|
||||
} while (qoriq_ptp->extts_fifo_support && (stat & valid));
|
||||
} while (ptp_qoriq->extts_fifo_support && (stat & valid));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -137,61 +137,61 @@ static int extts_clean_up(struct qoriq_ptp *qoriq_ptp, int index,
|
|||
|
||||
static irqreturn_t isr(int irq, void *priv)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = priv;
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = priv;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
struct ptp_clock_event event;
|
||||
u64 ns;
|
||||
u32 ack = 0, lo, hi, mask, val, irqs;
|
||||
|
||||
spin_lock(&qoriq_ptp->lock);
|
||||
spin_lock(&ptp_qoriq->lock);
|
||||
|
||||
val = qoriq_read(®s->ctrl_regs->tmr_tevent);
|
||||
mask = qoriq_read(®s->ctrl_regs->tmr_temask);
|
||||
|
||||
spin_unlock(&qoriq_ptp->lock);
|
||||
spin_unlock(&ptp_qoriq->lock);
|
||||
|
||||
irqs = val & mask;
|
||||
|
||||
if (irqs & ETS1) {
|
||||
ack |= ETS1;
|
||||
extts_clean_up(qoriq_ptp, 0, true);
|
||||
extts_clean_up(ptp_qoriq, 0, true);
|
||||
}
|
||||
|
||||
if (irqs & ETS2) {
|
||||
ack |= ETS2;
|
||||
extts_clean_up(qoriq_ptp, 1, true);
|
||||
extts_clean_up(ptp_qoriq, 1, true);
|
||||
}
|
||||
|
||||
if (irqs & ALM2) {
|
||||
ack |= ALM2;
|
||||
if (qoriq_ptp->alarm_value) {
|
||||
if (ptp_qoriq->alarm_value) {
|
||||
event.type = PTP_CLOCK_ALARM;
|
||||
event.index = 0;
|
||||
event.timestamp = qoriq_ptp->alarm_value;
|
||||
ptp_clock_event(qoriq_ptp->clock, &event);
|
||||
event.timestamp = ptp_qoriq->alarm_value;
|
||||
ptp_clock_event(ptp_qoriq->clock, &event);
|
||||
}
|
||||
if (qoriq_ptp->alarm_interval) {
|
||||
ns = qoriq_ptp->alarm_value + qoriq_ptp->alarm_interval;
|
||||
if (ptp_qoriq->alarm_interval) {
|
||||
ns = ptp_qoriq->alarm_value + ptp_qoriq->alarm_interval;
|
||||
hi = ns >> 32;
|
||||
lo = ns & 0xffffffff;
|
||||
qoriq_write(®s->alarm_regs->tmr_alarm2_l, lo);
|
||||
qoriq_write(®s->alarm_regs->tmr_alarm2_h, hi);
|
||||
qoriq_ptp->alarm_value = ns;
|
||||
ptp_qoriq->alarm_value = ns;
|
||||
} else {
|
||||
spin_lock(&qoriq_ptp->lock);
|
||||
spin_lock(&ptp_qoriq->lock);
|
||||
mask = qoriq_read(®s->ctrl_regs->tmr_temask);
|
||||
mask &= ~ALM2EN;
|
||||
qoriq_write(®s->ctrl_regs->tmr_temask, mask);
|
||||
spin_unlock(&qoriq_ptp->lock);
|
||||
qoriq_ptp->alarm_value = 0;
|
||||
qoriq_ptp->alarm_interval = 0;
|
||||
spin_unlock(&ptp_qoriq->lock);
|
||||
ptp_qoriq->alarm_value = 0;
|
||||
ptp_qoriq->alarm_interval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (irqs & PP1) {
|
||||
ack |= PP1;
|
||||
event.type = PTP_CLOCK_PPS;
|
||||
ptp_clock_event(qoriq_ptp->clock, &event);
|
||||
ptp_clock_event(ptp_qoriq->clock, &event);
|
||||
}
|
||||
|
||||
if (ack) {
|
||||
|
@ -210,14 +210,14 @@ static int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
|
|||
u64 adj, diff;
|
||||
u32 tmr_add;
|
||||
int neg_adj = 0;
|
||||
struct qoriq_ptp *qoriq_ptp = container_of(ptp, struct qoriq_ptp, caps);
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
|
||||
if (scaled_ppm < 0) {
|
||||
neg_adj = 1;
|
||||
scaled_ppm = -scaled_ppm;
|
||||
}
|
||||
tmr_add = qoriq_ptp->tmr_add;
|
||||
tmr_add = ptp_qoriq->tmr_add;
|
||||
adj = tmr_add;
|
||||
|
||||
/* calculate diff as adj*(scaled_ppm/65536)/1000000
|
||||
|
@ -238,16 +238,16 @@ static int ptp_qoriq_adjtime(struct ptp_clock_info *ptp, s64 delta)
|
|||
{
|
||||
s64 now;
|
||||
unsigned long flags;
|
||||
struct qoriq_ptp *qoriq_ptp = container_of(ptp, struct qoriq_ptp, caps);
|
||||
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
|
||||
|
||||
spin_lock_irqsave(&qoriq_ptp->lock, flags);
|
||||
spin_lock_irqsave(&ptp_qoriq->lock, flags);
|
||||
|
||||
now = tmr_cnt_read(qoriq_ptp);
|
||||
now = tmr_cnt_read(ptp_qoriq);
|
||||
now += delta;
|
||||
tmr_cnt_write(qoriq_ptp, now);
|
||||
set_fipers(qoriq_ptp);
|
||||
tmr_cnt_write(ptp_qoriq, now);
|
||||
set_fipers(ptp_qoriq);
|
||||
|
||||
spin_unlock_irqrestore(&qoriq_ptp->lock, flags);
|
||||
spin_unlock_irqrestore(&ptp_qoriq->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -257,13 +257,13 @@ static int ptp_qoriq_gettime(struct ptp_clock_info *ptp,
|
|||
{
|
||||
u64 ns;
|
||||
unsigned long flags;
|
||||
struct qoriq_ptp *qoriq_ptp = container_of(ptp, struct qoriq_ptp, caps);
|
||||
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
|
||||
|
||||
spin_lock_irqsave(&qoriq_ptp->lock, flags);
|
||||
spin_lock_irqsave(&ptp_qoriq->lock, flags);
|
||||
|
||||
ns = tmr_cnt_read(qoriq_ptp);
|
||||
ns = tmr_cnt_read(ptp_qoriq);
|
||||
|
||||
spin_unlock_irqrestore(&qoriq_ptp->lock, flags);
|
||||
spin_unlock_irqrestore(&ptp_qoriq->lock, flags);
|
||||
|
||||
*ts = ns_to_timespec64(ns);
|
||||
|
||||
|
@ -275,16 +275,16 @@ static int ptp_qoriq_settime(struct ptp_clock_info *ptp,
|
|||
{
|
||||
u64 ns;
|
||||
unsigned long flags;
|
||||
struct qoriq_ptp *qoriq_ptp = container_of(ptp, struct qoriq_ptp, caps);
|
||||
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
|
||||
|
||||
ns = timespec64_to_ns(ts);
|
||||
|
||||
spin_lock_irqsave(&qoriq_ptp->lock, flags);
|
||||
spin_lock_irqsave(&ptp_qoriq->lock, flags);
|
||||
|
||||
tmr_cnt_write(qoriq_ptp, ns);
|
||||
set_fipers(qoriq_ptp);
|
||||
tmr_cnt_write(ptp_qoriq, ns);
|
||||
set_fipers(ptp_qoriq);
|
||||
|
||||
spin_unlock_irqrestore(&qoriq_ptp->lock, flags);
|
||||
spin_unlock_irqrestore(&ptp_qoriq->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -292,8 +292,8 @@ static int ptp_qoriq_settime(struct ptp_clock_info *ptp,
|
|||
static int ptp_qoriq_enable(struct ptp_clock_info *ptp,
|
||||
struct ptp_clock_request *rq, int on)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = container_of(ptp, struct qoriq_ptp, caps);
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
unsigned long flags;
|
||||
u32 bit, mask = 0;
|
||||
|
||||
|
@ -311,7 +311,7 @@ static int ptp_qoriq_enable(struct ptp_clock_info *ptp,
|
|||
}
|
||||
|
||||
if (on)
|
||||
extts_clean_up(qoriq_ptp, rq->extts.index, false);
|
||||
extts_clean_up(ptp_qoriq, rq->extts.index, false);
|
||||
|
||||
break;
|
||||
case PTP_CLK_REQ_PPS:
|
||||
|
@ -321,7 +321,7 @@ static int ptp_qoriq_enable(struct ptp_clock_info *ptp,
|
|||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&qoriq_ptp->lock, flags);
|
||||
spin_lock_irqsave(&ptp_qoriq->lock, flags);
|
||||
|
||||
mask = qoriq_read(®s->ctrl_regs->tmr_temask);
|
||||
if (on) {
|
||||
|
@ -333,7 +333,7 @@ static int ptp_qoriq_enable(struct ptp_clock_info *ptp,
|
|||
|
||||
qoriq_write(®s->ctrl_regs->tmr_temask, mask);
|
||||
|
||||
spin_unlock_irqrestore(&qoriq_ptp->lock, flags);
|
||||
spin_unlock_irqrestore(&ptp_qoriq->lock, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ static const struct ptp_clock_info ptp_qoriq_caps = {
|
|||
};
|
||||
|
||||
/**
|
||||
* qoriq_ptp_nominal_freq - calculate nominal frequency according to
|
||||
* ptp_qoriq_nominal_freq - calculate nominal frequency according to
|
||||
* reference clock frequency
|
||||
*
|
||||
* @clk_src: reference clock frequency
|
||||
|
@ -365,7 +365,7 @@ static const struct ptp_clock_info ptp_qoriq_caps = {
|
|||
*
|
||||
* Return the nominal frequency
|
||||
*/
|
||||
static u32 qoriq_ptp_nominal_freq(u32 clk_src)
|
||||
static u32 ptp_qoriq_nominal_freq(u32 clk_src)
|
||||
{
|
||||
u32 remainder = 0;
|
||||
|
||||
|
@ -385,9 +385,9 @@ static u32 qoriq_ptp_nominal_freq(u32 clk_src)
|
|||
}
|
||||
|
||||
/**
|
||||
* qoriq_ptp_auto_config - calculate a set of default configurations
|
||||
* ptp_qoriq_auto_config - calculate a set of default configurations
|
||||
*
|
||||
* @qoriq_ptp: pointer to qoriq_ptp
|
||||
* @ptp_qoriq: pointer to ptp_qoriq
|
||||
* @node: pointer to device_node
|
||||
*
|
||||
* If below dts properties are not provided, this function will be
|
||||
|
@ -401,7 +401,7 @@ static u32 qoriq_ptp_nominal_freq(u32 clk_src)
|
|||
*
|
||||
* Return 0 if success
|
||||
*/
|
||||
static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
|
||||
static int ptp_qoriq_auto_config(struct ptp_qoriq *ptp_qoriq,
|
||||
struct device_node *node)
|
||||
{
|
||||
struct clk *clk;
|
||||
|
@ -411,7 +411,7 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
|
|||
u32 remainder = 0;
|
||||
u32 clk_src = 0;
|
||||
|
||||
qoriq_ptp->cksel = DEFAULT_CKSEL;
|
||||
ptp_qoriq->cksel = DEFAULT_CKSEL;
|
||||
|
||||
clk = of_clk_get(node, 0);
|
||||
if (!IS_ERR(clk)) {
|
||||
|
@ -424,12 +424,12 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
nominal_freq = qoriq_ptp_nominal_freq(clk_src);
|
||||
nominal_freq = ptp_qoriq_nominal_freq(clk_src);
|
||||
if (!nominal_freq)
|
||||
return -EINVAL;
|
||||
|
||||
qoriq_ptp->tclk_period = 1000000000UL / nominal_freq;
|
||||
qoriq_ptp->tmr_prsc = DEFAULT_TMR_PRSC;
|
||||
ptp_qoriq->tclk_period = 1000000000UL / nominal_freq;
|
||||
ptp_qoriq->tmr_prsc = DEFAULT_TMR_PRSC;
|
||||
|
||||
/* Calculate initial frequency compensation value for TMR_ADD register.
|
||||
* freq_comp = ceil(2^32 / freq_ratio)
|
||||
|
@ -440,171 +440,171 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
|
|||
if (remainder)
|
||||
freq_comp++;
|
||||
|
||||
qoriq_ptp->tmr_add = freq_comp;
|
||||
qoriq_ptp->tmr_fiper1 = DEFAULT_FIPER1_PERIOD - qoriq_ptp->tclk_period;
|
||||
qoriq_ptp->tmr_fiper2 = DEFAULT_FIPER2_PERIOD - qoriq_ptp->tclk_period;
|
||||
ptp_qoriq->tmr_add = freq_comp;
|
||||
ptp_qoriq->tmr_fiper1 = DEFAULT_FIPER1_PERIOD - ptp_qoriq->tclk_period;
|
||||
ptp_qoriq->tmr_fiper2 = DEFAULT_FIPER2_PERIOD - ptp_qoriq->tclk_period;
|
||||
|
||||
/* max_adj = 1000000000 * (freq_ratio - 1.0) - 1
|
||||
* freq_ratio = reference_clock_freq / nominal_freq
|
||||
*/
|
||||
max_adj = 1000000000ULL * (clk_src - nominal_freq);
|
||||
max_adj = div_u64(max_adj, nominal_freq) - 1;
|
||||
qoriq_ptp->caps.max_adj = max_adj;
|
||||
ptp_qoriq->caps.max_adj = max_adj;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qoriq_ptp_probe(struct platform_device *dev)
|
||||
static int ptp_qoriq_probe(struct platform_device *dev)
|
||||
{
|
||||
struct device_node *node = dev->dev.of_node;
|
||||
struct qoriq_ptp *qoriq_ptp;
|
||||
struct qoriq_ptp_registers *regs;
|
||||
struct ptp_qoriq *ptp_qoriq;
|
||||
struct ptp_qoriq_registers *regs;
|
||||
struct timespec64 now;
|
||||
int err = -ENOMEM;
|
||||
u32 tmr_ctrl;
|
||||
unsigned long flags;
|
||||
void __iomem *base;
|
||||
|
||||
qoriq_ptp = kzalloc(sizeof(*qoriq_ptp), GFP_KERNEL);
|
||||
if (!qoriq_ptp)
|
||||
ptp_qoriq = kzalloc(sizeof(*ptp_qoriq), GFP_KERNEL);
|
||||
if (!ptp_qoriq)
|
||||
goto no_memory;
|
||||
|
||||
err = -EINVAL;
|
||||
|
||||
qoriq_ptp->dev = &dev->dev;
|
||||
qoriq_ptp->caps = ptp_qoriq_caps;
|
||||
ptp_qoriq->dev = &dev->dev;
|
||||
ptp_qoriq->caps = ptp_qoriq_caps;
|
||||
|
||||
if (of_property_read_u32(node, "fsl,cksel", &qoriq_ptp->cksel))
|
||||
qoriq_ptp->cksel = DEFAULT_CKSEL;
|
||||
if (of_property_read_u32(node, "fsl,cksel", &ptp_qoriq->cksel))
|
||||
ptp_qoriq->cksel = DEFAULT_CKSEL;
|
||||
|
||||
if (of_property_read_bool(node, "fsl,extts-fifo"))
|
||||
qoriq_ptp->extts_fifo_support = true;
|
||||
ptp_qoriq->extts_fifo_support = true;
|
||||
else
|
||||
qoriq_ptp->extts_fifo_support = false;
|
||||
ptp_qoriq->extts_fifo_support = false;
|
||||
|
||||
if (of_property_read_u32(node,
|
||||
"fsl,tclk-period", &qoriq_ptp->tclk_period) ||
|
||||
"fsl,tclk-period", &ptp_qoriq->tclk_period) ||
|
||||
of_property_read_u32(node,
|
||||
"fsl,tmr-prsc", &qoriq_ptp->tmr_prsc) ||
|
||||
"fsl,tmr-prsc", &ptp_qoriq->tmr_prsc) ||
|
||||
of_property_read_u32(node,
|
||||
"fsl,tmr-add", &qoriq_ptp->tmr_add) ||
|
||||
"fsl,tmr-add", &ptp_qoriq->tmr_add) ||
|
||||
of_property_read_u32(node,
|
||||
"fsl,tmr-fiper1", &qoriq_ptp->tmr_fiper1) ||
|
||||
"fsl,tmr-fiper1", &ptp_qoriq->tmr_fiper1) ||
|
||||
of_property_read_u32(node,
|
||||
"fsl,tmr-fiper2", &qoriq_ptp->tmr_fiper2) ||
|
||||
"fsl,tmr-fiper2", &ptp_qoriq->tmr_fiper2) ||
|
||||
of_property_read_u32(node,
|
||||
"fsl,max-adj", &qoriq_ptp->caps.max_adj)) {
|
||||
"fsl,max-adj", &ptp_qoriq->caps.max_adj)) {
|
||||
pr_warn("device tree node missing required elements, try automatic configuration\n");
|
||||
|
||||
if (qoriq_ptp_auto_config(qoriq_ptp, node))
|
||||
if (ptp_qoriq_auto_config(ptp_qoriq, node))
|
||||
goto no_config;
|
||||
}
|
||||
|
||||
err = -ENODEV;
|
||||
|
||||
qoriq_ptp->irq = platform_get_irq(dev, 0);
|
||||
ptp_qoriq->irq = platform_get_irq(dev, 0);
|
||||
|
||||
if (qoriq_ptp->irq < 0) {
|
||||
if (ptp_qoriq->irq < 0) {
|
||||
pr_err("irq not in device tree\n");
|
||||
goto no_node;
|
||||
}
|
||||
if (request_irq(qoriq_ptp->irq, isr, IRQF_SHARED, DRIVER, qoriq_ptp)) {
|
||||
if (request_irq(ptp_qoriq->irq, isr, IRQF_SHARED, DRIVER, ptp_qoriq)) {
|
||||
pr_err("request_irq failed\n");
|
||||
goto no_node;
|
||||
}
|
||||
|
||||
qoriq_ptp->rsrc = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
||||
if (!qoriq_ptp->rsrc) {
|
||||
ptp_qoriq->rsrc = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
||||
if (!ptp_qoriq->rsrc) {
|
||||
pr_err("no resource\n");
|
||||
goto no_resource;
|
||||
}
|
||||
if (request_resource(&iomem_resource, qoriq_ptp->rsrc)) {
|
||||
if (request_resource(&iomem_resource, ptp_qoriq->rsrc)) {
|
||||
pr_err("resource busy\n");
|
||||
goto no_resource;
|
||||
}
|
||||
|
||||
spin_lock_init(&qoriq_ptp->lock);
|
||||
spin_lock_init(&ptp_qoriq->lock);
|
||||
|
||||
base = ioremap(qoriq_ptp->rsrc->start,
|
||||
resource_size(qoriq_ptp->rsrc));
|
||||
base = ioremap(ptp_qoriq->rsrc->start,
|
||||
resource_size(ptp_qoriq->rsrc));
|
||||
if (!base) {
|
||||
pr_err("ioremap ptp registers failed\n");
|
||||
goto no_ioremap;
|
||||
}
|
||||
|
||||
qoriq_ptp->base = base;
|
||||
ptp_qoriq->base = base;
|
||||
|
||||
if (of_device_is_compatible(node, "fsl,fman-ptp-timer")) {
|
||||
qoriq_ptp->regs.ctrl_regs = base + FMAN_CTRL_REGS_OFFSET;
|
||||
qoriq_ptp->regs.alarm_regs = base + FMAN_ALARM_REGS_OFFSET;
|
||||
qoriq_ptp->regs.fiper_regs = base + FMAN_FIPER_REGS_OFFSET;
|
||||
qoriq_ptp->regs.etts_regs = base + FMAN_ETTS_REGS_OFFSET;
|
||||
ptp_qoriq->regs.ctrl_regs = base + FMAN_CTRL_REGS_OFFSET;
|
||||
ptp_qoriq->regs.alarm_regs = base + FMAN_ALARM_REGS_OFFSET;
|
||||
ptp_qoriq->regs.fiper_regs = base + FMAN_FIPER_REGS_OFFSET;
|
||||
ptp_qoriq->regs.etts_regs = base + FMAN_ETTS_REGS_OFFSET;
|
||||
} else {
|
||||
qoriq_ptp->regs.ctrl_regs = base + CTRL_REGS_OFFSET;
|
||||
qoriq_ptp->regs.alarm_regs = base + ALARM_REGS_OFFSET;
|
||||
qoriq_ptp->regs.fiper_regs = base + FIPER_REGS_OFFSET;
|
||||
qoriq_ptp->regs.etts_regs = base + ETTS_REGS_OFFSET;
|
||||
ptp_qoriq->regs.ctrl_regs = base + CTRL_REGS_OFFSET;
|
||||
ptp_qoriq->regs.alarm_regs = base + ALARM_REGS_OFFSET;
|
||||
ptp_qoriq->regs.fiper_regs = base + FIPER_REGS_OFFSET;
|
||||
ptp_qoriq->regs.etts_regs = base + ETTS_REGS_OFFSET;
|
||||
}
|
||||
|
||||
ktime_get_real_ts64(&now);
|
||||
ptp_qoriq_settime(&qoriq_ptp->caps, &now);
|
||||
ptp_qoriq_settime(&ptp_qoriq->caps, &now);
|
||||
|
||||
tmr_ctrl =
|
||||
(qoriq_ptp->tclk_period & TCLK_PERIOD_MASK) << TCLK_PERIOD_SHIFT |
|
||||
(qoriq_ptp->cksel & CKSEL_MASK) << CKSEL_SHIFT;
|
||||
(ptp_qoriq->tclk_period & TCLK_PERIOD_MASK) << TCLK_PERIOD_SHIFT |
|
||||
(ptp_qoriq->cksel & CKSEL_MASK) << CKSEL_SHIFT;
|
||||
|
||||
spin_lock_irqsave(&qoriq_ptp->lock, flags);
|
||||
spin_lock_irqsave(&ptp_qoriq->lock, flags);
|
||||
|
||||
regs = &qoriq_ptp->regs;
|
||||
regs = &ptp_qoriq->regs;
|
||||
qoriq_write(®s->ctrl_regs->tmr_ctrl, tmr_ctrl);
|
||||
qoriq_write(®s->ctrl_regs->tmr_add, qoriq_ptp->tmr_add);
|
||||
qoriq_write(®s->ctrl_regs->tmr_prsc, qoriq_ptp->tmr_prsc);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper1, qoriq_ptp->tmr_fiper1);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper2, qoriq_ptp->tmr_fiper2);
|
||||
set_alarm(qoriq_ptp);
|
||||
qoriq_write(®s->ctrl_regs->tmr_add, ptp_qoriq->tmr_add);
|
||||
qoriq_write(®s->ctrl_regs->tmr_prsc, ptp_qoriq->tmr_prsc);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper1, ptp_qoriq->tmr_fiper1);
|
||||
qoriq_write(®s->fiper_regs->tmr_fiper2, ptp_qoriq->tmr_fiper2);
|
||||
set_alarm(ptp_qoriq);
|
||||
qoriq_write(®s->ctrl_regs->tmr_ctrl, tmr_ctrl|FIPERST|RTPE|TE|FRD);
|
||||
|
||||
spin_unlock_irqrestore(&qoriq_ptp->lock, flags);
|
||||
spin_unlock_irqrestore(&ptp_qoriq->lock, flags);
|
||||
|
||||
qoriq_ptp->clock = ptp_clock_register(&qoriq_ptp->caps, &dev->dev);
|
||||
if (IS_ERR(qoriq_ptp->clock)) {
|
||||
err = PTR_ERR(qoriq_ptp->clock);
|
||||
ptp_qoriq->clock = ptp_clock_register(&ptp_qoriq->caps, &dev->dev);
|
||||
if (IS_ERR(ptp_qoriq->clock)) {
|
||||
err = PTR_ERR(ptp_qoriq->clock);
|
||||
goto no_clock;
|
||||
}
|
||||
qoriq_ptp->phc_index = ptp_clock_index(qoriq_ptp->clock);
|
||||
ptp_qoriq->phc_index = ptp_clock_index(ptp_qoriq->clock);
|
||||
|
||||
ptp_qoriq_create_debugfs(qoriq_ptp);
|
||||
platform_set_drvdata(dev, qoriq_ptp);
|
||||
ptp_qoriq_create_debugfs(ptp_qoriq);
|
||||
platform_set_drvdata(dev, ptp_qoriq);
|
||||
|
||||
return 0;
|
||||
|
||||
no_clock:
|
||||
iounmap(qoriq_ptp->base);
|
||||
iounmap(ptp_qoriq->base);
|
||||
no_ioremap:
|
||||
release_resource(qoriq_ptp->rsrc);
|
||||
release_resource(ptp_qoriq->rsrc);
|
||||
no_resource:
|
||||
free_irq(qoriq_ptp->irq, qoriq_ptp);
|
||||
free_irq(ptp_qoriq->irq, ptp_qoriq);
|
||||
no_config:
|
||||
no_node:
|
||||
kfree(qoriq_ptp);
|
||||
kfree(ptp_qoriq);
|
||||
no_memory:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int qoriq_ptp_remove(struct platform_device *dev)
|
||||
static int ptp_qoriq_remove(struct platform_device *dev)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = platform_get_drvdata(dev);
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = platform_get_drvdata(dev);
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
|
||||
qoriq_write(®s->ctrl_regs->tmr_temask, 0);
|
||||
qoriq_write(®s->ctrl_regs->tmr_ctrl, 0);
|
||||
|
||||
ptp_qoriq_remove_debugfs(qoriq_ptp);
|
||||
ptp_clock_unregister(qoriq_ptp->clock);
|
||||
iounmap(qoriq_ptp->base);
|
||||
release_resource(qoriq_ptp->rsrc);
|
||||
free_irq(qoriq_ptp->irq, qoriq_ptp);
|
||||
kfree(qoriq_ptp);
|
||||
ptp_qoriq_remove_debugfs(ptp_qoriq);
|
||||
ptp_clock_unregister(ptp_qoriq->clock);
|
||||
iounmap(ptp_qoriq->base);
|
||||
release_resource(ptp_qoriq->rsrc);
|
||||
free_irq(ptp_qoriq->irq, ptp_qoriq);
|
||||
kfree(ptp_qoriq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -616,16 +616,16 @@ static const struct of_device_id match_table[] = {
|
|||
};
|
||||
MODULE_DEVICE_TABLE(of, match_table);
|
||||
|
||||
static struct platform_driver qoriq_ptp_driver = {
|
||||
static struct platform_driver ptp_qoriq_driver = {
|
||||
.driver = {
|
||||
.name = "ptp_qoriq",
|
||||
.of_match_table = match_table,
|
||||
},
|
||||
.probe = qoriq_ptp_probe,
|
||||
.remove = qoriq_ptp_remove,
|
||||
.probe = ptp_qoriq_probe,
|
||||
.remove = ptp_qoriq_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(qoriq_ptp_driver);
|
||||
module_platform_driver(ptp_qoriq_driver);
|
||||
|
||||
MODULE_AUTHOR("Richard Cochran <richardcochran@gmail.com>");
|
||||
MODULE_DESCRIPTION("PTP clock for Freescale QorIQ 1588 timer");
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
static int ptp_qoriq_fiper1_lpbk_get(void *data, u64 *val)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = data;
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = data;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
|
||||
|
@ -19,8 +19,8 @@ static int ptp_qoriq_fiper1_lpbk_get(void *data, u64 *val)
|
|||
|
||||
static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = data;
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = data;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
|
||||
|
@ -38,8 +38,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper1_fops, ptp_qoriq_fiper1_lpbk_get,
|
|||
|
||||
static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = data;
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = data;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
|
||||
|
@ -50,8 +50,8 @@ static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val)
|
|||
|
||||
static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val)
|
||||
{
|
||||
struct qoriq_ptp *qoriq_ptp = data;
|
||||
struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
|
||||
struct ptp_qoriq *ptp_qoriq = data;
|
||||
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
||||
u32 ctrl;
|
||||
|
||||
ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
|
||||
|
@ -67,35 +67,35 @@ static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val)
|
|||
DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper2_fops, ptp_qoriq_fiper2_lpbk_get,
|
||||
ptp_qoriq_fiper2_lpbk_set, "%llu\n");
|
||||
|
||||
void ptp_qoriq_create_debugfs(struct qoriq_ptp *qoriq_ptp)
|
||||
void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq)
|
||||
{
|
||||
struct dentry *root;
|
||||
|
||||
root = debugfs_create_dir(dev_name(qoriq_ptp->dev), NULL);
|
||||
root = debugfs_create_dir(dev_name(ptp_qoriq->dev), NULL);
|
||||
if (IS_ERR(root))
|
||||
return;
|
||||
if (!root)
|
||||
goto err_root;
|
||||
|
||||
qoriq_ptp->debugfs_root = root;
|
||||
ptp_qoriq->debugfs_root = root;
|
||||
|
||||
if (!debugfs_create_file_unsafe("fiper1-loopback", 0600, root,
|
||||
qoriq_ptp, &ptp_qoriq_fiper1_fops))
|
||||
ptp_qoriq, &ptp_qoriq_fiper1_fops))
|
||||
goto err_node;
|
||||
if (!debugfs_create_file_unsafe("fiper2-loopback", 0600, root,
|
||||
qoriq_ptp, &ptp_qoriq_fiper2_fops))
|
||||
ptp_qoriq, &ptp_qoriq_fiper2_fops))
|
||||
goto err_node;
|
||||
return;
|
||||
|
||||
err_node:
|
||||
debugfs_remove_recursive(root);
|
||||
qoriq_ptp->debugfs_root = NULL;
|
||||
ptp_qoriq->debugfs_root = NULL;
|
||||
err_root:
|
||||
dev_err(qoriq_ptp->dev, "failed to initialize debugfs\n");
|
||||
dev_err(ptp_qoriq->dev, "failed to initialize debugfs\n");
|
||||
}
|
||||
|
||||
void ptp_qoriq_remove_debugfs(struct qoriq_ptp *qoriq_ptp)
|
||||
void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
|
||||
{
|
||||
debugfs_remove_recursive(qoriq_ptp->debugfs_root);
|
||||
qoriq_ptp->debugfs_root = NULL;
|
||||
debugfs_remove_recursive(ptp_qoriq->debugfs_root);
|
||||
ptp_qoriq->debugfs_root = NULL;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ struct etts_regs {
|
|||
u32 tmr_etts2_l; /* Timestamp of general purpose external trigger */
|
||||
};
|
||||
|
||||
struct qoriq_ptp_registers {
|
||||
struct ptp_qoriq_registers {
|
||||
struct ctrl_regs __iomem *ctrl_regs;
|
||||
struct alarm_regs __iomem *alarm_regs;
|
||||
struct fiper_regs __iomem *fiper_regs;
|
||||
|
@ -136,9 +136,9 @@ struct qoriq_ptp_registers {
|
|||
#define DEFAULT_FIPER1_PERIOD 1000000000
|
||||
#define DEFAULT_FIPER2_PERIOD 100000
|
||||
|
||||
struct qoriq_ptp {
|
||||
struct ptp_qoriq {
|
||||
void __iomem *base;
|
||||
struct qoriq_ptp_registers regs;
|
||||
struct ptp_qoriq_registers regs;
|
||||
spinlock_t lock; /* protects regs */
|
||||
struct ptp_clock *clock;
|
||||
struct ptp_clock_info caps;
|
||||
|
@ -172,12 +172,12 @@ static inline void qoriq_write(unsigned __iomem *addr, u32 val)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
void ptp_qoriq_create_debugfs(struct qoriq_ptp *qoriq_ptp);
|
||||
void ptp_qoriq_remove_debugfs(struct qoriq_ptp *qoriq_ptp);
|
||||
void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq);
|
||||
void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq);
|
||||
#else
|
||||
static inline void ptp_qoriq_create_debugfs(struct qoriq_ptp *qoriq_ptp)
|
||||
static inline void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq)
|
||||
{ }
|
||||
static inline void ptp_qoriq_remove_debugfs(struct qoriq_ptp *qoriq_ptp)
|
||||
static inline void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue