All of lore.kernel.org
 help / color / mirror / Atom feed
* [PC87366] A bit different design for it's SuperIO.
@ 2005-05-19  6:25 Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Although lm_sensors already has driver for it's fan, voltage and
temperature sensors, it does not have driver for is's GPIO, which allows
anyone to create i2c and w1 adapters over it.
Design is simple as 5 pennies:

	SuperIO main driver
		|
+----+----+-----+-----+-----+---
|    |    |     |     |     |

	Logical devices space...

Where each logical device may be registered and deregistered to/from
main driver. Theoretically master device may have some kind of ioctl or
any other communication mechanism with userspace/kernelspace which will
allow any kind of slave manipulations.

Since you have "monitoring" driver already, I've created one only for
GPIO.

Since I do not know where it should live(at my private trees it lives in
drivers/w1/) I post here files itself.

Anyone using GNU/Arch may access it through public mirror at:
http://tservice.net.ru/~s0mbre/2004/ branch "soekris--main--0".

Please review and comment.

-- 
	Evgeniy Polyakov ( s0mbre )

Crash is better than data corruption. -- Art Grabowski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: text/x-makefile
Size: 254 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040816/9a2f13db/Makefile.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc.c
Type: text/x-csrc
Size: 8462 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040816/9a2f13db/sc.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc_gpio.c
Type: text/x-csrc
Size: 4357 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040816/9a2f13db/sc_gpio.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc_gpio.h
Type: text/x-chdr
Size: 1940 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040816/9a2f13db/sc_gpio-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc.h
Type: text/x-chdr
Size: 2538 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040816/9a2f13db/sc-0001.bin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (8 preceding siblings ...)
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Jean Delvare
  9 siblings, 0 replies; 11+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> Although lm_sensors already has driver for it's fan, voltage and
> temperature sensors, it does not have driver for is's GPIO, which
> allows anyone to create i2c and w1 adapters over it.
> Design is simple as 5 pennies:
> 
> 	SuperIO main driver
> 		|
> +----+----+-----+-----+-----+---
> |    |    |     |     |     |
> 
> 	Logical devices space...
> 
> Where each logical device may be registered and deregistered to/from
> main driver. Theoretically master device may have some kind of ioctl
> or any other communication mechanism with userspace/kernelspace which
> will allow any kind of slave manipulations.
> 
> Since you have "monitoring" driver already, I've created one only for
> GPIO.
> 
> Since I do not know where it should live(at my private trees it lives
> in drivers/w1/) I post here files itself.
> 
> Anyone using GNU/Arch may access it through public mirror at:
> http://tservice.net.ru/~s0mbre/2004/ branch "soekris--main--0".
> 
> Please review and comment.

I haven't read the code (yet), just a few random comments on the general
design:

1* The final driver definitely should be placed in a "common" location.
It isn't i2c- nor w1-specific. It would be in drivers/isa but this one
doesn't seem to exist... Maybe Greg will have a suggestion when he comes
back from vacations.

2* If such a design is in place as I port the pc87360 driver to Linux
2.6, I'll of course use it. Note that this driver supports not only the
PC87366 but also the PC87360, PC87363, PC87364 and PC87365 (although
these are less frequently found, it seems) so your driver would have to
support them all as well.

3* The Super-I/O mechanics are not PC8736x-specific. It is a standard
(established by Intel some years ago) used by all Super-I/O chips,
including those made by National Semiconductor, ITE, Winbond, SMSC and
VIA. This means that your driver should most likely be completely
generic, and probably doesn't even need to know of any chip ID. It
could, OTOH, export an ID test function (although I guess it wouldn't be
any different from the register read function with register set to
0x20).

-- 
Jean "Khali" Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Jean Delvare
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-08-16 at 22:25, Jean Delvare wrote:

> I haven't read the code (yet), just a few random comments on the general
> design:
> 
> 1* The final driver definitely should be placed in a "common" location.
> It isn't i2c- nor w1-specific. It would be in drivers/isa but this one
> doesn't seem to exist... Maybe Greg will have a suggestion when he comes
> back from vacations.
> 
> 2* If such a design is in place as I port the pc87360 driver to Linux
> 2.6, I'll of course use it. Note that this driver supports not only the
> PC87366 but also the PC87360, PC87363, PC87364 and PC87365 (although
> these are less frequently found, it seems) so your driver would have to
> support them all as well.

I do not have neither spec nor hardware for any SuperIO chips other than
PC87366, so I can not say if they will fill itself comfortably in the
new driver, but according to your driver they almost do not have any
differences.
If they are really the same, then all is ok, and I can easily extend
this driver to support different ID's and even registers. But I can not
test it, I have only Soekris board (PC87366 based) provided by
Alexander  Yurchenko (grange@openbsd.org) for a while, Thanks :)

> 3* The Super-I/O mechanics are not PC8736x-specific. It is a standard
> (established by Intel some years ago) used by all Super-I/O chips,
> including those made by National Semiconductor, ITE, Winbond, SMSC and
> VIA. This means that your driver should most likely be completely
> generic, and probably doesn't even need to know of any chip ID. It
> could, OTOH, export an ID test function (although I guess it wouldn't be
> any different from the register read function with register set to
> 0x20).

Probably we need to call the testers, I will extend driver to support
different ID's for now, but only for PC8736*.

Will send files soon.

Thank you.

-- 
	Evgeniy Polyakov ( s0mbre )

