Skip to contentSkip to conversation

SuperIO driver redesign.

DISCUSSION Evgeniy Polyakov 1 participant 4 messages May 19, 2005 Kbuild

lore
Share & tools
lore
#3 lore raw
In reply to Evgeniy Polyakov

SuperIO update.

This update contains mostly stub drivers for SCx200/SC1100 SuperIO, and stub driver( it can not be found neither in scx200/sc1100 chip nor in pc87366 chip) for Access buss logical device.

Main feature is logical device cloning feature:
When new logical device is being added SuperIO core checks if any registered SuperIO chip expects this logical device but with different index, then SuperIO core will clone logical device being added and registers clones with appropriate sc_dev devices. When logical device is being removed, then SuperIO core finds all it's clones(by looking into ldev_list) and remove them also.

Please review and comment.

This will include following changeset:

# do not edit -- automatically generated by arch changelog
# arch-tag:
[email protected]/soekris--main--0
#
2004-09-03 18:39:39 GMT	Evgeniy Polyakov <[email protected]>	patch-46

Summary:
Fixed unclone bug. Process all logical devices that SuperIO chips
has in it's structure, little optimization in reference counting in
sc_ldev_clone(). Revision:
soekris--main--0--patch-46

Fixed unclone bug. Bit operation must be done on pointers to the
bitfield.
Process all logical devices that SuperIO chips has in it's
structure, do not break if first one was not activated.

Little optimization in reference counting - increment original
logical device refcnt after it was copied.

modified files:
sc.c

2004-09-03 13:12:03 GMT	Evgeniy Polyakov <[email protected]>	patch-45

Summary:
Added scx200.c - driver for SCx200/SC1100 SuperIO chips.
Revision:
soekris--main--0--patch-45

Added scx200.c - driver for SCx200/SC1100 SuperIO chips.

new files:
.arch-ids/scx200.c.id scx200.c

modified files:
Makefile

2004-09-03 13:10:10 GMT	Evgeniy Polyakov <[email protected]>	patch-44

Summary:
Commented unused variable.
Revision:
soekris--main--0--patch-44

Commented unused variable.

modified files:
sc_gpio.c

2004-09-03 13:04:33 GMT	Evgeniy Polyakov <[email protected]>	patch-43

Summary:
Finished cloning mechanism.
Revision:
soekris--main--0--patch-43

Finished cloning mechanism.
When new logical device is being added SuperIO core checks if any
registered SuperIO chip expects this logical device but with
different index, then SuperIO core will clone logical device being added
and registers clones with appropriate sc_dev devices. When logical device is being removed, then SuperIO core finds all
it's clones(by looking into ldev_list) and remove them also.

modified files:
sc.c sc.h

2004-09-03 08:19:39 GMT	Evgeniy Polyakov <[email protected]>	patch-42

Summary:
Moved SIO_ definitions common to all SuperIO chips into sc.h
Revision:
soekris--main--0--patch-42

Moved SIO_ definitions common to all SuperIO chips into sc.h

modified files:
pc8736x.h

2004-09-03 08:18:23 GMT	Evgeniy Polyakov <[email protected]>	patch-41

Summary:
Set orig_dev to NULL in initialization time.
Revision:
soekris--main--0--patch-41

Set orig_dev to NULL in initialization time.
This means that in initialization time we do not have any clones of
this device.

modified files:
sc_acb.c sc_gpio.c

2004-09-03 08:16:38 GMT	Evgeniy Polyakov <[email protected]>	patch-40

Summary:
Changed locking schema, added cloning functions.
Revision:
soekris--main--0--patch-40

Changed locking schema - get appropriate lock when access to logical
device or sc device. This will be needed when we will add/remove
different device not only in loading/unloading time but in any other
moment through clone creating.
Added cloning functions.

modified files:
sc.c sc.h

2004-09-03 05:31:30 GMT	Evgeniy Polyakov <[email protected]>	patch-39

