summaryrefslogtreecommitdiff
path: root/bsp/qemu-vexpress-a9
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-06-10 17:59:17 +0800
committerBernard Xiong <[email protected]>2018-06-10 17:59:17 +0800
commit884fb70fe9973eaf01a7df04941cbcb0475ba8d5 (patch)
tree7c8e3f42629e46b3d7ecb0c8507f67934d9fae47 /bsp/qemu-vexpress-a9
parentbca65f30a90857287dc1371ddbc8d5f165691c7f (diff)
[Kernel] Add device ops feature.
Diffstat (limited to 'bsp/qemu-vexpress-a9')
-rw-r--r--bsp/qemu-vexpress-a9/drivers/drv_clcd.c21
-rw-r--r--bsp/qemu-vexpress-a9/drivers/drv_smc911x.c25
2 files changed, 35 insertions, 11 deletions
diff --git a/bsp/qemu-vexpress-a9/drivers/drv_clcd.c b/bsp/qemu-vexpress-a9/drivers/drv_clcd.c
index 543924e718..4444d338c3 100644
--- a/bsp/qemu-vexpress-a9/drivers/drv_clcd.c
+++ b/bsp/qemu-vexpress-a9/drivers/drv_clcd.c
@@ -5,8 +5,8 @@
#include <rtthread.h>
#include "drv_clcd.h"
-#define CLCD_WIDTH 480
-#define CLCD_HEIGHT 320
+#define CLCD_WIDTH 640
+#define CLCD_HEIGHT 480
#define CLCD_DEVICE(dev) (struct drv_clcd_device*)(dev)
@@ -78,6 +78,18 @@ static rt_err_t drv_clcd_control(struct rt_device *device, int cmd, void *args)
return RT_EOK;
}
+#ifdef RT_USING_DEVICE_OPS
+const static struct rt_device_ops clcd_ops =
+{
+ drv_clcd_init,
+ RT_NULL,
+ RT_NULL,
+ RT_NULL,
+ RT_NULL,
+ drv_clcd_control
+};
+#endif
+
int drv_clcd_hw_init(void)
{
PL111MMIO *plio;
@@ -107,8 +119,13 @@ int drv_clcd_hw_init(void)
plio->control = 0x1921 | (0x6 << 1);
device->type = RT_Device_Class_Graphic;
+#ifdef RT_USING_DEVICE_OPS
+ device->ops = &clcd_ops;
+#else
device->init = drv_clcd_init;
device->control = drv_clcd_control;
+#endif
+
rt_device_register(device, "lcd", RT_DEVICE_FLAG_RDWR);
return 0;
diff --git a/bsp/qemu-vexpress-a9/drivers/drv_smc911x.c b/bsp/qemu-vexpress-a9/drivers/drv_smc911x.c
index a5a7df3b06..4b33cc4215 100644
--- a/bsp/qemu-vexpress-a9/drivers/drv_smc911x.c
+++ b/bsp/qemu-vexpress-a9/drivers/drv_smc911x.c
@@ -485,6 +485,18 @@ struct pbuf *smc911x_emac_rx(rt_device_t dev)
return p;
}
+#ifdef RT_USING_DEVICE_OPS
+const static struct rt_device_ops smc911x_emac_ops =
+{
+ smc911x_emac_init,
+ RT_NULL,
+ RT_NULL,
+ RT_NULL,
+ RT_NULL,
+ smc911x_emac_control
+};
+#endif
+
int smc911x_emac_hw_init(void)
{
_emac.iobase = VEXPRESS_ETH_BASE;
@@ -507,12 +519,16 @@ int smc911x_emac_hw_init(void)
_emac.enetaddr[4] = 0x22;
_emac.enetaddr[5] = 0x33;
+#ifdef RT_USING_DEVICE_OPS
+ _emac.parent.parent.ops = &smc911x_emac_ops;
+#else
_emac.parent.parent.init = smc911x_emac_init;
_emac.parent.parent.open = RT_NULL;
_emac.parent.parent.close = RT_NULL;
_emac.parent.parent.read = RT_NULL;
_emac.parent.parent.write = RT_NULL;
_emac.parent.parent.control = smc911x_emac_control;
+#endif
_emac.parent.parent.user_data = RT_NULL;
_emac.parent.eth_rx = smc911x_emac_rx;
_emac.parent.eth_tx = smc911x_emac_tx;
@@ -540,12 +556,3 @@ int smc911x_emac_hw_init(void)
return 0;
}
INIT_APP_EXPORT(smc911x_emac_hw_init);
-
-#include <finsh.h>
-int emac(int argc, char** argv)
-{
- rt_hw_interrupt_umask(_emac.irqno);
-
- return 0;
-}
-MSH_CMD_EXPORT(emac, emac dump);