Crash is better than data corruption. -- Art Grabowski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040817/20b0b936/attachment.bin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (7 preceding siblings ...)
  2005-05-19  6:25 ` Greg KH
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Jean Delvare
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, 2004-08-16 at 22:25, Jean Delvare wrote:

> I haven't read the code (yet), just a few random comments on the general
> design:
> 
> 1* The final driver definitely should be placed in a "common" location.
> It isn't i2c- nor w1-specific. It would be in drivers/isa but this one
> doesn't seem to exist... Maybe Greg will have a suggestion when he comes
> back from vacations.
> 
> 2* If such a design is in place as I port the pc87360 driver to Linux
> 2.6, I'll of course use it. Note that this driver supports not only the
> PC87366 but also the PC87360, PC87363, PC87364 and PC87365 (although
> these are less frequently found, it seems) so your driver would have to
> support them all as well.

I do not have neither spec nor hardware for any SuperIO chips other than
PC87366, so I can not say if they will fill itself comfortably in the
new driver, but according to your driver they almost do not have any
differences.
If they are really the same, then all is ok, and I can easily extend
this driver to support different ID's and even registers. But I can not
test it, I have only Soekris board (PC87366 based) provided by
Alexander  Yurchenko (grange@openbsd.org) for a while, Thanks :)

> 3* The Super-I/O mechanics are not PC8736x-specific. It is a standard
> (established by Intel some years ago) used by all Super-I/O chips,
> including those made by National Semiconductor, ITE, Winbond, SMSC and
> VIA. This means that your driver should most likely be completely
> generic, and probably doesn't even need to know of any chip ID. It
> could, OTOH, export an ID test function (although I guess it wouldn't be
> any different from the register read function with register set to
> 0x20).

Probably we need to call the testers, I will extend driver to support
different ID's for now, but only for PC8736*.

Will send files soon.

Thank you.

-- 
	Evgeniy Polyakov ( s0mbre )

Crash is better than data corruption. -- Art Grabowski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040817/ad14f396/attachment.bin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (5 preceding siblings ...)
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Greg KH
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Tue, 17 Aug 2004 14:33:01 +0400
Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:

> > 3* The Super-I/O mechanics are not PC8736x-specific. It is a
> > standard(established by Intel some years ago) used by all Super-I/O
> > chips, including those made by National Semiconductor, ITE, Winbond,
> > SMSC and VIA. This means that your driver should most likely be
> > completely generic, and probably doesn't even need to know of any
> > chip ID. It could, OTOH, export an ID test function (although I
> > guess it wouldn't be any different from the register read function
> > with register set to 0x20).
> 
> Probably we need to call the testers, I will extend driver to support
> different ID's for now, but only for PC8736*.
> 
> Will send files soon.

Done.
dmesg:
Soekris SuperIO driver is starting...
Found PC87366 [0xe9] at 0x002e-0x0030.
GPIO logical device driver is activating now.
                    GPIO - activated: 0x6600-0x6610, irq\0 [type\x03]

As before one can access GNU/Arch archive at
http://tservice.net.ru/~s0mbre/2004 branch soekris--main--0.

Please review and comment.
Thank you.

Differences from previous set include:

# do not edit -- automatically generated by arch changelog
# arch-tag:
automatic-ChangeLog--johnpol@2ka.mipt.ru-2004/soekris--main--0#

2004-08-18 17:55:04 GMT Evgeniy Polyakov <johnpol@2ka.mipt.ru>  patch-15

    Summary:
      Added run-time SuperIO chip identification.
    Revision:
      soekris--main--0--patch-15

    Added run-time SuperIO chip identifications.
    Now differend PC8736* are supported.

    modified files:
     sc.c sc.h


2004-08-18 17:35:57 GMT Evgeniy Polyakov <johnpol@2ka.mipt.ru>  patch-14

    Summary:
      Added sc_w1.c - w1 master over PC87366 GPIO pins.
    Revision:
      soekris--main--0--patch-14

    Added sc_w1.c - w1 master over PC87366 GPIO pins.

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

    modified files:
     Makefile


2004-08-18 17:35:02 GMT Evgeniy Polyakov <johnpol@2ka.mipt.ru>  patch-13

    Summary:
      Experiments with GPIO pin states and masks. Added control calling
into read/write functions.    Revision:
      soekris--main--0--patch-13

    Experiments with GPIO pin states and masks. 
        GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL - can blink.
    
    Added control calling into read/write functions.
        Need for ability to read from line just after writing to it -
useful for i2c and w1 emulation.

    modified files:
     sc_gpio.c


2004-08-18 17:32:35 GMT Evgeniy Polyakov <johnpol@2ka.mipt.ru>  patch-12

    Summary:
      Removed timer insertion, do not remove logical device if refcnt !0, added sc_{get,put}_ldev, do not use port read/write operations with
delay(*_p).    Revision:
      soekris--main--0--patch-12

    Removed timer insertion.
    Do not remove logical device if refcnt != 0.
    Added sc_{get,put}_ldev.
    Do not use port read/write operations with delay(*_p).
    
    Added pin_num module parameter for sc.c - selects pin to work with.
    Removed unneded and commented debug.

    modified files:
     sc.c sc.h





	Evgeniy Polyakov ( s0mbre )

Only failure makes us experts. -- Theo de Raadt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc.c
Type: text/x-csrc
Size: 9056 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040818/95e65e9b/sc.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc.h
Type: text/x-chdr
Size: 2689 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040818/95e65e9b/sc-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc_gpio.c
Type: text/x-csrc
Size: 4574 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040818/95e65e9b/sc_gpio.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc_gpio.h
Type: text/x-chdr
Size: 1940 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040818/95e65e9b/sc_gpio-0001.bin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (4 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Wed, 18 Aug 2004 22:10:21 +0400
Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:

> On Tue, 17 Aug 2004 14:33:01 +0400
> Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:
> 
> > > 3* The Super-I/O mechanics are not PC8736x-specific. It is a
> > > standard(established by Intel some years ago) used by all
> > > Super-I/O chips, including those made by National Semiconductor,
> > > ITE, Winbond, SMSC and VIA. This means that your driver should
> > > most likely be completely generic, and probably doesn't even need
> > > to know of any chip ID. It could, OTOH, export an ID test function
> > > (although I guess it wouldn't be any different from the register
> > > read function with register set to 0x20).
> > 
> > Probably we need to call the testers, I will extend driver to
> > support different ID's for now, but only for PC8736*.
> > 
> > Will send files soon.
> 
> Done.
> dmesg:
> Soekris SuperIO driver is starting...
> Found PC87366 [0xe9] at 0x002e-0x0030.
> GPIO logical device driver is activating now.
>                     GPIO - activated: 0x6600-0x6610, irq\0 [type\x03]
> 
> As before one can access GNU/Arch archive at
> http://tservice.net.ru/~s0mbre/2004 branch soekris--main--0.
> 
> Please review and comment.

BTW, If someone really want to use this then it requires following
patch(also attached): 

s0mbre@zanzibar:~/aWork/soekris$ tla cat-log
patch-16 Revision: soekris--main--0--patch-16
Archive: johnpol@2ka.mipt.ru-2004
Creator: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Date: Thu Aug 19 00:54:56 MSD 2004
Standard-date: 2004-08-18 20:54:56 GMT
Modified-files: sc_gpio.c
New-patches: johnpol@2ka.mipt.ru-2004/soekris--main--0--patch-16
Summary: Fixed read bug - we must read from GPIO INPUT register, not
OUTPUT. Control manipulations in ->activate(). 
Keywords:
 
Fixed read bug - we must read from GPIO INPUT register, not OUTPUT.
Control manipulations in ->activate().

--- orig/sc_gpio.c
+++ mod/sc_gpio.c
@@ -68,13 +68,14 @@
 
 	for (i=0; i<SIO_GPIO_NPINS; ++i)
 	{
-		gpin[i].flags = GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL;
-		//gpin[i].flags = GPIO_PIN_OPENDRAIN;
-		gpin[i].state = GPIO_PIN_HIGH;
+		//gpin[i].flags = GPIO_PIN_OPENDRAIN | GPIO_PIN_PUSHPULL;
+		gpin[i].flags = GPIO_PIN_TRISTATE;
 		gpin[i].mask &= ~(SIO_GPIO_CONF_OUTPUTEN |
SIO_GPIO_CONF_PUSHPULL |  					SIO_GPIO_CONF_PULLUP |
SIO_GPIO_CONF_DEBOUNCE); 		
 		sc_gpio_control(ldev, i, gpin[i].mask, gpin[i].flags);
+		
+		gpin[i].state = GPIO_PIN_HIGH;
 		sc_gpio_write(ldev, i, gpin[i].state);
 	}
 	
@@ -93,16 +94,16 @@
 	switch (port)
 	{
 		case 0:
-			reg = SIO_GPDO0;
+			reg = SIO_GPDI0;
 			break;
 		case 1:
-			reg = SIO_GPDO1;
+			reg = SIO_GPDI1;
 			break;
 		case 2:
-			reg = SIO_GPDO2;
+			reg = SIO_GPDI2;
 			break;
 		case 3:
-			reg = SIO_GPDO3;
+			reg = SIO_GPDI3;
 			break;
 	}
 

	Evgeniy Polyakov ( s0mbre )

Only failure makes us experts. -- Theo de Raadt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sc_gpio.c.patch
Type: application/octet-stream
Size: 908 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040819/cb9bef53/sc_gpio.c.obj

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (3 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Evgeniy Polyakov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi Evgeniy,

Here are my comments on your code. I'll only comment on the Super-I/O
part, since I don't know much (and don't really care) about the GPIO
driver.

First question, why the name "sc"? We'll have to find a more suitable
name for the driver. What about simply "superio"?

### sc.h

> #define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */

This is PC87366-specific and doesn't belong to that driver.

> #define SIO_ACTIVE_EN		0x01	/* enabled */
> (...)
> #define LDEV_ACTIVE		(1<<0)

Aren't these the same thing?

> #define SIO_GPDO0		0x00
> #define SIO_GPDI0 		0x01
> #define SIO_GPEVEN0		0x02 
> #define SIO_GPEVST0		0x03 
> #define SIO_GPDO1 		0x04
> #define SIO_GPDI1 		0x05
> #define SIO_GPEVEN1		0x06 
> #define SIO_GPEVST1		0x07 
> #define SIO_GPDO2 		0x08
> #define SIO_GPDI2 		0x09
> #define SIO_GPDO3 		0x0A
> #define SIO_GPDI3 		0x0B

Same here, PC87366-specific (I believe) so doesn't belong to that
driver.

> struct logical_dev
> {
> (...)
>	int			(*activate)(void *);
>	u8			(*read)(void *, int);
>	void			(*write)(void *, int, u8);
>	void			(*control)(void *, int, u8, u8);
> };

Please give the function parameters names in your prototypes. Without
them, the prototype is useless to us humans (although the compiler is
perfectly happy without them).

> void sc_write_reg(struct sc_dev *, u8, u8);
> u8 sc_read_reg(struct sc_dev *, u8);
> 
> int sc_add_logical_dev(struct logical_dev *);
> void sc_del_logical_dev(struct logical_dev *);
> struct logical_dev *sc_get_ldev(char *);
> void sc_put_ldev(struct logical_dev *);

Ditto.

At this point, I'd appreciate a detailed explanation of your choices of
implementation. It looks rather complex to me so the choices are not
that obvious. I'd simply have provided read and write functions, keeping
things really simple and low level, while it looks like you intend to
implement the concept of logical device registration. Why is it needed?
How is it going to work?

Please explain what the 6 functions are meant for, and how the three
different structures will be used.

### sc.c

> #include <asm/atomic.h>
> #include <asm/types.h>
> #include <asm/io.h>

> #include <linux/delay.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/list.h>
> #include <linux/interrupt.h>
> #include <linux/spinlock.h>
> #include <linux/timer.h>
> #include <linux/slab.h>
> #include <linux/timer.h>
> 
> #include "../w1/w1.h"
> #include "../w1/w1_int.h"
> #include "../w1/w1_log.h"
> 
> #include "sc.h"
> #include "sc_gpio.h"

Wow. I doubt you need all that. At any rate, you should not include any
device-specific or protocol-specific header here. There's no reason you
would need them. The superio driver offers an interface to the other
drivers, not the other way around.

> void sc_write_reg(struct sc_dev *, u8, u8);
> u8 sc_read_reg(struct sc_dev *, u8);
> 
> int sc_add_logical_dev(struct logical_dev *);
> void sc_del_logical_dev(struct logical_dev *);

These are already defined in the .h file.

> static int sc_activate_one_logical(struct sc_dev *dev, struct logical_dev *ldev)
> (...)
> static void sc_activate_logical(struct sc_dev *dev)

I doubt that the second one will ever be needed. There's no point in
arbitrary activating all logical devices at once, is there? Ditto for
deactivating.

> static int sc_chip_id(u8 id)

This one is supposed to convert an id into an index, isn't it? It would
better be called sc_chip_index then.

> static int sc_find_device(struct sc_dev *dev, unsigned long __base)
> {
> 	unsigned long base;
> 	unsigned long size = 2;
> 	int i, sz;
> 
> 	if (__base)
> 	{
> 		base = __base;
> 		sz = 1;
> 	}
> 	else
> 	{
> 		base = 0; /* Make compiler happy */
> 		sz = sizeof(base_addr)/sizeof(base_addr[0]);
> 	}
> 	
> 	for (i=0; i<sz; ++i)
> 	{
> 		u8 id;
> 		int chip_num;
> 		
> 		if (!__base)
> 			base = base_addr[i];
> 
> 		dev->base_index = base;
> 		dev->base_data = base + 1;
> (...)

You handling of base is complex without a reason. If __base is set, do
base_addr[0] = __base and sz = 1. If it isn't, sz sizeof(base_addr)/sizeof(base_addr[0]) (unchanged). Then you don't have
to care about it in the for loop:

static int sc_find_device(struct sc_dev *dev, unsigned long base)
{
	unsigned long size = 2;
	int i, sz;

	if (base)
	{
		base_addr[0] = base;
		sz = 1;
	}
	else
	{
		sz = sizeof(base_addr)/sizeof(base_addr[0]);
	}
	
	for (i=0; i<sz; ++i)
	{
		u8 id;
		int chip_num;
		
		dev->base_index = base_addr[i];
		dev->base_data = base_addr[i] + 1;

How about it?

BTW, I see no reason why you would want to force the base address. The
possible addresses are standardized (0x2e/0x2f and 0x4e/0x4f), 99% of
the case the super I/O is at 0x2e/0x2f. So I wouldn't even bother with
that parameter.

> 		if (chip_num >= 0)
> 		{
> 			printk(KERN_INFO "Found %s [0x%x] at 0x%04lx-0x%04lx.\n", 
> 					sc_sio_ids[chip_num].name, sc_sio_ids[chip_num].id, 
> 					base, base+size);
> 			return i;
> 		}
> 
> 		printk(KERN_INFO "Found nothing at 0x%04lx-0x%04lx.\n", base, base+size);

base+size is really base+size-1. And actually size could go away and it
would be base+1. Again, it's standard. I wouldn't even print it as
"0x%x/0x%x". Super-I/O have a couple addresses by nature, not an I/O
range (although this translates into a 2-address range in the end).

I also see that your function wouldn't support a system with two similar
Super-I/Os at different addresses. I admit it was never seen and will
probably never be, but since you seem to be wanting to handle all cases,
that's a strange choice.

As for the rest, it's way above me until you explain what it is supposed
to do.

Thanks.

-- 
Jean "Khali" Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Sat, 21 Aug 2004 09:30:57 +0200
Jean Delvare <khali@linux-fr.org> wrote:

> Hi Evgeniy,

Hi, Jean.
 
> Here are my comments on your code. I'll only comment on the Super-I/O
> part, since I don't know much (and don't really care) about the GPIO
> driver.
> 
> First question, why the name "sc"? We'll have to find a more suitable
> name for the driver. What about simply "superio"?

It was derived from "Soekris" board name since it was initially wrote
for those board. 
It looks like it was bad crack since now I do not see letter "c" in
it's name... Hmmm, maybe it was "Soekris control" or "SuperIO
Control"? :)

> ### sc.h
> 
> > #define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
> 
> This is PC87366-specific and doesn't belong to that driver.

No, I think it just should be extended and include any other defines(for
temperature, voltage and others). Although they may live in drivers for
those logical devices. Driver for PC87366 may use it... I will move it
there after it will be created(actually separated to support several
main SuperIO chips at once).

> > #define SIO_ACTIVE_EN		0x01	/* enabled */
> > (...)
> > #define LDEV_ACTIVE		(1<<0)
> 
> Aren't these the same thing?

Actually not, the former is register value, the latter is bit in
->flags bitfield.
Although it is not very usefull to create bitfield for one bit, but it
can be exteded to support states for chips that requires several steps
for initialization.

> > #define SIO_GPDO0		0x00
> > #define SIO_GPDI0 		0x01
> > #define SIO_GPEVEN0		0x02 
> > #define SIO_GPEVST0		0x03 
> > #define SIO_GPDO1 		0x04
> > #define SIO_GPDI1 		0x05
> > #define SIO_GPEVEN1		0x06 
> > #define SIO_GPEVST1		0x07 
> > #define SIO_GPDO2 		0x08
> > #define SIO_GPDI2 		0x09
> > #define SIO_GPDO3 		0x0A
> > #define SIO_GPDI3 		0x0B
> 
> Same here, PC87366-specific (I believe) so doesn't belong to that
> driver.

I think I should move them into GPIO driver's header or header for
PC87366 SuperIO module(next step).

> > struct logical_dev
> > {
> > (...)
> >	int			(*activate)(void *);
> >	u8			(*read)(void *, int);
> >	void			(*write)(void *, int, u8);
> >	void			(*control)(void *, int, u8, u8);
> > };
> 
> Please give the function parameters names in your prototypes. Without
> them, the prototype is useless to us humans (although the compiler is
> perfectly happy without them).

Actually I always remove names from prototypes, since I think prototypes
are needed not for detailed explanation of appropriate function but only
for overall design view...

> 
> > void sc_write_reg(struct sc_dev *, u8, u8);
> > u8 sc_read_reg(struct sc_dev *, u8);
> > 
> > int sc_add_logical_dev(struct logical_dev *);
> > void sc_del_logical_dev(struct logical_dev *);
> > struct logical_dev *sc_get_ldev(char *);
> > void sc_put_ldev(struct logical_dev *);
> 
> Ditto.
> 
> At this point, I'd appreciate a detailed explanation of your choices
> of implementation. It looks rather complex to me so the choices are
> not that obvious. I'd simply have provided read and write functions,
> keeping things really simple and low level, while it looks like you
> intend to implement the concept of logical device registration. Why is
> it needed? How is it going to work?
> 
> Please explain what the 6 functions are meant for, and how the three
> different structures will be used.

Sure.

sc_{add,del}_logical_dev() links and unlinks logical device from the
main SuperIO module. After being added any logical device becomes
visible for the external world, but it should be accessed only through
main module using sc_{get,put}_ldev, which also increment/decrement is's
usage counter and may implement additional functionality. When logical
device is registered userspace can connect to it(actually it is the next
step and will be implemented after ability to handle several main
SuperIO logical modules) using either ioctl or netlink but again only
through main module - with such approach we can control any data/control
flow only in one place and do not disperse efforts.

> ### sc.c
> 
> > #include <asm/atomic.h>
> > #include <asm/types.h>
> > #include <asm/io.h>
> 
> > #include <linux/delay.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > #include <linux/list.h>
> > #include <linux/interrupt.h>
> > #include <linux/spinlock.h>
> > #include <linux/timer.h>
> > #include <linux/slab.h>
> > #include <linux/timer.h>
> > 
> > #include "../w1/w1.h"
> > #include "../w1/w1_int.h"
> > #include "../w1/w1_log.h"
> > 
> > #include "sc.h"
> > #include "sc_gpio.h"
> 
> Wow. I doubt you need all that. At any rate, you should not include
> any device-specific or protocol-specific header here. There's no
> reason you would need them. The superio driver offers an interface to
> the other drivers, not the other way around.

Sure, w1 includes absolutely do not needed there.

> > void sc_write_reg(struct sc_dev *, u8, u8);
> > u8 sc_read_reg(struct sc_dev *, u8);
> > 
> > int sc_add_logical_dev(struct logical_dev *);
> > void sc_del_logical_dev(struct logical_dev *);
> 
> These are already defined in the .h file.

Yep, will remove.

> > static int sc_activate_one_logical(struct sc_dev *dev, struct
> > logical_dev *ldev)(...)
> > static void sc_activate_logical(struct sc_dev *dev)
> 
> I doubt that the second one will ever be needed. There's no point in
> arbitrary activating all logical devices at once, is there? Ditto for
> deactivating.

Now it even is not called from any place. It was usefull when all
logical devices lived with main driver in one file and we registered all
at once.

> > static int sc_chip_id(u8 id)
> 
> This one is supposed to convert an id into an index, isn't it? It
> would better be called sc_chip_index then.

No problem.

> > static int sc_find_device(struct sc_dev *dev, unsigned long __base)
> > {
> > 	unsigned long base;
> > 	unsigned long size = 2;
> > 	int i, sz;
> > 
> > 	if (__base)
> > 	{
> > 		base = __base;
> > 		sz = 1;
> > 	}
> > 	else
> > 	{
> > 		base = 0; /* Make compiler happy */
> > 		sz = sizeof(base_addr)/sizeof(base_addr[0]);
> > 	}
> > 	
> > 	for (i=0; i<sz; ++i)
> > 	{
> > 		u8 id;
> > 		int chip_num;
> > 		
> > 		if (!__base)
> > 			base = base_addr[i];
> > 
> > 		dev->base_index = base;
> > 		dev->base_data = base + 1;
> > (...)
> 
> You handling of base is complex without a reason. If __base is set, do
> base_addr[0] = __base and sz = 1. If it isn't, sz > sizeof(base_addr)/sizeof(base_addr[0]) (unchanged). Then you don't
> have to care about it in the for loop:

base_addr is global and may be accessed later.
And it do will be accessed when I create ability to dynamically add and
remove main SuperIO "logical" modules(like with situation when we have
two of them in one board).

> static int sc_find_device(struct sc_dev *dev, unsigned long base)
> {
> 	unsigned long size = 2;
> 	int i, sz;
> 
> 	if (base)
> 	{
> 		base_addr[0] = base;
> 		sz = 1;
> 	}
> 	else
> 	{
> 		sz = sizeof(base_addr)/sizeof(base_addr[0]);
> 	}
> 	
> 	for (i=0; i<sz; ++i)
> 	{
> 		u8 id;
> 		int chip_num;
> 		
> 		dev->base_index = base_addr[i];
> 		dev->base_data = base_addr[i] + 1;
> 
> How about it?
> 
> BTW, I see no reason why you would want to force the base address. The
> possible addresses are standardized (0x2e/0x2f and 0x4e/0x4f), 99% of
> the case the super I/O is at 0x2e/0x2f. So I wouldn't even bother with
> that parameter.

The may live in PCI space, like SC1100 Geode processor.
It also has SuperIO, and although linux already have driver for it I
will extend SuperIO main driver to support several chips at one time.

> > 		if (chip_num >= 0)
> > 		{
> > 			printk(KERN_INFO "Found %s [0x%x] at
> > 			0x%04lx-0x%04lx.\n", 
> > 					sc_sio_ids[chip_num].name,
> > 					sc_sio_ids[chip_num].id, base, base+size);
> > 			return i;
> > 		}
> > 
> > 		printk(KERN_INFO "Found nothing at 0x%04lx-0x%04lx.\n", base,
> > 		base+size);
> 
> base+size is really base+size-1. And actually size could go away and
> it would be base+1. Again, it's standard. I wouldn't even print it as
> "0x%x/0x%x". Super-I/O have a couple addresses by nature, not an I/O
> range (although this translates into a 2-address range in the end).

Sure, it should be base+size-1, but if it is not PC8736* but for example
SC1100 we must request more than 2 bytes at a time, because of such
chips I've added size parameter.

> I also see that your function wouldn't support a system with two
> similar Super-I/Os at different addresses. I admit it was never seen
> and will probably never be, but since you seem to be wanting to handle
> all cases, that's a strange choice.

It is in my TODO list and wil be implemeted very soon after current
technical problems are resolved.

> As for the rest, it's way above me until you explain what it is
> supposed to do.
> 
> Thanks.

Thank you for review and comments.

> 
> -- 
> Jean "Khali" Delvare
> http://khali.linux-fr.org/


	Evgeniy Polyakov ( s0mbre )

Only failure makes us experts. -- Theo de Raadt

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (2 preceding siblings ...)
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Jean Delvare
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> > > #define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
> > 
> > This is PC87366-specific and doesn't belong to that driver.
> 
> No, I think it just should be extended and include any other
> defines(for temperature, voltage and others). Although they may live
> in drivers for those logical devices. Driver for PC87366 may use it...
> I will move it there after it will be created (actually separated to
> support several main SuperIO chips at once).

I'm not sure I get everything you mean here (especially the last
sentence). At any rate, the logical device usage is
manufacturer-dependant and, in most cases, chip dependant. And when two
different chips each have a logical device for, say, temperature
monitoring, the way it is organized "inside" each logical device will be
different. So there's no benefit in adding labels or classes to each
logical device of each chip, since we will never be able to use them.

I insist that the superio driver should be mostly chip-independant. The
only part which will not be is the Super-I/O enter sequence. Since the
PC8736x chips don't need any, you may not be familiar with it. Most
Super-I/O chips need a special sequence to be written to them before
they activate. Since the superio driver won't know what it is looking
for before it finds it, it'll probably have to test all known keys, then
the client driver will ask not only for a given chip ID but for a key +
chip ID pair. This also means that you will have to store the (variable
length) key in the superio structure.

> > > struct logical_dev
> > > {
> > > (...)
> > >	int			(*activate)(void *);
> > >	u8			(*read)(void *, int);
> > >	void			(*write)(void *, int, u8);
> > >	void			(*control)(void *, int, u8, u8);
> > > };
> > 
> > Please give the function parameters names in your prototypes.
> > Without them, the prototype is useless to us humans (although the
> > compiler is perfectly happy without them).
> 
> Actually I always remove names from prototypes, since I think
> prototypes are needed not for detailed explanation of appropriate
> function but only for overall design view...

You probably miss the target then. In the above example, I can easily
imagine what the activate, read and write member functions are for (left
apart the fact that I wonder what the void * is for), but I just cannot
guess what the control member function is for. Anonymous parameters
don't help. At any rate, other kernel headers seem to include parameters
names in their functions declarations.

While we're at it, I start wondering why you need these callback
functions here. Is the client not supposed to just call sc_read_reg and
sc_write_reg? I see nothing logical-device-dependent here.

> sc_{add,del}_logical_dev() links and unlinks logical device from the
> main SuperIO module. After being added any logical device becomes
> visible for the external world, but it should be accessed only through
> main module using sc_{get,put}_ldev, which also increment/decrement
> is's usage counter and may implement additional functionality. When
> logical device is registered userspace can connect to it (actually it
> is the next step and will be implemented after ability to handle
> several main SuperIO logical modules) using either ioctl or netlink
> but again only through main module - with such approach we can control
> any data/control flow only in one place and do not disperse efforts.

What's the idea behind logical device registration? I don't see how this
is needed. The reason why a superio driver is needed, as I understand
it, is to handle concurrent accesses to 0x2E/0x2F. This means that all
we really need is:

* Super-I/O detection.
* Read and write functions (specifying a logical device and a register)
* User-space interface to read and write.

Anything above that may be discussed but isn't strictly needed. I
wouldn't mind shortcut functions for retrieving the logical device I/O
address or activating the logical device, but these are really only
read and write functions.

I don't even see the need of having a structure for logical devices.

Could you please explain what benefit your approach offers? I may be
missing something.

Greg, I much would like to hear you about this.

> > > static int sc_activate_one_logical(struct sc_dev *dev, struct
> > > logical_dev *ldev)(...)
> > > static void sc_activate_logical(struct sc_dev *dev)
> > 
> > I doubt that the second one will ever be needed. There's no point in
> > arbitrary activating all logical devices at once, is there? Ditto
> > for deactivating.
> 
> Now it even is not called from any place. It was usefull when all
> logical devices lived with main driver in one file and we registered
> all at once.

Registering is one thing (even if I don't much get the interest at this
point), activating is one other. Registering is a software, lernel
internal action. Activating may have hardware consequences. If the
functions are really about registering, they should be renamed. If they
are about activating, then doing this on all logical devices at once
doesn't make any sense and a function that does so shouldn't even exist.

> > You handling of base is complex without a reason. If __base is set,
> > do base_addr[0] = __base and sz = 1. If it isn't, sz > > sizeof(base_addr)/sizeof(base_addr[0]) (unchanged). Then you don't
> > have to care about it in the for loop:
> 
> base_addr is global and may be accessed later.
> And it do will be accessed when I create ability to dynamically add
> and remove main SuperIO "logical" modules(like with situation when we
> have two of them in one board).

Hm OK I see the idea now. The function may be called more than once, and
my method will make the second call (possibly) fail. I admit it's no
good. Forget about my proposal.

> > base+size is really base+size-1. And actually size could go away and
> > it would be base+1. Again, it's standard. I wouldn't even print it
> > as"0x%x/0x%x". Super-I/O have a couple addresses by nature, not an
> > I/O range (although this translates into a 2-address range in the
> > end).
> 
> Sure, it should be base+size-1, but if it is not PC8736* but for
> example SC1100 we must request more than 2 bytes at a time, because of
> such chips I've added size parameter.

If the SC1100 does live at different addresses and uses a different
number of I/O ports, I start wondering the point in having a common
driver. What are the common points between regular Super-I/O chips and
the SC1100? Care to explain how the SC1100 works?

Thanks.

-- 
Jean "Khali" Delvare
http://khali.linux-fr.org/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
@ 2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Evgeniy Polyakov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Evgeniy Polyakov @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Sun, 2004-08-22 at 12:48, Jean Delvare wrote:
> > > > #define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
> > > 
> > > This is PC87366-specific and doesn't belong to that driver.
> > 
> > No, I think it just should be extended and include any other
> > defines(for temperature, voltage and others). Although they may live
> > in drivers for those logical devices. Driver for PC87366 may use it...
> > I will move it there after it will be created (actually separated to
> > support several main SuperIO chips at once).
> 
> I'm not sure I get everything you mean here (especially the last
> sentence). At any rate, the logical device usage is
> manufacturer-dependant and, in most cases, chip dependant. And when two
> different chips each have a logical device for, say, temperature
> monitoring, the way it is organized "inside" each logical device will be
> different. So there's no benefit in adding labels or classes to each
> logical device of each chip, since we will never be able to use them.
> 
> I insist that the superio driver should be mostly chip-independant. The
> only part which will not be is the Super-I/O enter sequence. Since the
> PC8736x chips don't need any, you may not be familiar with it. Most
> Super-I/O chips need a special sequence to be written to them before
> they activate. Since the superio driver won't know what it is looking
> for before it finds it, it'll probably have to test all known keys, then
> the client driver will ask not only for a given chip ID but for a key +
> chip ID pair. This also means that you will have to store the (variable
> length) key in the superio structure.

I'm absolutely agree here.
I mean above that when I will split sc.c into generic part and pc8736*
part I will move those definitions into the header for pc8736* driver.

Hm, if I understood you correctly you propose following design:
each superio chip has it's own driver each of which can be connected to
the main superio driver, but inside it will not have different logical
devices, only one monolithic module which handles all them at once.

The main idea about logical devices was that we need a simple set of
cubes(logical devices) and a table(superio chip's driver) and can create
any set of functionality we need.

Logical device GPIO in SC1100 is very similar with PC87366 one.
I even think that _any_ GPIO logical device in any SuperIO chip works
only in following way:
pin_select();
read_value();

Where pin_select() is
	write(base + index_reg, pin_select_reg_number);
	read(base + data_reg);

So if we create logical device GPIO which will get from main driver(from
main SuperIO module, which in turn will get it from chip specific
driver(like pc87366, sc1100)) those registers it becomes to work.

> > > > struct logical_dev
> > > > {
> > > > (...)
> > > >	int			(*activate)(void *);
> > > >	u8			(*read)(void *, int);
> > > >	void			(*write)(void *, int, u8);
> > > >	void			(*control)(void *, int, u8, u8);
> > > > };
> > > 
> > > Please give the function parameters names in your prototypes.
> > > Without them, the prototype is useless to us humans (although the
> > > compiler is perfectly happy without them).
> > 
> > Actually I always remove names from prototypes, since I think
> > prototypes are needed not for detailed explanation of appropriate
> > function but only for overall design view...
> 
> You probably miss the target then. In the above example, I can easily
> imagine what the activate, read and write member functions are for (left
> apart the fact that I wonder what the void * is for), but I just cannot
> guess what the control member function is for. Anonymous parameters
> don't help. At any rate, other kernel headers seem to include parameters
> names in their functions declarations.

->control() is for control logical device - one may enable/disable
logical device, turn on/off additional functionality et cetera using
this function.

I'm not insist on removing parameters name, I just do not understand why
they are needed there. :)

> 
> While we're at it, I start wondering why you need these callback
> functions here. Is the client not supposed to just call sc_read_reg and
> sc_write_reg? I see nothing logical-device-dependent here.

If we want to use read or write function outside the superio module set,
than we either need to know exact name( like
xyz_my_pRiVaTtte_superIo_ChIp_rEaD()) or have to use following chain:
->superio->logical_dev->read().
Or something like that...
So superio module will export common logical device structure which have
pointers to it's private functions and we may just call it.
Example of such behaviour is timer function(sc_timer_func()) in sc.c -
it is for testing and will definitely be removed.
External driver will get pointer to the logical device using
sc_{get,put}_ldev();

> > sc_{add,del}_logical_dev() links and unlinks logical device from the
> > main SuperIO module. After being added any logical device becomes
> > visible for the external world, but it should be accessed only through
> > main module using sc_{get,put}_ldev, which also increment/decrement
> > is's usage counter and may implement additional functionality. When
> > logical device is registered userspace can connect to it (actually it
> > is the next step and will be implemented after ability to handle
> > several main SuperIO logical modules) using either ioctl or netlink
> > but again only through main module - with such approach we can control
> > any data/control flow only in one place and do not disperse efforts.
> 
> What's the idea behind logical device registration? I don't see how this
> is needed. The reason why a superio driver is needed, as I understand
> it, is to handle concurrent accesses to 0x2E/0x2F. This means that all
> we really need is:
> 
> * Super-I/O detection.
> * Read and write functions (specifying a logical device and a register)
> * User-space interface to read and write.
> 
> Anything above that may be discussed but isn't strictly needed. I
> wouldn't mind shortcut functions for retrieving the logical device I/O
> address or activating the logical device, but these are really only
> read and write functions.
> 
> I don't even see the need of having a structure for logical devices.
> 
> Could you please explain what benefit your approach offers? I may be
> missing something.

As I described above we will not have code duplication and will have
ability to add/remove logical devices in run-time.

> Greg, I much would like to hear you about this.

I think we will come to logical conclusion when he will back from
vocation.
Or not.

``Quod erat demonstrandum'' wise latins would often say finishing
discussion with a scuffle :)

> > > > static int sc_activate_one_logical(struct sc_dev *dev, struct
> > > > logical_dev *ldev)(...)
> > > > static void sc_activate_logical(struct sc_dev *dev)
> > > 
> > > I doubt that the second one will ever be needed. There's no point in
> > > arbitrary activating all logical devices at once, is there? Ditto
> > > for deactivating.
> > 
> > Now it even is not called from any place. It was usefull when all
> > logical devices lived with main driver in one file and we registered
> > all at once.
> 
> Registering is one thing (even if I don't much get the interest at this
> point), activating is one other. Registering is a software, lernel
> internal action. Activating may have hardware consequences. If the
> functions are really about registering, they should be renamed. If they
> are about activating, then doing this on all logical devices at once
> doesn't make any sense and a function that does so shouldn't even exist.

Those function was used after all devices were logically registered and
then all we "hardware" activated.
In old version they were at one place and it was more convenient to
register them all at once and then to activate them all at once.

You right that it is deprecated now and not needed. I just explain why
it was there.

> > > base+size is really base+size-1. And actually size could go away and
> > > it would be base+1. Again, it's standard. I wouldn't even print it
> > > as"0x%x/0x%x". Super-I/O have a couple addresses by nature, not an
> > > I/O range (although this translates into a 2-address range in the
> > > end).
> > 
> > Sure, it should be base+size-1, but if it is not PC8736* but for
> > example SC1100 we must request more than 2 bytes at a time, because of
> > such chips I've added size parameter.
> 
> If the SC1100 does live at different addresses and uses a different
> number of I/O ports, I start wondering the point in having a common
> driver. What are the common points between regular Super-I/O chips and
> the SC1100? Care to explain how the SC1100 works?

sc1100 is a system-on-chip processor which has integrated superio
system.
Although AMD did not gave me spec(it's theirs fault), I have
documentation.
SuperIO chip there contains serial port, IR port, RTC, system wakeup
control and two AccessBUSes.
Although GPIO does not live in SuperIO module but in Core Logic module
it will enter into design quite good.

> 
> Thanks.
-- 
	Evgeniy Polyakov ( s0mbre )

Crash is better than data corruption. -- Art Grabowski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040823/c756b448/attachment.bin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PC87366] A bit different design for it's SuperIO.
  2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
                   ` (6 preceding siblings ...)
  2005-05-19  6:25 ` Evgeniy Polyakov
@ 2005-05-19  6:25 ` Greg KH
  2005-05-19  6:25 ` Evgeniy Polyakov
  2005-05-19  6:25 ` Jean Delvare
  9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

