mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-18 23:36:41 +07:00
MIPS: Alchemy: irda: use clk framework
Test the existence of the irda_clk clock object, use it to en/dis- able it when date is being transferred. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Patchwork: https://patchwork.linux-mips.org/patch/7470/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
415e0fec7a
commit
9178af9aa7
@ -18,6 +18,7 @@
|
|||||||
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/clk.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
@ -175,6 +176,7 @@ struct au1k_private {
|
|||||||
|
|
||||||
struct resource *ioarea;
|
struct resource *ioarea;
|
||||||
struct au1k_irda_platform_data *platdata;
|
struct au1k_irda_platform_data *platdata;
|
||||||
|
struct clk *irda_clk;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int qos_mtt_bits = 0x07; /* 1 ms or more */
|
static int qos_mtt_bits = 0x07; /* 1 ms or more */
|
||||||
@ -514,9 +516,39 @@ static irqreturn_t au1k_irda_interrupt(int dummy, void *dev_id)
|
|||||||
static int au1k_init(struct net_device *dev)
|
static int au1k_init(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct au1k_private *aup = netdev_priv(dev);
|
struct au1k_private *aup = netdev_priv(dev);
|
||||||
u32 enable, ring_address;
|
u32 enable, ring_address, phyck;
|
||||||
|
struct clk *c;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
c = clk_get(NULL, "irda_clk");
|
||||||
|
if (IS_ERR(c))
|
||||||
|
return PTR_ERR(c);
|
||||||
|
i = clk_prepare_enable(c);
|
||||||
|
if (i) {
|
||||||
|
clk_put(c);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (clk_get_rate(c)) {
|
||||||
|
case 40000000:
|
||||||
|
phyck = IR_PHYCLK_40MHZ;
|
||||||
|
break;
|
||||||
|
case 48000000:
|
||||||
|
phyck = IR_PHYCLK_48MHZ;
|
||||||
|
break;
|
||||||
|
case 56000000:
|
||||||
|
phyck = IR_PHYCLK_56MHZ;
|
||||||
|
break;
|
||||||
|
case 64000000:
|
||||||
|
phyck = IR_PHYCLK_64MHZ;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
clk_disable_unprepare(c);
|
||||||
|
clk_put(c);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
aup->irda_clk = c;
|
||||||
|
|
||||||
enable = IR_HC | IR_CE | IR_C;
|
enable = IR_HC | IR_CE | IR_C;
|
||||||
#ifndef CONFIG_CPU_LITTLE_ENDIAN
|
#ifndef CONFIG_CPU_LITTLE_ENDIAN
|
||||||
enable |= IR_BE;
|
enable |= IR_BE;
|
||||||
@ -545,7 +577,7 @@ static int au1k_init(struct net_device *dev)
|
|||||||
irda_write(aup, IR_RING_SIZE,
|
irda_write(aup, IR_RING_SIZE,
|
||||||
(RING_SIZE_64 << 8) | (RING_SIZE_64 << 12));
|
(RING_SIZE_64 << 8) | (RING_SIZE_64 << 12));
|
||||||
|
|
||||||
irda_write(aup, IR_CONFIG_2, IR_PHYCLK_48MHZ | IR_ONE_PIN);
|
irda_write(aup, IR_CONFIG_2, phyck | IR_ONE_PIN);
|
||||||
irda_write(aup, IR_RING_ADDR_CMPR, 0);
|
irda_write(aup, IR_RING_ADDR_CMPR, 0);
|
||||||
|
|
||||||
au1k_irda_set_speed(dev, 9600);
|
au1k_irda_set_speed(dev, 9600);
|
||||||
@ -619,6 +651,9 @@ static int au1k_irda_stop(struct net_device *dev)
|
|||||||
free_irq(aup->irq_tx, dev);
|
free_irq(aup->irq_tx, dev);
|
||||||
free_irq(aup->irq_rx, dev);
|
free_irq(aup->irq_rx, dev);
|
||||||
|
|
||||||
|
clk_disable_unprepare(aup->irda_clk);
|
||||||
|
clk_put(aup->irda_clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,6 +888,7 @@ static int au1k_irda_probe(struct platform_device *pdev)
|
|||||||
struct au1k_private *aup;
|
struct au1k_private *aup;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct resource *r;
|
struct resource *r;
|
||||||
|
struct clk *c;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
dev = alloc_irdadev(sizeof(struct au1k_private));
|
dev = alloc_irdadev(sizeof(struct au1k_private));
|
||||||
@ -886,6 +922,14 @@ static int au1k_irda_probe(struct platform_device *pdev)
|
|||||||
if (!aup->ioarea)
|
if (!aup->ioarea)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
/* bail out early if clock doesn't exist */
|
||||||
|
c = clk_get(NULL, "irda_clk");
|
||||||
|
if (IS_ERR(c)) {
|
||||||
|
err = PTR_ERR(c);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
clk_put(c);
|
||||||
|
|
||||||
aup->iobase = ioremap_nocache(r->start, resource_size(r));
|
aup->iobase = ioremap_nocache(r->start, resource_size(r));
|
||||||
if (!aup->iobase)
|
if (!aup->iobase)
|
||||||
goto out2;
|
goto out2;
|
||||||
|
Loading…
Reference in New Issue
Block a user