Summary:
Changed name for the struct sc_sio_chip to sc_chip_id.
Revision:
soekris--main--0--patch-39

Changed name for the struct sc_sio_chip to sc_chip_id.

modified files:
pc8736x.c sc.h

2004-09-03 05:20:57 GMT	Evgeniy Polyakov <[email protected]>	patch-38

Summary:
Added sc_get_ldev_index() - search logical device by name and
index. Revision:
soekris--main--0--patch-38

Added sc_get_ldev_index() - search logical device by name and index.

modified files:
sc.c

2004-09-03 04:29:26 GMT	Evgeniy Polyakov <[email protected]>	patch-37
    Summary:
      Added sc_acb.c - driver for Access Bus logical device.
    Revision:
      soekris--main--0--patch-37

    Added sc_acb.c - driver for Access Bus logical device.

    new files:
     .arch-ids/sc_acb.c.id sc_acb.c

    modified files:
     Makefile pc8736x.h
2004-09-03 04:27:21 GMT	Evgeniy Polyakov <[email protected]>	patch-36

Summary:
Compilation fix in sc_sdev_equal().
Revision:
soekris--main--0--patch-36

Compilation fix in sc_sdev_equal().

modified files:
sc.c

2004-09-03 04:24:44 GMT	Evgeniy Polyakov <[email protected]>	patch-35

Summary:
Added sc_{sdev,ldev}_equal() functions.
Revision:
soekris--main--0--patch-35

Added sc_{sdev,ldev}_equal() functions.
The check if two given sdev/ldev are equal.

modified files:
sc.c

2004-09-02 11:15:59 GMT	Evgeniy Polyakov <[email protected]>	patch-34

Summary:
Changes module description.
Revision:
soekris--main--0--patch-34

Changes module description.
sc_gpio.c is not driver for any w1 device.

modified files:
sc_gpio.c

Evgeniy Polyakov ( s0mbre )

Only failure makes us experts. -- Theo de Raadt
-------------- next part --------------

Makefile +2 -3
diff -Nru soekris.old/Makefile soekris/Makefile
@@ -1,6 +1,5 @@
-obj-m		:= superio.o sc_gpio.o pc8736x.o
+obj-m		:= superio.o sc_gpio.o pc8736x.o sc_acb.o scx200.o
 superio-objs	:= sc.o chain.o
-# sc_gpio.o sc_w1.o pc8736x.o
 
 #KDIR	:= /lib/modules/$(shell uname -r)/build
 KDIR	:= /usr/local/src/linux-2.6/linux-2.6.6
@@ -10,5 +9,5 @@
 	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
 
 clean:
-	rm -f *.o *.ko *.mod.* .*.cmd *~
+	rm -f *.o *.ko *.mod.* .*.cmd *~ .*.o.*
 	rm -rf .tmp_versions
pc8736x.c +1 -1
diff -Nru soekris.old/pc8736x.c soekris/pc8736x.c
@@ -54,7 +54,7 @@
 	//.write	pc8736x_write,
 };
 
