linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sony-laptop for 2.6.23-rc3
@ 2007-08-11  1:43 Mattia Dongili
  2007-08-11  1:43 ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
  0 siblings, 1 reply; 6+ messages in thread
From: Mattia Dongili @ 2007-08-11  1:43 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Stelian Pop

Hi Len,

two more patches for sony-laptop.
Please take a look at the second one (a bit more invasive): it fixes a
regression (http://bugzilla.kernel.org/show_bug.cgi?id=8803) and doesn't break
on my laptops, anyway better look for anything obvious that I may have missed.

---
 drivers/misc/sony-laptop.c |  212 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 153 insertions(+), 59 deletions(-)
-- 
Thanks
Mattia


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

* [PATCH 1/2] sony-laptop: enable vaio FZ events
  2007-08-11  1:43 [PATCH 0/2] sony-laptop for 2.6.23-rc3 Mattia Dongili
@ 2007-08-11  1:43 ` Mattia Dongili
  2007-08-11  1:43   ` [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries Mattia Dongili
  2007-08-12  3:33   ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
  0 siblings, 2 replies; 6+ messages in thread
From: Mattia Dongili @ 2007-08-11  1:43 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Stelian Pop, Mattia Dongili

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/misc/sony-laptop.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 99f48c7..1fd84a5 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -847,13 +847,17 @@ static struct sony_nc_event sony_C_events[] = {
 /* SNC-only model map */
 static struct dmi_system_id sony_nc_ids[] = {
 		{
-			.ident = "Sony Vaio FE Series",
+			.ident = "Sony Vaio FE/FZ Series",
 			.callback = sony_nc_C_enable,
 			.driver_data = sony_C_events,
 			.matches = {
 				DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
 				DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FE"),
 			},
+			{
+				DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+				DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ"),
+			},
 		},
 		{
 			.ident = "Sony Vaio C Series",
-- 
1.5.2.4


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

* [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries
  2007-08-11  1:43 ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
@ 2007-08-11  1:43   ` Mattia Dongili
  2007-08-12  3:27     ` Len Brown
  2007-08-12  3:33   ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
  1 sibling, 1 reply; 6+ messages in thread
From: Mattia Dongili @ 2007-08-11  1:43 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Stelian Pop, Mattia Dongili

Make the driver aware of this case and manage the existence of a
second separate IO port.
Fixes http://bugzilla.kernel.org/show_bug.cgi?id=8803

Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/misc/sony-laptop.c |  204 ++++++++++++++++++++++++++++++++------------
 1 files changed, 148 insertions(+), 56 deletions(-)

diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 1fd84a5..8f7c9ee 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1156,7 +1156,8 @@ static struct acpi_driver sony_nc_driver = {
 #define SONYPI_TYPE3_OFFSET	0x12
 
 struct sony_pic_ioport {
-	struct acpi_resource_io	io;
+	struct acpi_resource_io	io1;
+	struct acpi_resource_io	io2;
 	struct list_head	list;
 };
 
@@ -1426,11 +1427,11 @@ static u8 sony_pic_call1(u8 dev)
 {
 	u8 v1, v2;
 
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
 			ITERATIONS_LONG);
-	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
-	v1 = inb_p(spic_dev.cur_ioport->io.minimum + 4);
-	v2 = inb_p(spic_dev.cur_ioport->io.minimum);
+	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
+	v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4);
+	v2 = inb_p(spic_dev.cur_ioport->io1.minimum);
 	dprintk("sony_pic_call1: 0x%.4x\n", (v2 << 8) | v1);
 	return v2;
 }
@@ -1439,13 +1440,13 @@ static u8 sony_pic_call2(u8 dev, u8 fn)
 {
 	u8 v1;
 
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
 			ITERATIONS_LONG);
-	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
+	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
 			ITERATIONS_LONG);
-	outb(fn, spic_dev.cur_ioport->io.minimum);
-	v1 = inb_p(spic_dev.cur_ioport->io.minimum);
+	outb(fn, spic_dev.cur_ioport->io1.minimum);
+	v1 = inb_p(spic_dev.cur_ioport->io1.minimum);
 	dprintk("sony_pic_call2: 0x%.4x\n", v1);
 	return v1;
 }
@@ -1454,13 +1455,13 @@ static u8 sony_pic_call3(u8 dev, u8 fn, u8 v)
 {
 	u8 v1;
 
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
-	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
-	outb(fn, spic_dev.cur_ioport->io.minimum);
-	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
-	outb(v, spic_dev.cur_ioport->io.minimum);
-	v1 = inb_p(spic_dev.cur_ioport->io.minimum);
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
+	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
+	outb(fn, spic_dev.cur_ioport->io1.minimum);
+	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
+	outb(v, spic_dev.cur_ioport->io1.minimum);
+	v1 = inb_p(spic_dev.cur_ioport->io1.minimum);
 	dprintk("sony_pic_call3: 0x%.4x\n", v1);
 	return v1;
 }
@@ -2057,7 +2058,18 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
 
 	switch (resource->type) {
 	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
+		{
+			/* start IO enumeration */
+			struct sony_pic_ioport *ioport = kzalloc(sizeof(*ioport), GFP_KERNEL);
+			if (!ioport)
+				return AE_ERROR;
+
+			list_add(&ioport->list, &dev->ioports);
+			return AE_OK;
+		}
+
 	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
+		/* end IO enumeration */
 		return AE_OK;
 
 	case ACPI_RESOURCE_TYPE_IRQ:
@@ -2084,7 +2096,7 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
 				if (!interrupt)
 					return AE_ERROR;
 
-				list_add_tail(&interrupt->list, &dev->interrupts);
+				list_add(&interrupt->list, &dev->interrupts);
 				interrupt->irq.triggering = p->triggering;
 				interrupt->irq.polarity = p->polarity;
 				interrupt->irq.sharable = p->sharable;
@@ -2096,18 +2108,27 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
 	case ACPI_RESOURCE_TYPE_IO:
 		{
 			struct acpi_resource_io *io = &resource->data.io;
-			struct sony_pic_ioport *ioport = NULL;
+			struct sony_pic_ioport *ioport =
+				list_first_entry(&dev->ioports, struct sony_pic_ioport, list);
 			if (!io) {
 				dprintk("Blank IO resource\n");
 				return AE_OK;
 			}
 
-			ioport = kzalloc(sizeof(*ioport), GFP_KERNEL);
-			if (!ioport)
+			if (!ioport->io1.minimum) {
+				memcpy(&ioport->io1, io, sizeof(*io));
+				dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum,
+						ioport->io1.address_length);
+			}
+			else if (!ioport->io2.minimum) {
+				memcpy(&ioport->io2, io, sizeof(*io));
+				dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum,
+						ioport->io2.address_length);
+			}
+			else {
+				printk(KERN_ERR DRV_PFX "Unknown SPIC Type, more than 2 IO Ports\n");
 				return AE_ERROR;
-
-			list_add_tail(&ioport->list, &dev->ioports);
-			memcpy(&ioport->io, io, sizeof(*io));
+			}
 			return AE_OK;
 		}
 	default:
@@ -2182,10 +2203,22 @@ static int sony_pic_enable(struct acpi_device *device,
 {
 	acpi_status status;
 	int result = 0;
+	/* Type 1 resource layout is:
+	 *    IO
+	 *    IO
+	 *    IRQNoFlags
+	 *    End
+	 *
+	 * Type 2 and 3 resource layout is:
+	 *    IO
+	 *    IRQNoFlags
+	 *    End
+	 */
 	struct {
-		struct acpi_resource io_res;
-		struct acpi_resource irq_res;
-		struct acpi_resource end;
+		struct acpi_resource res1;
+		struct acpi_resource res2;
+		struct acpi_resource res3;
+		struct acpi_resource res4;
 	} *resource;
 	struct acpi_buffer buffer = { 0, NULL };
 
@@ -2200,21 +2233,49 @@ static int sony_pic_enable(struct acpi_device *device,
 	buffer.length = sizeof(*resource) + 1;
 	buffer.pointer = resource;
 
-	/* setup io resource */
-	resource->io_res.type = ACPI_RESOURCE_TYPE_IO;
-	resource->io_res.length = sizeof(struct acpi_resource);
-	memcpy(&resource->io_res.data.io, &ioport->io,
-			sizeof(struct acpi_resource_io));
+	/* setup Type 1 resources */
+	if (spic_dev.model == SONYPI_DEVICE_TYPE1) {
 
-	/* setup irq resource */
-	resource->irq_res.type = ACPI_RESOURCE_TYPE_IRQ;
-	resource->irq_res.length = sizeof(struct acpi_resource);
-	memcpy(&resource->irq_res.data.irq, &irq->irq,
-			sizeof(struct acpi_resource_irq));
-	/* we requested a shared irq */
-	resource->irq_res.data.irq.sharable = ACPI_SHARED;
+		/* setup io resources */
+		resource->res1.type = ACPI_RESOURCE_TYPE_IO;
+		resource->res1.length = sizeof(struct acpi_resource);
+		memcpy(&resource->res1.data.io, &ioport->io1,
+				sizeof(struct acpi_resource_io));
 
-	resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
+		resource->res2.type = ACPI_RESOURCE_TYPE_IO;
+		resource->res2.length = sizeof(struct acpi_resource);
+		memcpy(&resource->res2.data.io, &ioport->io2,
+				sizeof(struct acpi_resource_io));
+
+		/* setup irq resource */
+		resource->res3.type = ACPI_RESOURCE_TYPE_IRQ;
+		resource->res3.length = sizeof(struct acpi_resource);
+		memcpy(&resource->res3.data.irq, &irq->irq,
+				sizeof(struct acpi_resource_irq));
+		/* we requested a shared irq */
+		resource->res3.data.irq.sharable = ACPI_SHARED;
+
+		resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG;
+
+	}
+	/* setup Type 2/3 resources */
+	else {
+		/* setup io resource */
+		resource->res1.type = ACPI_RESOURCE_TYPE_IO;
+		resource->res1.length = sizeof(struct acpi_resource);
+		memcpy(&resource->res1.data.io, &ioport->io1,
+				sizeof(struct acpi_resource_io));
+
+		/* setup irq resource */
+		resource->res2.type = ACPI_RESOURCE_TYPE_IRQ;
+		resource->res2.length = sizeof(struct acpi_resource);
+		memcpy(&resource->res2.data.irq, &irq->irq,
+				sizeof(struct acpi_resource_irq));
+		/* we requested a shared irq */
+		resource->res2.data.irq.sharable = ACPI_SHARED;
+
+		resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG;
+	}
 
 	/* Attempt to set the resource */
 	dprintk("Evaluating _SRS\n");
@@ -2222,7 +2283,7 @@ static int sony_pic_enable(struct acpi_device *device,
 
 	/* check for total failure */
 	if (ACPI_FAILURE(status)) {
-		printk(KERN_ERR DRV_PFX "Error evaluating _SRS");
+		printk(KERN_ERR DRV_PFX "Error evaluating _SRS\n");
 		result = -ENODEV;
 		goto end;
 	}
@@ -2251,11 +2312,14 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id)
 
 	struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id;
 
-	ev = inb_p(dev->cur_ioport->io.minimum);
-	data_mask = inb_p(dev->cur_ioport->io.minimum + dev->evport_offset);
+	ev = inb_p(dev->cur_ioport->io1.minimum);
+	if (dev->cur_ioport->io2.minimum)
+		data_mask = inb_p(dev->cur_ioport->io2.minimum);
+	else
+		data_mask = inb_p(dev->cur_ioport->io1.minimum + dev->evport_offset);
 
 	dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
-			ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset);
+			ev, data_mask, dev->cur_ioport->io1.minimum, dev->evport_offset);
 
 	if (ev == 0x00 || ev == 0xff)
 		return IRQ_HANDLED;
@@ -2308,8 +2372,11 @@ static int sony_pic_remove(struct acpi_device *device, int type)
 	}
 
 	free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
-	release_region(spic_dev.cur_ioport->io.minimum,
-			spic_dev.cur_ioport->io.address_length);
+	release_region(spic_dev.cur_ioport->io1.minimum,
+			spic_dev.cur_ioport->io1.address_length);
+	if (spic_dev.cur_ioport->io2.minimum)
+		release_region(spic_dev.cur_ioport->io2.minimum,
+				spic_dev.cur_ioport->io2.address_length);
 
 	sony_laptop_remove_input();
 
@@ -2377,14 +2444,36 @@ static int sony_pic_add(struct acpi_device *device)
 	}
 
 	/* request io port */
-	list_for_each_entry(io, &spic_dev.ioports, list) {
-		if (request_region(io->io.minimum, io->io.address_length,
+	list_for_each_entry_reverse(io, &spic_dev.ioports, list) {
+		if (request_region(io->io1.minimum, io->io1.address_length,
 					"Sony Programable I/O Device")) {
-			dprintk("I/O port: 0x%.4x (0x%.4x) + 0x%.2x\n",
-					io->io.minimum, io->io.maximum,
-					io->io.address_length);
-			spic_dev.cur_ioport = io;
-			break;
+			dprintk("I/O port1: 0x%.4x (0x%.4x) + 0x%.2x\n",
+					io->io1.minimum, io->io1.maximum,
+					io->io1.address_length);
+			/* Type 1 have 2 ioports */
+			if (io->io2.minimum) {
+				if (request_region(io->io2.minimum,
+						io->io2.address_length,
+						"Sony Programable I/O Device")) {
+					dprintk("I/O port2: 0x%.4x (0x%.4x) + 0x%.2x\n",
+							io->io2.minimum, io->io2.maximum,
+							io->io2.address_length);
+					spic_dev.cur_ioport = io;
+					break;
+				}
+				else {
+					dprintk("Unable to get I/O port2: "
+							"0x%.4x (0x%.4x) + 0x%.2x\n",
+							io->io2.minimum, io->io2.maximum,
+							io->io2.address_length);
+					release_region(io->io1.minimum,
+							io->io1.address_length);
+				}
+			}
+			else {
+				spic_dev.cur_ioport = io;
+				break;
+			}
 		}
 	}
 	if (!spic_dev.cur_ioport) {
@@ -2394,7 +2483,7 @@ static int sony_pic_add(struct acpi_device *device)
 	}
 
 	/* request IRQ */
-	list_for_each_entry(irq, &spic_dev.interrupts, list) {
+	list_for_each_entry_reverse(irq, &spic_dev.interrupts, list) {
 		if (!request_irq(irq->irq.interrupts[0], sony_pic_irq,
 					IRQF_SHARED, "sony-laptop", &spic_dev)) {
 			dprintk("IRQ: %d - triggering: %d - "
@@ -2445,8 +2534,11 @@ err_free_irq:
 	free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
 
 err_release_region:
-	release_region(spic_dev.cur_ioport->io.minimum,
-			spic_dev.cur_ioport->io.address_length);
+	release_region(spic_dev.cur_ioport->io1.minimum,
+			spic_dev.cur_ioport->io1.address_length);
+	if (spic_dev.cur_ioport->io2.minimum)
+		release_region(spic_dev.cur_ioport->io2.minimum,
+				spic_dev.cur_ioport->io2.address_length);
 
 err_remove_input:
 	sony_laptop_remove_input();
-- 
1.5.2.4


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

* Re: [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries
  2007-08-11  1:43   ` [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries Mattia Dongili
@ 2007-08-12  3:27     ` Len Brown
  2007-08-12  4:26       ` Mattia Dongili
  0 siblings, 1 reply; 6+ messages in thread
From: Len Brown @ 2007-08-12  3:27 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: linux-acpi, Stelian Pop

On Friday 10 August 2007 21:43, Mattia Dongili wrote:
> Make the driver aware of this case and manage the existence of a
> second separate IO port.
> Fixes http://bugzilla.kernel.org/show_bug.cgi?id=8803

Why is this marked as a regression vs 2.6.21?
Is the problem that sonypi supported this this type of box
and sony-laptop did not, and that is when the submitter
started using sony-laptop?

They can still build and use sonypi in 2.6.22, 3 if they want, yes?

I don't see a huge risk in applying this patch, because it
seems that it (should) only have an effect on the boxes
that were not properly supported before.

But, it is pretty big for a post-rc2 type thing,
particularly if they can still use sonypi per above.
Probably appropriate to test it till 2.6.24.

-Len

> 
> Signed-off-by: Mattia Dongili <malattia@linux.it>
> ---
>  drivers/misc/sony-laptop.c |  204 ++++++++++++++++++++++++++++++++------------
>  1 files changed, 148 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
> index 1fd84a5..8f7c9ee 100644
> --- a/drivers/misc/sony-laptop.c
> +++ b/drivers/misc/sony-laptop.c
> @@ -1156,7 +1156,8 @@ static struct acpi_driver sony_nc_driver = {
>  #define SONYPI_TYPE3_OFFSET	0x12
>  
>  struct sony_pic_ioport {
> -	struct acpi_resource_io	io;
> +	struct acpi_resource_io	io1;
> +	struct acpi_resource_io	io2;
>  	struct list_head	list;
>  };
>  
> @@ -1426,11 +1427,11 @@ static u8 sony_pic_call1(u8 dev)
>  {
>  	u8 v1, v2;
>  
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
>  			ITERATIONS_LONG);
> -	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
> -	v1 = inb_p(spic_dev.cur_ioport->io.minimum + 4);
> -	v2 = inb_p(spic_dev.cur_ioport->io.minimum);
> +	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
> +	v1 = inb_p(spic_dev.cur_ioport->io1.minimum + 4);
> +	v2 = inb_p(spic_dev.cur_ioport->io1.minimum);
>  	dprintk("sony_pic_call1: 0x%.4x\n", (v2 << 8) | v1);
>  	return v2;
>  }
> @@ -1439,13 +1440,13 @@ static u8 sony_pic_call2(u8 dev, u8 fn)
>  {
>  	u8 v1;
>  
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
>  			ITERATIONS_LONG);
> -	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2,
> +	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2,
>  			ITERATIONS_LONG);
> -	outb(fn, spic_dev.cur_ioport->io.minimum);
> -	v1 = inb_p(spic_dev.cur_ioport->io.minimum);
> +	outb(fn, spic_dev.cur_ioport->io1.minimum);
> +	v1 = inb_p(spic_dev.cur_ioport->io1.minimum);
>  	dprintk("sony_pic_call2: 0x%.4x\n", v1);
>  	return v1;
>  }
> @@ -1454,13 +1455,13 @@ static u8 sony_pic_call3(u8 dev, u8 fn, u8 v)
>  {
>  	u8 v1;
>  
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
> -	outb(dev, spic_dev.cur_ioport->io.minimum + 4);
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
> -	outb(fn, spic_dev.cur_ioport->io.minimum);
> -	wait_on_command(inb_p(spic_dev.cur_ioport->io.minimum + 4) & 2, ITERATIONS_LONG);
> -	outb(v, spic_dev.cur_ioport->io.minimum);
> -	v1 = inb_p(spic_dev.cur_ioport->io.minimum);
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
> +	outb(dev, spic_dev.cur_ioport->io1.minimum + 4);
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
> +	outb(fn, spic_dev.cur_ioport->io1.minimum);
> +	wait_on_command(inb_p(spic_dev.cur_ioport->io1.minimum + 4) & 2, ITERATIONS_LONG);
> +	outb(v, spic_dev.cur_ioport->io1.minimum);
> +	v1 = inb_p(spic_dev.cur_ioport->io1.minimum);
>  	dprintk("sony_pic_call3: 0x%.4x\n", v1);
>  	return v1;
>  }
> @@ -2057,7 +2058,18 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
>  
>  	switch (resource->type) {
>  	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
> +		{
> +			/* start IO enumeration */
> +			struct sony_pic_ioport *ioport = kzalloc(sizeof(*ioport), GFP_KERNEL);
> +			if (!ioport)
> +				return AE_ERROR;
> +
> +			list_add(&ioport->list, &dev->ioports);
> +			return AE_OK;
> +		}
> +
>  	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
> +		/* end IO enumeration */
>  		return AE_OK;
>  
>  	case ACPI_RESOURCE_TYPE_IRQ:
> @@ -2084,7 +2096,7 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
>  				if (!interrupt)
>  					return AE_ERROR;
>  
> -				list_add_tail(&interrupt->list, &dev->interrupts);
> +				list_add(&interrupt->list, &dev->interrupts);
>  				interrupt->irq.triggering = p->triggering;
>  				interrupt->irq.polarity = p->polarity;
>  				interrupt->irq.sharable = p->sharable;
> @@ -2096,18 +2108,27 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
>  	case ACPI_RESOURCE_TYPE_IO:
>  		{
>  			struct acpi_resource_io *io = &resource->data.io;
> -			struct sony_pic_ioport *ioport = NULL;
> +			struct sony_pic_ioport *ioport =
> +				list_first_entry(&dev->ioports, struct sony_pic_ioport, list);
>  			if (!io) {
>  				dprintk("Blank IO resource\n");
>  				return AE_OK;
>  			}
>  
> -			ioport = kzalloc(sizeof(*ioport), GFP_KERNEL);
> -			if (!ioport)
> +			if (!ioport->io1.minimum) {
> +				memcpy(&ioport->io1, io, sizeof(*io));
> +				dprintk("IO1 at 0x%.4x (0x%.2x)\n", ioport->io1.minimum,
> +						ioport->io1.address_length);
> +			}
> +			else if (!ioport->io2.minimum) {
> +				memcpy(&ioport->io2, io, sizeof(*io));
> +				dprintk("IO2 at 0x%.4x (0x%.2x)\n", ioport->io2.minimum,
> +						ioport->io2.address_length);
> +			}
> +			else {
> +				printk(KERN_ERR DRV_PFX "Unknown SPIC Type, more than 2 IO Ports\n");
>  				return AE_ERROR;
> -
> -			list_add_tail(&ioport->list, &dev->ioports);
> -			memcpy(&ioport->io, io, sizeof(*io));
> +			}
>  			return AE_OK;
>  		}
>  	default:
> @@ -2182,10 +2203,22 @@ static int sony_pic_enable(struct acpi_device *device,
>  {
>  	acpi_status status;
>  	int result = 0;
> +	/* Type 1 resource layout is:
> +	 *    IO
> +	 *    IO
> +	 *    IRQNoFlags
> +	 *    End
> +	 *
> +	 * Type 2 and 3 resource layout is:
> +	 *    IO
> +	 *    IRQNoFlags
> +	 *    End
> +	 */
>  	struct {
> -		struct acpi_resource io_res;
> -		struct acpi_resource irq_res;
> -		struct acpi_resource end;
> +		struct acpi_resource res1;
> +		struct acpi_resource res2;
> +		struct acpi_resource res3;
> +		struct acpi_resource res4;
>  	} *resource;
>  	struct acpi_buffer buffer = { 0, NULL };
>  
> @@ -2200,21 +2233,49 @@ static int sony_pic_enable(struct acpi_device *device,
>  	buffer.length = sizeof(*resource) + 1;
>  	buffer.pointer = resource;
>  
> -	/* setup io resource */
> -	resource->io_res.type = ACPI_RESOURCE_TYPE_IO;
> -	resource->io_res.length = sizeof(struct acpi_resource);
> -	memcpy(&resource->io_res.data.io, &ioport->io,
> -			sizeof(struct acpi_resource_io));
> +	/* setup Type 1 resources */
> +	if (spic_dev.model == SONYPI_DEVICE_TYPE1) {
>  
> -	/* setup irq resource */
> -	resource->irq_res.type = ACPI_RESOURCE_TYPE_IRQ;
> -	resource->irq_res.length = sizeof(struct acpi_resource);
> -	memcpy(&resource->irq_res.data.irq, &irq->irq,
> -			sizeof(struct acpi_resource_irq));
> -	/* we requested a shared irq */
> -	resource->irq_res.data.irq.sharable = ACPI_SHARED;
> +		/* setup io resources */
> +		resource->res1.type = ACPI_RESOURCE_TYPE_IO;
> +		resource->res1.length = sizeof(struct acpi_resource);
> +		memcpy(&resource->res1.data.io, &ioport->io1,
> +				sizeof(struct acpi_resource_io));
>  
> -	resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
> +		resource->res2.type = ACPI_RESOURCE_TYPE_IO;
> +		resource->res2.length = sizeof(struct acpi_resource);
> +		memcpy(&resource->res2.data.io, &ioport->io2,
> +				sizeof(struct acpi_resource_io));
> +
> +		/* setup irq resource */
> +		resource->res3.type = ACPI_RESOURCE_TYPE_IRQ;
> +		resource->res3.length = sizeof(struct acpi_resource);
> +		memcpy(&resource->res3.data.irq, &irq->irq,
> +				sizeof(struct acpi_resource_irq));
> +		/* we requested a shared irq */
> +		resource->res3.data.irq.sharable = ACPI_SHARED;
> +
> +		resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG;
> +
> +	}
> +	/* setup Type 2/3 resources */
> +	else {
> +		/* setup io resource */
> +		resource->res1.type = ACPI_RESOURCE_TYPE_IO;
> +		resource->res1.length = sizeof(struct acpi_resource);
> +		memcpy(&resource->res1.data.io, &ioport->io1,
> +				sizeof(struct acpi_resource_io));
> +
> +		/* setup irq resource */
> +		resource->res2.type = ACPI_RESOURCE_TYPE_IRQ;
> +		resource->res2.length = sizeof(struct acpi_resource);
> +		memcpy(&resource->res2.data.irq, &irq->irq,
> +				sizeof(struct acpi_resource_irq));
> +		/* we requested a shared irq */
> +		resource->res2.data.irq.sharable = ACPI_SHARED;
> +
> +		resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG;
> +	}
>  
>  	/* Attempt to set the resource */
>  	dprintk("Evaluating _SRS\n");
> @@ -2222,7 +2283,7 @@ static int sony_pic_enable(struct acpi_device *device,
>  
>  	/* check for total failure */
>  	if (ACPI_FAILURE(status)) {
> -		printk(KERN_ERR DRV_PFX "Error evaluating _SRS");
> +		printk(KERN_ERR DRV_PFX "Error evaluating _SRS\n");
>  		result = -ENODEV;
>  		goto end;
>  	}
> @@ -2251,11 +2312,14 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id)
>  
>  	struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id;
>  
> -	ev = inb_p(dev->cur_ioport->io.minimum);
> -	data_mask = inb_p(dev->cur_ioport->io.minimum + dev->evport_offset);
> +	ev = inb_p(dev->cur_ioport->io1.minimum);
> +	if (dev->cur_ioport->io2.minimum)
> +		data_mask = inb_p(dev->cur_ioport->io2.minimum);
> +	else
> +		data_mask = inb_p(dev->cur_ioport->io1.minimum + dev->evport_offset);
>  
>  	dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
> -			ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset);
> +			ev, data_mask, dev->cur_ioport->io1.minimum, dev->evport_offset);
>  
>  	if (ev == 0x00 || ev == 0xff)
>  		return IRQ_HANDLED;
> @@ -2308,8 +2372,11 @@ static int sony_pic_remove(struct acpi_device *device, int type)
>  	}
>  
>  	free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
> -	release_region(spic_dev.cur_ioport->io.minimum,
> -			spic_dev.cur_ioport->io.address_length);
> +	release_region(spic_dev.cur_ioport->io1.minimum,
> +			spic_dev.cur_ioport->io1.address_length);
> +	if (spic_dev.cur_ioport->io2.minimum)
> +		release_region(spic_dev.cur_ioport->io2.minimum,
> +				spic_dev.cur_ioport->io2.address_length);
>  
>  	sony_laptop_remove_input();
>  
> @@ -2377,14 +2444,36 @@ static int sony_pic_add(struct acpi_device *device)
>  	}
>  
>  	/* request io port */
> -	list_for_each_entry(io, &spic_dev.ioports, list) {
> -		if (request_region(io->io.minimum, io->io.address_length,
> +	list_for_each_entry_reverse(io, &spic_dev.ioports, list) {
> +		if (request_region(io->io1.minimum, io->io1.address_length,
>  					"Sony Programable I/O Device")) {
> -			dprintk("I/O port: 0x%.4x (0x%.4x) + 0x%.2x\n",
> -					io->io.minimum, io->io.maximum,
> -					io->io.address_length);
> -			spic_dev.cur_ioport = io;
> -			break;
> +			dprintk("I/O port1: 0x%.4x (0x%.4x) + 0x%.2x\n",
> +					io->io1.minimum, io->io1.maximum,
> +					io->io1.address_length);
> +			/* Type 1 have 2 ioports */
> +			if (io->io2.minimum) {
> +				if (request_region(io->io2.minimum,
> +						io->io2.address_length,
> +						"Sony Programable I/O Device")) {
> +					dprintk("I/O port2: 0x%.4x (0x%.4x) + 0x%.2x\n",
> +							io->io2.minimum, io->io2.maximum,
> +							io->io2.address_length);
> +					spic_dev.cur_ioport = io;
> +					break;
> +				}
> +				else {
> +					dprintk("Unable to get I/O port2: "
> +							"0x%.4x (0x%.4x) + 0x%.2x\n",
> +							io->io2.minimum, io->io2.maximum,
> +							io->io2.address_length);
> +					release_region(io->io1.minimum,
> +							io->io1.address_length);
> +				}
> +			}
> +			else {
> +				spic_dev.cur_ioport = io;
> +				break;
> +			}
>  		}
>  	}
>  	if (!spic_dev.cur_ioport) {
> @@ -2394,7 +2483,7 @@ static int sony_pic_add(struct acpi_device *device)
>  	}
>  
>  	/* request IRQ */
> -	list_for_each_entry(irq, &spic_dev.interrupts, list) {
> +	list_for_each_entry_reverse(irq, &spic_dev.interrupts, list) {
>  		if (!request_irq(irq->irq.interrupts[0], sony_pic_irq,
>  					IRQF_SHARED, "sony-laptop", &spic_dev)) {
>  			dprintk("IRQ: %d - triggering: %d - "
> @@ -2445,8 +2534,11 @@ err_free_irq:
>  	free_irq(spic_dev.cur_irq->irq.interrupts[0], &spic_dev);
>  
>  err_release_region:
> -	release_region(spic_dev.cur_ioport->io.minimum,
> -			spic_dev.cur_ioport->io.address_length);
> +	release_region(spic_dev.cur_ioport->io1.minimum,
> +			spic_dev.cur_ioport->io1.address_length);
> +	if (spic_dev.cur_ioport->io2.minimum)
> +		release_region(spic_dev.cur_ioport->io2.minimum,
> +				spic_dev.cur_ioport->io2.address_length);
>  
>  err_remove_input:
>  	sony_laptop_remove_input();

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

* Re: [PATCH 1/2] sony-laptop: enable vaio FZ events
  2007-08-11  1:43 ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
  2007-08-11  1:43   ` [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries Mattia Dongili
@ 2007-08-12  3:33   ` Mattia Dongili
  1 sibling, 0 replies; 6+ messages in thread
From: Mattia Dongili @ 2007-08-12  3:33 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Stelian Pop

On Sat, Aug 11, 2007 at 10:43:06AM +0900, Mattia Dongili wrote:
> Signed-off-by: Mattia Dongili <malattia@linux.it>
...
>  			.matches = {
>  				DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
>  				DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FE"),
>  			},
> +			{
> +				DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
> +				DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ"),
> +			},
>  		},
>  		{

sorry, this is wrong. Will resend shortly
-- 
mattia
:wq!

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

* Re: [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries
  2007-08-12  3:27     ` Len Brown
@ 2007-08-12  4:26       ` Mattia Dongili
  0 siblings, 0 replies; 6+ messages in thread
From: Mattia Dongili @ 2007-08-12  4:26 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, Stelian Pop

On Sat, Aug 11, 2007 at 11:27:44PM -0400, Len Brown wrote:
> On Friday 10 August 2007 21:43, Mattia Dongili wrote:
> > Make the driver aware of this case and manage the existence of a
> > second separate IO port.
> > Fixes http://bugzilla.kernel.org/show_bug.cgi?id=8803
> 
> Why is this marked as a regression vs 2.6.21?
> Is the problem that sonypi supported this this type of box
> and sony-laptop did not, and that is when the submitter
> started using sony-laptop?
> 
> They can still build and use sonypi in 2.6.22, 3 if they want, yes?

yes but they can't use meye.ko which now (since .22) depends on
sony-laptop loading correctly on their boxes.

> I don't see a huge risk in applying this patch, because it
> seems that it (should) only have an effect on the boxes
> that were not properly supported before.

yep, that's the purpose :)

> But, it is pretty big for a post-rc2 type thing,
> particularly if they can still use sonypi per above.
> Probably appropriate to test it till 2.6.24.

as said the problem is meye, but I agree it's not very appropriate as a
post-rc2.
Oh, and I seem to have some randomic Oops when loading the module (most
probably unrelated to this patch). Let me re-doublecheck it all once
again.

-- 
mattia
:wq!

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

end of thread, other threads:[~2007-08-12  4:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-11  1:43 [PATCH 0/2] sony-laptop for 2.6.23-rc3 Mattia Dongili
2007-08-11  1:43 ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili
2007-08-11  1:43   ` [PATCH 2/2] sony-laptop: old Vaio models contain 2 IO port entries Mattia Dongili
2007-08-12  3:27     ` Len Brown
2007-08-12  4:26       ` Mattia Dongili
2007-08-12  3:33   ` [PATCH 1/2] sony-laptop: enable vaio FZ events Mattia Dongili

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).