s5pc210: slp7: add single wire interface
authorDonghwa Lee <dh09.lee@samsung.com>
Thu, 20 Jan 2011 00:17:51 +0000 (09:17 +0900)
committerDonghwa Lee <dh09.lee@samsung.com>
Thu, 20 Jan 2011 00:17:51 +0000 (09:17 +0900)
Makefile
drivers/swi/Makefile [new file with mode: 0644]
drivers/swi/swi.c [new file with mode: 0644]

index 3f05328..608bc97 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -219,6 +219,7 @@ LIBS += drivers/pci/libpci.o
 LIBS += drivers/pcmcia/libpcmcia.o
 LIBS += drivers/power/libpower.o
 LIBS += drivers/spi/libspi.o
+LIBS += drivers/swi/libswi.o
 ifeq ($(CPU),mpc83xx)
 LIBS += drivers/qe/libqe.o
 LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
diff --git a/drivers/swi/Makefile b/drivers/swi/Makefile
new file mode 100644 (file)
index 0000000..3b7f3a7
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# (C) Copyright 2010
+#
+# Donghwa Lee <dh09.lee@samsung.com>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# 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., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    := $(obj)libswi.o
+
+COBJS-$(CONFIG_SWI) += swi.o
+
+COBJS  := $(COBJS-y)
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+all:   $(LIB)
+
+$(LIB):        $(obj).depend $(OBJS)
+       $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/drivers/swi/swi.c b/drivers/swi/swi.c
new file mode 100644 (file)
index 0000000..faf9507
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * linux/driver/swi/swi.c 
+ *
+ * Single-Wired Interface Driver.
+ *
+ * Copyright (C) 2010 Samsung Electronics Co.Ltd
+ *     Donghwa Lee <dh09.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTAswiLITY 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <common.h>
+#include <asm/arch/gpio.h>
+#include <swi.h>
+
+struct swi_platform_data *swi;
+
+int swi_transfer_command(unsigned int command)
+{
+       switch (command) {
+       case SWI_LOW:
+               gpio_set_value(swi->swi_bank, swi->controller_data, 0);
+               break;
+       case SWI_HIGH:
+               gpio_set_value(swi->swi_bank, swi->controller_data, 1);
+               break;
+       case SWI_CHANGE:
+               gpio_direction_output(swi->swi_bank, swi->controller_data, 0);
+               udelay(swi->low_period);
+
+               gpio_set_value(swi->swi_bank, swi->controller_data, 1);
+               udelay(swi->high_period);
+               break;
+       default:
+               printf("invalid command.\n");
+               return 0;
+       }
+
+       return 1;
+}
+
+/*
+ * register SWI devices for a given board.
+ *
+ * @info : array of chip descriptors.
+ * @n : how many descriptors are provided.
+ */
+void swi_set_platform_data(struct swi_platform_data *pd)
+{
+       if (pd == NULL) {
+               printf("pd is NULL.\n");
+               return;
+       }
+
+       swi = pd;
+}