-static struct sc_sio_chip pc8736x_sio_ids[] = 
+static struct sc_chip_id pc8736x_sio_ids[] = 
 {
 	{"PC87360", 0xe1},
 	{"PC87363", 0xe8},
pc8736x.h +0 -16
diff -Nru soekris.old/pc8736x.h soekris/pc8736x.h
@@ -23,22 +23,6 @@
 #ifndef __PC8736X_H
 #define __PC8736X_H
 
-#define SIO_REG_SID		0x20	/* Super I/O ID */
-#define SIO_SID_PC87366		0xE9 	/* PC87366 is identified as 0xE9.*/
-
-#define SIO_REG_SRID		0x27	/* Super I/O Revision */
-#define SIO_REG_IRQ		0x70	/* IRQ number */
-#define SIO_REG_IRQ_TYPE	0x71	/* IRQ type */
-
-#define SIO_REG_LDN		0x07	/* Logical Device Number */
-#define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
-
-#define SIO_REG_ACTIVE		0x30	/* Logical Device Activate Register */
-#define SIO_ACTIVE_EN		0x01	/* enabled */
-
-#define SIO_REG_IO_MSB		0x60	/* I/O Port Base, bits 15-8 */
-#define SIO_REG_IO_LSB		0x61	/* I/O Port Base, bits 7-0 */
-
 #define SIO_GPDO0		0x00
 #define SIO_GPDI0 		0x01
 #define SIO_GPEVEN0		0x02 
sc.c +304 -44

527 lines not on this page · raw message

sc.h +31 -1
diff -Nru soekris.old/sc.h soekris/sc.h
@@ -29,6 +29,24 @@
 
 #define SC_NAME_LEN		16
 
+#define SIO_REG_SID		0x20	/* Super I/O ID */
+
+#define SIO_REG_SRID		0x27	/* Super I/O Revision */
+#define SIO_REG_IRQ		0x70	/* IRQ number */
+#define SIO_REG_IRQ_TYPE	0x71	/* IRQ type */
+
+#define SIO_REG_LDN		0x07	/* Logical Device Number */
+#define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
+#define SIO_LDN_ACB		0x08	/* Access bus */
+
+#define SIO_REG_ACTIVE		0x30	/* Logical Device Activate Register */
+#define SIO_ACTIVE_EN		0x01	/* enabled */
+
+#define SIO_REG_IO_MSB		0x60	/* I/O Port Base, bits 15-8 */
+#define SIO_REG_IO_LSB		0x61	/* I/O Port Base, bits 7-0 */
+
+#define LDEV_CLONED		(1<<0)
+
 struct logical_dev
 {
 	struct list_head	ldev_entry;
@@ -48,6 +66,7 @@
 	u32			flags;
 
 	void			*pdev;
+	void			*orig_ldev;
 
 	u8			irq;
 	u8			irq_type;
@@ -73,6 +92,8 @@
 	void			*pdev;
 	unsigned long		base_index, base_data;
 
+	struct sc_chip_id	*ldevs;
+
 	int			(*probe)(void *, unsigned long);
 	int			(*activate_one)(struct logical_dev *);
 	int			(*deactivate_one)(struct logical_dev *);
@@ -80,7 +101,7 @@
 	void			(*write)(struct logical_dev *, unsigned long, u8);
 };
 
-struct sc_sio_chip
+struct sc_chip_id
 {
 	unsigned char		name[SC_NAME_LEN];
 	u8			id;
@@ -95,4 +116,13 @@
 void sc_del_sc_dev(struct sc_dev *);
 struct sc_dev *sc_get_sdev(char *);
 void sc_put_sdev(struct sc_dev *);
+
+struct logical_dev *sc_ldev_clone(struct logical_dev *ldev);
+void sc_ldev_unclone(struct logical_dev *ldev);
+inline int sc_ldev_cloned(struct logical_dev *ldev);
+inline int sc_ldev_is_clone(struct logical_dev *ldev);
+
+struct logical_dev *sc_ldev_alloc(char *name, u8 index);
+void sc_ldev_free(struct logical_dev *ldev);
+
 #endif /* __SC_H */
sc_acb.c +120 -0

120 lines not on this page · raw message

sc_gpio.c +2 -1
diff -Nru soekris.old/sc_gpio.c soekris/sc_gpio.c
@@ -43,6 +43,7 @@
 	.control	= sc_gpio_control,
 
 	.flags		= 0,
+	.orig_ldev	= 0,
 };
 
 void sc_write_reg(struct sc_dev *dev, u8 reg, u8 val)
@@ -77,7 +78,7 @@
 
 int sc_gpio_activate(void *data)
 {
-	struct logical_dev *ldev = (struct logical_dev *)data;
+	//struct logical_dev *ldev = (struct logical_dev *)data;
 	int i;
 
 	memset(gpin, 0, sizeof(gpin));
scx200.c +203 -0

203 lines not on this page · raw message