2015-08-05 17:22:42 +02:00
|
|
|
/*
|
|
|
|
* octonet.c: Digital Devices network tuner driver
|
|
|
|
*
|
2017-05-17 19:42:25 +02:00
|
|
|
* Copyright (C) 2012-17 Digital Devices GmbH
|
2015-08-05 17:22:42 +02:00
|
|
|
* Marcus Metzler <mocm@metzlerbros.de>
|
|
|
|
* Ralph Metzler <rjkm@metzlerbros.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA
|
|
|
|
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ddbridge.h"
|
2017-08-02 20:22:52 +02:00
|
|
|
#include "ddbridge-io.h"
|
2015-08-05 17:22:42 +02:00
|
|
|
|
|
|
|
static int __exit octonet_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct ddb *dev;
|
|
|
|
|
|
|
|
dev = platform_get_drvdata(pdev);
|
|
|
|
|
2015-09-25 17:45:48 +02:00
|
|
|
ddb_device_destroy(dev);
|
2015-08-05 17:22:42 +02:00
|
|
|
ddb_nsd_detach(dev);
|
|
|
|
ddb_ports_detach(dev);
|
|
|
|
ddb_i2c_release(dev);
|
|
|
|
|
2015-12-10 18:26:45 +01:00
|
|
|
if (dev->link[0].info->ns_num)
|
|
|
|
ddbwritel(dev, 0, ETHER_CONTROL);
|
2015-08-05 17:22:42 +02:00
|
|
|
ddbwritel(dev, 0, INTERRUPT_ENABLE);
|
|
|
|
|
2015-12-10 18:26:45 +01:00
|
|
|
free_irq(platform_get_irq(dev->pfdev, 0), dev);
|
2015-08-05 17:22:42 +02:00
|
|
|
ddb_ports_release(dev);
|
2017-07-24 01:03:40 +02:00
|
|
|
ddb_unmap(dev);
|
2015-08-05 17:22:42 +02:00
|
|
|
platform_set_drvdata(pdev, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init octonet_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct ddb *dev;
|
|
|
|
struct resource *regs;
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
dev = vzalloc(sizeof(struct ddb));
|
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
platform_set_drvdata(pdev, dev);
|
|
|
|
dev->dev = &pdev->dev;
|
|
|
|
dev->pfdev = pdev;
|
|
|
|
|
|
|
|
mutex_init(&dev->mutex);
|
|
|
|
regs = platform_get_resource(dev->pfdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!regs)
|
|
|
|
return -ENXIO;
|
|
|
|
dev->regs_len = (regs->end - regs->start) + 1;
|
|
|
|
dev_info(dev->dev, "regs_start=%08x regs_len=%08x\n",
|
|
|
|
(u32) regs->start, (u32) dev->regs_len);
|
|
|
|
dev->regs = ioremap(regs->start, dev->regs_len);
|
|
|
|
|
|
|
|
if (!dev->regs) {
|
|
|
|
dev_err(dev->dev, "ioremap failed\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2015-09-06 19:08:57 +02:00
|
|
|
dev->link[0].ids.hwid = ddbreadl(dev, 0);
|
|
|
|
dev->link[0].ids.regmapid = ddbreadl(dev, 4);
|
|
|
|
dev->link[0].ids.devid = ddbreadl(dev, 8);
|
|
|
|
dev->link[0].ids.mac = ddbreadl(dev, 12);
|
2015-08-05 17:22:42 +02:00
|
|
|
|
2015-09-06 19:08:57 +02:00
|
|
|
dev->link[0].ids.vendor = dev->link[0].ids.devid & 0xffff;
|
|
|
|
dev->link[0].ids.device = dev->link[0].ids.devid >> 16;
|
|
|
|
dev->link[0].ids.subvendor = dev->link[0].ids.devid & 0xffff;
|
|
|
|
dev->link[0].ids.subdevice = dev->link[0].ids.devid >> 16;
|
2015-08-05 17:22:42 +02:00
|
|
|
|
|
|
|
dev->link[0].dev = dev;
|
2017-07-24 22:24:47 +02:00
|
|
|
#if 0
|
2015-09-06 19:08:57 +02:00
|
|
|
if (dev->link[0].ids.devid == 0x0300dd01)
|
2015-08-05 17:22:42 +02:00
|
|
|
dev->link[0].info = &ddb_octonet;
|
2015-09-06 19:08:57 +02:00
|
|
|
else if (dev->link[0].ids.devid == 0x0301dd01)
|
2015-08-05 17:22:42 +02:00
|
|
|
dev->link[0].info = &ddb_octonet_jse;
|
2015-09-06 19:08:57 +02:00
|
|
|
else if (dev->link[0].ids.devid == 0x0307dd01)
|
2015-08-05 17:22:42 +02:00
|
|
|
dev->link[0].info = &ddb_octonet_gtl;
|
|
|
|
else
|
|
|
|
dev->link[0].info = &ddb_octonet_tbd;
|
2017-07-24 22:24:47 +02:00
|
|
|
#else
|
|
|
|
dev->link[0].info = get_ddb_info(dev->link[0].ids.vendor,
|
|
|
|
dev->link[0].ids.device,
|
|
|
|
0xdd01, 0xffff);
|
|
|
|
#endif
|
2016-10-10 00:19:16 +02:00
|
|
|
pr_info("DDBridge: HW %08x REGMAP %08x\n",
|
2016-03-24 12:10:20 +01:00
|
|
|
dev->link[0].ids.hwid, dev->link[0].ids.regmapid);
|
2016-10-10 00:19:16 +02:00
|
|
|
pr_info("DDBridge: MAC %08x DEVID %08x\n",
|
2016-03-24 12:10:20 +01:00
|
|
|
dev->link[0].ids.mac, dev->link[0].ids.devid);
|
2015-08-05 17:22:42 +02:00
|
|
|
|
|
|
|
ddbwritel(dev, 0, ETHER_CONTROL);
|
|
|
|
ddbwritel(dev, 0x00000000, INTERRUPT_ENABLE);
|
|
|
|
ddbwritel(dev, 0xffffffff, INTERRUPT_STATUS);
|
2016-05-02 16:27:32 +02:00
|
|
|
ddb_reset_ios(dev);
|
2015-08-05 17:22:42 +02:00
|
|
|
|
|
|
|
irq = platform_get_irq(dev->pfdev, 0);
|
|
|
|
if (irq < 0)
|
|
|
|
goto fail;
|
|
|
|
if (request_irq(irq, irq_handler,
|
|
|
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
|
|
|
"octonet-dvb", (void *) dev) < 0)
|
|
|
|
goto fail;
|
|
|
|
ddbwritel(dev, 0x0fffff0f, INTERRUPT_ENABLE);
|
|
|
|
|
|
|
|
if (ddb_init(dev) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
dev_err(dev->dev, "fail\n");
|
|
|
|
ddbwritel(dev, 0, ETHER_CONTROL);
|
|
|
|
ddbwritel(dev, 0, INTERRUPT_ENABLE);
|
2017-07-24 01:03:40 +02:00
|
|
|
ddb_unmap(dev);
|
2015-08-05 17:22:42 +02:00
|
|
|
platform_set_drvdata(pdev, 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_OF
|
|
|
|
static const struct of_device_id octonet_dt_ids[] = {
|
|
|
|
{ .compatible = "digitaldevices,octonet-dvb" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(of, octonet_dt_ids);
|
|
|
|
#endif
|
|
|
|
|
2017-07-18 00:23:13 +02:00
|
|
|
static struct platform_driver octonet_driver __refdata = {
|
2015-08-05 17:22:42 +02:00
|
|
|
.remove = __exit_p(octonet_remove),
|
|
|
|
.probe = octonet_probe,
|
|
|
|
.driver = {
|
|
|
|
.name = "octonet-dvb",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
#ifdef CONFIG_OF
|
|
|
|
.of_match_table = of_match_ptr(octonet_dt_ids),
|
|
|
|
#endif
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static __init int init_octonet(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
2016-10-10 00:19:16 +02:00
|
|
|
pr_info("DDBridge: Digital Devices OctopusNet driver " DDBRIDGE_VERSION
|
2016-05-02 16:27:32 +02:00
|
|
|
", Copyright (C) 2010-16 Digital Devices GmbH\n");
|
2015-08-05 17:22:42 +02:00
|
|
|
res = ddb_class_create();
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
res = platform_driver_probe(&octonet_driver, octonet_probe);
|
|
|
|
if (res) {
|
|
|
|
ddb_class_destroy();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __exit void exit_octonet(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&octonet_driver);
|
|
|
|
ddb_class_destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_octonet);
|
|
|
|
module_exit(exit_octonet);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("GPL");
|
|
|
|
MODULE_AUTHOR("Marcus and Ralph Metzler, Metzler Brothers Systementwicklung GbR");
|
|
|
|
MODULE_LICENSE("GPL");
|
2017-07-24 01:05:31 +02:00
|
|
|
MODULE_VERSION(DDBRIDGE_VERSION);
|