[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bsp/lk/include/dev/class/block.h b/src/bsp/lk/include/dev/class/block.h
new file mode 100644
index 0000000..240699d
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/block.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_BLOCK_H
+#define __DEV_CLASS_BLOCK_H
+
+#include <compiler.h>
+#include <dev/driver.h>
+
+/* block interface */
+struct block_ops {
+ struct driver_ops std;
+
+ ssize_t (*get_block_size)(struct device *dev);
+ ssize_t (*get_block_count)(struct device *dev);
+
+ ssize_t (*write)(struct device *dev, off_t offset, const void *buf, size_t count);
+ ssize_t (*read)(struct device *dev, off_t offset, void *buf, size_t count);
+
+ status_t (*flush)(struct device *dev);
+};
+
+__BEGIN_CDECLS
+
+ssize_t class_block_get_size(struct device *dev);
+ssize_t class_block_get_count(struct device *dev);
+ssize_t class_block_write(struct device *dev, off_t offset, const void *buf, size_t count);
+ssize_t class_block_read(struct device *dev, off_t offset, void *buf, size_t count);
+status_t class_block_flush(struct device *dev);
+
+__END_CDECLS
+
+#endif
+
diff --git a/src/bsp/lk/include/dev/class/fb.h b/src/bsp/lk/include/dev/class/fb.h
new file mode 100644
index 0000000..e29b266
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/fb.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_FB_H
+#define __DEV_CLASS_FB_H
+
+#include <compiler.h>
+#include <dev/driver.h>
+
+struct fb_info {
+ void *addr;
+ size_t line_width;
+ size_t width;
+ size_t height;
+ size_t bpp;
+};
+
+/* fb interface */
+struct fb_ops {
+ struct driver_ops std;
+
+ status_t (*set_mode)(struct device *dev, size_t width, size_t height, size_t bpp);
+ status_t (*get_info)(struct device *dev, struct fb_info *info);
+ status_t (*update)(struct device *dev);
+ status_t (*update_region)(struct device *dev, size_t x, size_t y, size_t width, size_t height);
+};
+
+__BEGIN_CDECLS
+
+status_t class_fb_set_mode(struct device *dev, size_t width, size_t height, size_t bpp);
+status_t class_fb_get_info(struct device *dev, struct fb_info *info);
+status_t class_fb_update(struct device *dev);
+status_t class_fb_update_region(struct device *dev, size_t x, size_t y, size_t width, size_t height);
+
+__END_CDECLS
+
+#endif
+
+
diff --git a/src/bsp/lk/include/dev/class/i2c.h b/src/bsp/lk/include/dev/class/i2c.h
new file mode 100644
index 0000000..d38fbcb
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/i2c.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_I2C_H
+#define __DEV_CLASS_I2C_H
+
+#include <compiler.h>
+#include <dev/driver.h>
+
+/* i2c interface */
+struct i2c_ops {
+ struct driver_ops std;
+
+ status_t (*write)(struct device *dev, uint8_t addr, const void *buf, size_t len);
+ status_t (*read)(struct device *dev, uint8_t addr, void *buf, size_t len);
+
+ status_t (*write_reg)(struct device *dev, uint8_t addr, uint8_t reg, uint8_t value);
+ status_t (*read_reg)(struct device *dev, uint8_t addr, uint8_t reg, void *value);
+};
+
+__BEGIN_CDECLS
+
+status_t class_i2c_write(struct device *dev, uint8_t addr, const void *buf, size_t len);
+status_t class_i2c_read(struct device *dev, uint8_t addr, void *buf, size_t len);
+status_t class_i2c_write_reg(struct device *dev, uint8_t addr, uint8_t reg, uint8_t value);
+status_t class_i2c_read_reg(struct device *dev, uint8_t addr, uint8_t reg, void *value);
+
+__END_CDECLS
+
+#endif
diff --git a/src/bsp/lk/include/dev/class/netif.h b/src/bsp/lk/include/dev/class/netif.h
new file mode 100644
index 0000000..099b40c
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/netif.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_NETIF_H
+#define __DEV_CLASS_NETIF_H
+
+#include <list.h>
+#include <compiler.h>
+#include <dev/driver.h>
+
+struct netstack_state;
+struct pbuf;
+
+/* netif interface */
+struct netif_ops {
+ struct driver_ops std;
+
+ status_t (*set_state)(struct device *dev, struct netstack_state *state);
+ ssize_t (*get_hwaddr)(struct device *dev, void *buf, size_t max_len);
+ ssize_t (*get_mtu)(struct device *dev);
+
+ status_t (*set_status)(struct device *dev, bool up);
+ status_t (*output)(struct device *dev, struct pbuf *p);
+ status_t (*mcast_filter)(struct device *dev, const uint8_t *mac, int action);
+};
+
+__BEGIN_CDECLS
+
+/* netif API */
+status_t class_netif_set_state(struct device *dev, struct netstack_state *state);
+ssize_t class_netif_get_hwaddr(struct device *dev, void *buf, size_t max_len);
+ssize_t class_netif_get_mtu(struct device *dev);
+status_t class_netif_set_status(struct device *dev, bool up);
+status_t class_netif_output(struct device *dev, struct pbuf *p);
+status_t class_netif_mcast_filter(struct device *dev, const uint8_t *mac, int action);
+
+status_t class_netif_add(struct device *dev);
+
+/* network stack API - called by drivers */
+status_t class_netstack_input(struct device *dev, struct netstack_state *state, struct pbuf *p);
+
+status_t class_netstack_wait_for_network(lk_time_t timeout);
+
+__END_CDECLS
+
+#endif
+
diff --git a/src/bsp/lk/include/dev/class/spi.h b/src/bsp/lk/include/dev/class/spi.h
new file mode 100644
index 0000000..dad8959
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/spi.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_SPI_H
+#define __DEV_CLASS_SPI_H
+
+#include <compiler.h>
+#include <dev/driver.h>
+
+/* spi transaction flags */
+enum spi_flags {
+ SPI_READ = (1<<0),
+ SPI_WRITE = (1<<1),
+ SPI_CS_ASSERT = (1<<2),
+ SPI_CS_DEASSERT = (1<<3),
+};
+
+/* spi transaction */
+struct spi_transaction {
+ enum spi_flags flags;
+ void *tx_buf;
+ void *rx_buf;
+ size_t len;
+};
+
+/* spi interface */
+struct spi_ops {
+ struct driver_ops std;
+
+ ssize_t (*transaction)(struct device *dev, struct spi_transaction *txn, size_t count);
+};
+
+__BEGIN_CDECLS
+
+ssize_t class_spi_transaction(struct device *dev, struct spi_transaction *txn, size_t count);
+
+__END_CDECLS
+
+#endif
+
diff --git a/src/bsp/lk/include/dev/class/uart.h b/src/bsp/lk/include/dev/class/uart.h
new file mode 100644
index 0000000..aabf101
--- /dev/null
+++ b/src/bsp/lk/include/dev/class/uart.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013 Corey Tabaka
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_CLASS_UART_H
+#define __DEV_CLASS_UART_H
+
+#include <dev/driver.h>
+
+/* uart interface */
+struct uart_ops {
+ struct driver_ops std;
+
+ ssize_t (*read)(struct device *dev, void *buf, size_t len);
+ ssize_t (*write)(struct device *dev, const void *buf, size_t len);
+};
+
+
+ssize_t class_uart_read(struct device *dev, void *buf, size_t len);
+ssize_t class_uart_write(struct device *dev, const void *buf, size_t len);
+
+#endif
+