On Mon, Aug 23, 2004 at 03:08:29PM +0400, Evgeniy Polyakov wrote:
> On Sun, 2004-08-22 at 12:48, Jean Delvare wrote:
> > > > > #define SIO_LDN_GPIO		0x07	/* General-Purpose I/O (GPIO) Ports */
> > > > 
> > > > This is PC87366-specific and doesn't belong to that driver.
> > > 
> > > No, I think it just should be extended and include any other
> > > defines(for temperature, voltage and others). Although they may live
> > > in drivers for those logical devices. Driver for PC87366 may use it...
> > > I will move it there after it will be created (actually separated to
> > > support several main SuperIO chips at once).
> > 
> > I'm not sure I get everything you mean here (especially the last
> > sentence). At any rate, the logical device usage is
> > manufacturer-dependant and, in most cases, chip dependant. And when two
> > different chips each have a logical device for, say, temperature
> > monitoring, the way it is organized "inside" each logical device will be
> > different. So there's no benefit in adding labels or classes to each
> > logical device of each chip, since we will never be able to use them.
> > 
> > I insist that the superio driver should be mostly chip-independant. The
> > only part which will not be is the Super-I/O enter sequence. Since the
> > PC8736x chips don't need any, you may not be familiar with it. Most
> > Super-I/O chips need a special sequence to be written to them before
> > they activate. Since the superio driver won't know what it is looking
> > for before it finds it, it'll probably have to test all known keys, then
> > the client driver will ask not only for a given chip ID but for a key +
> > chip ID pair. This also means that you will have to store the (variable
> > length) key in the superio structure.
> 
> I'm absolutely agree here.
> I mean above that when I will split sc.c into generic part and pc8736*
> part I will move those definitions into the header for pc8736* driver.

That sounds fine.

> As I described above we will not have code duplication and will have
> ability to add/remove logical devices in run-time.

Which is a good thing.

> > Greg, I much would like to hear you about this.
> 
> I think we will come to logical conclusion when he will back from
> vocation.
> Or not.

Heh, it looks good to me.  Oh, and I suggest putting this in
drivers/superio for a location.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-05-19  6:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19  6:25 [PC87366] A bit different design for it's SuperIO Evgeniy Polyakov
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Greg KH
2005-05-19  6:25 ` Evgeniy Polyakov
2005-05-19  6:25 ` Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.