diff options
Diffstat (limited to 'drivers/misc')
30 files changed, 868 insertions, 538 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 98a442da892a..99c73352c430 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -105,7 +105,7 @@ config ATMEL_TCB_CLKSRC_BLOCK | |||
105 | 105 | ||
106 | config IBM_ASM | 106 | config IBM_ASM |
107 | tristate "Device driver for IBM RSA service processor" | 107 | tristate "Device driver for IBM RSA service processor" |
108 | depends on X86 && PCI && INPUT && EXPERIMENTAL | 108 | depends on X86 && PCI && INPUT |
109 | ---help--- | 109 | ---help--- |
110 | This option enables device driver support for in-band access to the | 110 | This option enables device driver support for in-band access to the |
111 | IBM RSA (Condor) service processor in eServer xSeries systems. | 111 | IBM RSA (Condor) service processor in eServer xSeries systems. |
@@ -162,8 +162,8 @@ config SGI_IOC4 | |||
162 | Otherwise say N. | 162 | Otherwise say N. |
163 | 163 | ||
164 | config TIFM_CORE | 164 | config TIFM_CORE |
165 | tristate "TI Flash Media interface support (EXPERIMENTAL)" | 165 | tristate "TI Flash Media interface support" |
166 | depends on EXPERIMENTAL && PCI | 166 | depends on PCI |
167 | help | 167 | help |
168 | If you want support for Texas Instruments(R) Flash Media adapters | 168 | If you want support for Texas Instruments(R) Flash Media adapters |
169 | you should select this option and then also choose an appropriate | 169 | you should select this option and then also choose an appropriate |
@@ -178,8 +178,8 @@ config TIFM_CORE | |||
178 | be called tifm_core. | 178 | be called tifm_core. |
179 | 179 | ||
180 | config TIFM_7XX1 | 180 | config TIFM_7XX1 |
181 | tristate "TI Flash Media PCI74xx/PCI76xx host adapter support (EXPERIMENTAL)" | 181 | tristate "TI Flash Media PCI74xx/PCI76xx host adapter support" |
182 | depends on PCI && TIFM_CORE && EXPERIMENTAL | 182 | depends on PCI && TIFM_CORE |
183 | default TIFM_CORE | 183 | default TIFM_CORE |
184 | help | 184 | help |
185 | This option enables support for Texas Instruments(R) PCI74xx and | 185 | This option enables support for Texas Instruments(R) PCI74xx and |
@@ -192,7 +192,7 @@ config TIFM_7XX1 | |||
192 | 192 | ||
193 | config ICS932S401 | 193 | config ICS932S401 |
194 | tristate "Integrated Circuits ICS932S401" | 194 | tristate "Integrated Circuits ICS932S401" |
195 | depends on I2C && EXPERIMENTAL | 195 | depends on I2C |
196 | help | 196 | help |
197 | If you say yes here you get support for the Integrated Circuits | 197 | If you say yes here you get support for the Integrated Circuits |
198 | ICS932S401 clock control chips. | 198 | ICS932S401 clock control chips. |
@@ -398,7 +398,7 @@ config EP93XX_PWM | |||
398 | 398 | ||
399 | config DS1682 | 399 | config DS1682 |
400 | tristate "Dallas DS1682 Total Elapsed Time Recorder with Alarm" | 400 | tristate "Dallas DS1682 Total Elapsed Time Recorder with Alarm" |
401 | depends on I2C && EXPERIMENTAL | 401 | depends on I2C |
402 | help | 402 | help |
403 | If you say yes here you get support for Dallas Semiconductor | 403 | If you say yes here you get support for Dallas Semiconductor |
404 | DS1682 Total Elapsed Time Recorder. | 404 | DS1682 Total Elapsed Time Recorder. |
diff --git a/drivers/misc/bmp085-i2c.c b/drivers/misc/bmp085-i2c.c index 9943971c13e3..a4f33c995ea1 100644 --- a/drivers/misc/bmp085-i2c.c +++ b/drivers/misc/bmp085-i2c.c | |||
@@ -57,12 +57,6 @@ static int bmp085_i2c_remove(struct i2c_client *client) | |||
57 | return bmp085_remove(&client->dev); | 57 | return bmp085_remove(&client->dev); |
58 | } | 58 | } |
59 | 59 | ||
60 | static const struct of_device_id bmp085_of_match[] = { | ||
61 | { .compatible = "bosch,bmp085", }, | ||
62 | { }, | ||
63 | }; | ||
64 | MODULE_DEVICE_TABLE(of, bmp085_of_match); | ||
65 | |||
66 | static const struct i2c_device_id bmp085_id[] = { | 60 | static const struct i2c_device_id bmp085_id[] = { |
67 | { BMP085_NAME, 0 }, | 61 | { BMP085_NAME, 0 }, |
68 | { "bmp180", 0 }, | 62 | { "bmp180", 0 }, |
@@ -74,7 +68,6 @@ static struct i2c_driver bmp085_i2c_driver = { | |||
74 | .driver = { | 68 | .driver = { |
75 | .owner = THIS_MODULE, | 69 | .owner = THIS_MODULE, |
76 | .name = BMP085_NAME, | 70 | .name = BMP085_NAME, |
77 | .of_match_table = bmp085_of_match | ||
78 | }, | 71 | }, |
79 | .id_table = bmp085_id, | 72 | .id_table = bmp085_id, |
80 | .probe = bmp085_i2c_probe, | 73 | .probe = bmp085_i2c_probe, |
diff --git a/drivers/misc/bmp085-spi.c b/drivers/misc/bmp085-spi.c index 78aaff9b5231..5e982af99730 100644 --- a/drivers/misc/bmp085-spi.c +++ b/drivers/misc/bmp085-spi.c | |||
@@ -73,19 +73,8 @@ static struct spi_driver bmp085_spi_driver = { | |||
73 | .remove = __devexit_p(bmp085_spi_remove) | 73 | .remove = __devexit_p(bmp085_spi_remove) |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static int __init bmp085_spi_init(void) | 76 | module_spi_driver(bmp085_spi_driver); |
77 | { | ||
78 | return spi_register_driver(&bmp085_spi_driver); | ||
79 | } | ||
80 | |||
81 | static void __exit bmp085_spi_exit(void) | ||
82 | { | ||
83 | spi_unregister_driver(&bmp085_spi_driver); | ||
84 | } | ||
85 | 77 | ||
86 | MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>"); | 78 | MODULE_AUTHOR("Eric Andersson <eric.andersson@unixphere.com>"); |
87 | MODULE_DESCRIPTION("BMP085 SPI bus driver"); | 79 | MODULE_DESCRIPTION("BMP085 SPI bus driver"); |
88 | MODULE_LICENSE("GPL"); | 80 | MODULE_LICENSE("GPL"); |
89 | |||
90 | module_init(bmp085_spi_init); | ||
91 | module_exit(bmp085_spi_exit); | ||
diff --git a/drivers/misc/c2port/Kconfig b/drivers/misc/c2port/Kconfig index 33ee834e1b83..0dd690e61d3c 100644 --- a/drivers/misc/c2port/Kconfig +++ b/drivers/misc/c2port/Kconfig | |||
@@ -3,8 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menuconfig C2PORT | 5 | menuconfig C2PORT |
6 | tristate "Silicon Labs C2 port support (EXPERIMENTAL)" | 6 | tristate "Silicon Labs C2 port support" |
7 | depends on EXPERIMENTAL | ||
8 | default n | 7 | default n |
9 | help | 8 | help |
10 | This option enables support for Silicon Labs C2 port used to | 9 | This option enables support for Silicon Labs C2 port used to |
@@ -22,7 +21,7 @@ menuconfig C2PORT | |||
22 | if C2PORT | 21 | if C2PORT |
23 | 22 | ||
24 | config C2PORT_DURAMAR_2150 | 23 | config C2PORT_DURAMAR_2150 |
25 | tristate "C2 port support for Eurotech's Duramar 2150 (EXPERIMENTAL)" | 24 | tristate "C2 port support for Eurotech's Duramar 2150" |
26 | depends on X86 | 25 | depends on X86 |
27 | default n | 26 | default n |
28 | help | 27 | help |
diff --git a/drivers/misc/carma/carma-fpga-program.c b/drivers/misc/carma/carma-fpga-program.c index a2d25e4857e3..eaddfe9db149 100644 --- a/drivers/misc/carma/carma-fpga-program.c +++ b/drivers/misc/carma/carma-fpga-program.c | |||
@@ -978,7 +978,6 @@ static int fpga_of_probe(struct platform_device *op) | |||
978 | dev_set_drvdata(priv->dev, priv); | 978 | dev_set_drvdata(priv->dev, priv); |
979 | dma_cap_zero(mask); | 979 | dma_cap_zero(mask); |
980 | dma_cap_set(DMA_MEMCPY, mask); | 980 | dma_cap_set(DMA_MEMCPY, mask); |
981 | dma_cap_set(DMA_INTERRUPT, mask); | ||
982 | dma_cap_set(DMA_SLAVE, mask); | 981 | dma_cap_set(DMA_SLAVE, mask); |
983 | dma_cap_set(DMA_SG, mask); | 982 | dma_cap_set(DMA_SG, mask); |
984 | 983 | ||
diff --git a/drivers/misc/carma/carma-fpga.c b/drivers/misc/carma/carma-fpga.c index 8c279da07410..0c43297ed9ac 100644 --- a/drivers/misc/carma/carma-fpga.c +++ b/drivers/misc/carma/carma-fpga.c | |||
@@ -666,7 +666,7 @@ static int data_submit_dma(struct fpga_device *priv, struct data_buf *buf) | |||
666 | src = SYS_FPGA_BLOCK; | 666 | src = SYS_FPGA_BLOCK; |
667 | tx = chan->device->device_prep_dma_memcpy(chan, dst, src, | 667 | tx = chan->device->device_prep_dma_memcpy(chan, dst, src, |
668 | REG_BLOCK_SIZE, | 668 | REG_BLOCK_SIZE, |
669 | DMA_PREP_INTERRUPT); | 669 | 0); |
670 | if (!tx) { | 670 | if (!tx) { |
671 | dev_err(priv->dev, "unable to prep SYS-FPGA DMA\n"); | 671 | dev_err(priv->dev, "unable to prep SYS-FPGA DMA\n"); |
672 | return -ENOMEM; | 672 | return -ENOMEM; |
diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig index 701edf658970..c9e695ea7c9a 100644 --- a/drivers/misc/eeprom/Kconfig +++ b/drivers/misc/eeprom/Kconfig | |||
@@ -50,7 +50,7 @@ config EEPROM_LEGACY | |||
50 | 50 | ||
51 | config EEPROM_MAX6875 | 51 | config EEPROM_MAX6875 |
52 | tristate "Maxim MAX6874/5 power supply supervisor" | 52 | tristate "Maxim MAX6874/5 power supply supervisor" |
53 | depends on I2C && EXPERIMENTAL | 53 | depends on I2C |
54 | help | 54 | help |
55 | If you say yes here you get read-only support for the user EEPROM of | 55 | If you say yes here you get read-only support for the user EEPROM of |
56 | the Maxim MAX6874/5 EEPROM-programmable, quad power-supply | 56 | the Maxim MAX6874/5 EEPROM-programmable, quad power-supply |
diff --git a/drivers/misc/eeprom/at25.c b/drivers/misc/eeprom/at25.c index 25003d6ceb56..4ed93dd54116 100644 --- a/drivers/misc/eeprom/at25.c +++ b/drivers/misc/eeprom/at25.c | |||
@@ -302,6 +302,61 @@ static ssize_t at25_mem_write(struct memory_accessor *mem, const char *buf, | |||
302 | 302 | ||
303 | /*-------------------------------------------------------------------------*/ | 303 | /*-------------------------------------------------------------------------*/ |
304 | 304 | ||
305 | static int at25_np_to_chip(struct device *dev, | ||
306 | struct device_node *np, | ||
307 | struct spi_eeprom *chip) | ||
308 | { | ||
309 | u32 val; | ||
310 | |||
311 | memset(chip, 0, sizeof(*chip)); | ||
312 | strncpy(chip->name, np->name, sizeof(chip->name)); | ||
313 | |||
314 | if (of_property_read_u32(np, "size", &val) == 0 || | ||
315 | of_property_read_u32(np, "at25,byte-len", &val) == 0) { | ||
316 | chip->byte_len = val; | ||
317 | } else { | ||
318 | dev_err(dev, "Error: missing \"size\" property\n"); | ||
319 | return -ENODEV; | ||
320 | } | ||
321 | |||
322 | if (of_property_read_u32(np, "pagesize", &val) == 0 || | ||
323 | of_property_read_u32(np, "at25,page-size", &val) == 0) { | ||
324 | chip->page_size = (u16)val; | ||
325 | } else { | ||
326 | dev_err(dev, "Error: missing \"pagesize\" property\n"); | ||
327 | return -ENODEV; | ||
328 | } | ||
329 | |||
330 | if (of_property_read_u32(np, "at25,addr-mode", &val) == 0) { | ||
331 | chip->flags = (u16)val; | ||
332 | } else { | ||
333 | if (of_property_read_u32(np, "address-width", &val)) { | ||
334 | dev_err(dev, | ||
335 | "Error: missing \"address-width\" property\n"); | ||
336 | return -ENODEV; | ||
337 | } | ||
338 | switch (val) { | ||
339 | case 8: | ||
340 | chip->flags |= EE_ADDR1; | ||
341 | break; | ||
342 | case 16: | ||
343 | chip->flags |= EE_ADDR2; | ||
344 | break; | ||
345 | case 24: | ||
346 | chip->flags |= EE_ADDR3; | ||
347 | break; | ||
348 | default: | ||
349 | dev_err(dev, | ||
350 | "Error: bad \"address-width\" property: %u\n", | ||
351 | val); | ||
352 | return -ENODEV; | ||
353 | } | ||
354 | if (of_find_property(np, "read-only", NULL)) | ||
355 | chip->flags |= EE_READONLY; | ||
356 | } | ||
357 | return 0; | ||
358 | } | ||
359 | |||
305 | static int at25_probe(struct spi_device *spi) | 360 | static int at25_probe(struct spi_device *spi) |
306 | { | 361 | { |
307 | struct at25_data *at25 = NULL; | 362 | struct at25_data *at25 = NULL; |
@@ -314,33 +369,11 @@ static int at25_probe(struct spi_device *spi) | |||
314 | /* Chip description */ | 369 | /* Chip description */ |
315 | if (!spi->dev.platform_data) { | 370 | if (!spi->dev.platform_data) { |
316 | if (np) { | 371 | if (np) { |
317 | u32 val; | 372 | err = at25_np_to_chip(&spi->dev, np, &chip); |
318 | 373 | if (err) | |
319 | memset(&chip, 0, sizeof(chip)); | ||
320 | strncpy(chip.name, np->name, 10); | ||
321 | |||
322 | err = of_property_read_u32(np, "at25,byte-len", &val); | ||
323 | if (err) { | ||
324 | dev_dbg(&spi->dev, "invalid chip dt description\n"); | ||
325 | goto fail; | ||
326 | } | ||
327 | chip.byte_len = val; | ||
328 | |||
329 | err = of_property_read_u32(np, "at25,addr-mode", &val); | ||
330 | if (err) { | ||
331 | dev_dbg(&spi->dev, "invalid chip dt description\n"); | ||
332 | goto fail; | ||
333 | } | ||
334 | chip.flags = (u16)val; | ||
335 | |||
336 | err = of_property_read_u32(np, "at25,page-size", &val); | ||
337 | if (err) { | ||
338 | dev_dbg(&spi->dev, "invalid chip dt description\n"); | ||
339 | goto fail; | 374 | goto fail; |
340 | } | ||
341 | chip.page_size = (u16)val; | ||
342 | } else { | 375 | } else { |
343 | dev_dbg(&spi->dev, "no chip description\n"); | 376 | dev_err(&spi->dev, "Error: no chip description\n"); |
344 | err = -ENODEV; | 377 | err = -ENODEV; |
345 | goto fail; | 378 | goto fail; |
346 | } | 379 | } |
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c index 6df0da4085e3..12ccdf94e4fa 100644 --- a/drivers/misc/hpilo.c +++ b/drivers/misc/hpilo.c | |||
@@ -736,7 +736,14 @@ static void ilo_remove(struct pci_dev *pdev) | |||
736 | free_irq(pdev->irq, ilo_hw); | 736 | free_irq(pdev->irq, ilo_hw); |
737 | ilo_unmap_device(pdev, ilo_hw); | 737 | ilo_unmap_device(pdev, ilo_hw); |
738 | pci_release_regions(pdev); | 738 | pci_release_regions(pdev); |
739 | pci_disable_device(pdev); | 739 | /* |
740 | * pci_disable_device(pdev) used to be here. But this PCI device has | ||
741 | * two functions with interrupt lines connected to a single pin. The | ||
742 | * other one is a USB host controller. So when we disable the PIN here | ||
743 | * e.g. by rmmod hpilo, the controller stops working. It is because | ||
744 | * the interrupt link is disabled in ACPI since it is not refcounted | ||
745 | * yet. See acpi_pci_link_free_irq called from acpi_pci_irq_disable. | ||
746 | */ | ||
740 | kfree(ilo_hw); | 747 | kfree(ilo_hw); |
741 | ilo_hwdev[(minor / max_ccb)] = 0; | 748 | ilo_hwdev[(minor / max_ccb)] = 0; |
742 | } | 749 | } |
@@ -826,7 +833,7 @@ unmap: | |||
826 | free_regions: | 833 | free_regions: |
827 | pci_release_regions(pdev); | 834 | pci_release_regions(pdev); |
828 | disable: | 835 | disable: |
829 | pci_disable_device(pdev); | 836 | /* pci_disable_device(pdev); see comment in ilo_remove */ |
830 | free: | 837 | free: |
831 | kfree(ilo_hw); | 838 | kfree(ilo_hw); |
832 | out: | 839 | out: |
diff --git a/drivers/misc/ibmasm/uart.c b/drivers/misc/ibmasm/uart.c index 1dcb9ae1905a..01e2b0d7e590 100644 --- a/drivers/misc/ibmasm/uart.c +++ b/drivers/misc/ibmasm/uart.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | void ibmasm_register_uart(struct service_processor *sp) | 34 | void ibmasm_register_uart(struct service_processor *sp) |
35 | { | 35 | { |
36 | struct uart_port uport; | 36 | struct uart_8250_port uart; |
37 | void __iomem *iomem_base; | 37 | void __iomem *iomem_base; |
38 | 38 | ||
39 | iomem_base = sp->base_address + SCOUT_COM_B_BASE; | 39 | iomem_base = sp->base_address + SCOUT_COM_B_BASE; |
@@ -47,14 +47,14 @@ void ibmasm_register_uart(struct service_processor *sp) | |||
47 | return; | 47 | return; |
48 | } | 48 | } |
49 | 49 | ||
50 | memset(&uport, 0, sizeof(struct uart_port)); | 50 | memset(&uart, 0, sizeof(uart)); |
51 | uport.irq = sp->irq; | 51 | uart.port.irq = sp->irq; |
52 | uport.uartclk = 3686400; | 52 | uart.port.uartclk = 3686400; |
53 | uport.flags = UPF_SHARE_IRQ; | 53 | uart.port.flags = UPF_SHARE_IRQ; |
54 | uport.iotype = UPIO_MEM; | 54 | uart.port.iotype = UPIO_MEM; |
55 | uport.membase = iomem_base; | 55 | uart.port.membase = iomem_base; |
56 | 56 | ||
57 | sp->serial_line = serial8250_register_port(&uport); | 57 | sp->serial_line = serial8250_register_8250_port(&uart); |
58 | if (sp->serial_line < 0) { | 58 | if (sp->serial_line < 0) { |
59 | dev_err(sp->dev, "Failed to register serial port\n"); | 59 | dev_err(sp->dev, "Failed to register serial port\n"); |
60 | return; | 60 | return; |
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c index a981e2a42f92..4a87e5c0a320 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d.c +++ b/drivers/misc/lis3lv02d/lis3lv02d.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/miscdevice.h> | 39 | #include <linux/miscdevice.h> |
40 | #include <linux/pm_runtime.h> | 40 | #include <linux/pm_runtime.h> |
41 | #include <linux/atomic.h> | 41 | #include <linux/atomic.h> |
42 | #include <linux/of_device.h> | ||
42 | #include "lis3lv02d.h" | 43 | #include "lis3lv02d.h" |
43 | 44 | ||
44 | #define DRIVER_NAME "lis3lv02d" | 45 | #define DRIVER_NAME "lis3lv02d" |
@@ -80,6 +81,15 @@ | |||
80 | #define LIS3_SENSITIVITY_12B ((LIS3_ACCURACY * 1000) / 1024) | 81 | #define LIS3_SENSITIVITY_12B ((LIS3_ACCURACY * 1000) / 1024) |
81 | #define LIS3_SENSITIVITY_8B (18 * LIS3_ACCURACY) | 82 | #define LIS3_SENSITIVITY_8B (18 * LIS3_ACCURACY) |
82 | 83 | ||
84 | /* | ||
85 | * LIS331DLH spec says 1LSBs corresponds 4G/4096 -> 1LSB is 1000/1024 mG. | ||
86 | * Below macros defines sensitivity values for +/-2G. Dataout bits for | ||
87 | * +/-2G range is 12 bits so 4 bits adjustment must be done to get 12bit | ||
88 | * data from 16bit value. Currently this driver supports only 2G range. | ||
89 | */ | ||
90 | #define LIS3DLH_SENSITIVITY_2G ((LIS3_ACCURACY * 1000) / 1024) | ||
91 | #define SHIFT_ADJ_2G 4 | ||
92 | |||
83 | #define LIS3_DEFAULT_FUZZ_12B 3 | 93 | #define LIS3_DEFAULT_FUZZ_12B 3 |
84 | #define LIS3_DEFAULT_FLAT_12B 3 | 94 | #define LIS3_DEFAULT_FLAT_12B 3 |
85 | #define LIS3_DEFAULT_FUZZ_8B 1 | 95 | #define LIS3_DEFAULT_FUZZ_8B 1 |
@@ -135,6 +145,19 @@ static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg) | |||
135 | return (s16)((hi << 8) | lo); | 145 | return (s16)((hi << 8) | lo); |
136 | } | 146 | } |
137 | 147 | ||
148 | /* 12bits for 2G range, 13 bits for 4G range and 14 bits for 8G range */ | ||
149 | static s16 lis331dlh_read_data(struct lis3lv02d *lis3, int reg) | ||
150 | { | ||
151 | u8 lo, hi; | ||
152 | int v; | ||
153 | |||
154 | lis3->read(lis3, reg - 1, &lo); | ||
155 | lis3->read(lis3, reg, &hi); | ||
156 | v = (int) ((hi << 8) | lo); | ||
157 | |||
158 | return (s16) v >> lis3->shift_adj; | ||
159 | } | ||
160 | |||
138 | /** | 161 | /** |
139 | * lis3lv02d_get_axis - For the given axis, give the value converted | 162 | * lis3lv02d_get_axis - For the given axis, give the value converted |
140 | * @axis: 1,2,3 - can also be negative | 163 | * @axis: 1,2,3 - can also be negative |
@@ -195,6 +218,7 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) | |||
195 | static int lis3_12_rates[4] = {40, 160, 640, 2560}; | 218 | static int lis3_12_rates[4] = {40, 160, 640, 2560}; |
196 | static int lis3_8_rates[2] = {100, 400}; | 219 | static int lis3_8_rates[2] = {100, 400}; |
197 | static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; | 220 | static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; |
221 | static int lis3_3dlh_rates[4] = {50, 100, 400, 1000}; | ||
198 | 222 | ||
199 | /* ODR is Output Data Rate */ | 223 | /* ODR is Output Data Rate */ |
200 | static int lis3lv02d_get_odr(struct lis3lv02d *lis3) | 224 | static int lis3lv02d_get_odr(struct lis3lv02d *lis3) |
@@ -267,7 +291,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) | |||
267 | (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); | 291 | (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); |
268 | } | 292 | } |
269 | 293 | ||
270 | if (lis3->whoami == WAI_3DC) { | 294 | if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) { |
271 | ctlreg = CTRL_REG4; | 295 | ctlreg = CTRL_REG4; |
272 | selftest = CTRL4_ST0; | 296 | selftest = CTRL4_ST0; |
273 | } else { | 297 | } else { |
@@ -398,9 +422,17 @@ int lis3lv02d_poweron(struct lis3lv02d *lis3) | |||
398 | lis3->read(lis3, CTRL_REG2, ®); | 422 | lis3->read(lis3, CTRL_REG2, ®); |
399 | if (lis3->whoami == WAI_12B) | 423 | if (lis3->whoami == WAI_12B) |
400 | reg |= CTRL2_BDU | CTRL2_BOOT; | 424 | reg |= CTRL2_BDU | CTRL2_BOOT; |
425 | else if (lis3->whoami == WAI_3DLH) | ||
426 | reg |= CTRL2_BOOT_3DLH; | ||
401 | else | 427 | else |
402 | reg |= CTRL2_BOOT_8B; | 428 | reg |= CTRL2_BOOT_8B; |
403 | lis3->write(lis3, CTRL_REG2, reg); | 429 | lis3->write(lis3, CTRL_REG2, reg); |
430 | |||
431 | if (lis3->whoami == WAI_3DLH) { | ||
432 | lis3->read(lis3, CTRL_REG4, ®); | ||
433 | reg |= CTRL4_BDU; | ||
434 | lis3->write(lis3, CTRL_REG4, reg); | ||
435 | } | ||
404 | } | 436 | } |
405 | 437 | ||
406 | err = lis3lv02d_get_pwron_wait(lis3); | 438 | err = lis3lv02d_get_pwron_wait(lis3); |
@@ -912,6 +944,154 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *lis3, | |||
912 | } | 944 | } |
913 | } | 945 | } |
914 | 946 | ||
947 | #ifdef CONFIG_OF | ||
948 | int lis3lv02d_init_dt(struct lis3lv02d *lis3) | ||
949 | { | ||
950 | struct lis3lv02d_platform_data *pdata; | ||
951 | struct device_node *np = lis3->of_node; | ||
952 | u32 val; | ||
953 | |||
954 | if (!lis3->of_node) | ||
955 | return 0; | ||
956 | |||
957 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | ||
958 | if (!pdata) | ||
959 | return -ENOMEM; | ||
960 | |||
961 | if (of_get_property(np, "st,click-single-x", NULL)) | ||
962 | pdata->click_flags |= LIS3_CLICK_SINGLE_X; | ||
963 | if (of_get_property(np, "st,click-double-x", NULL)) | ||
964 | pdata->click_flags |= LIS3_CLICK_DOUBLE_X; | ||
965 | |||
966 | if (of_get_property(np, "st,click-single-y", NULL)) | ||
967 | pdata->click_flags |= LIS3_CLICK_SINGLE_Y; | ||
968 | if (of_get_property(np, "st,click-double-y", NULL)) | ||
969 | pdata->click_flags |= LIS3_CLICK_DOUBLE_Y; | ||
970 | |||
971 | if (of_get_property(np, "st,click-single-z", NULL)) | ||
972 | pdata->click_flags |= LIS3_CLICK_SINGLE_Z; | ||
973 | if (of_get_property(np, "st,click-double-z", NULL)) | ||
974 | pdata->click_flags |= LIS3_CLICK_DOUBLE_Z; | ||
975 | |||
976 | if (!of_property_read_u32(np, "st,click-threshold-x", &val)) | ||
977 | pdata->click_thresh_x = val; | ||
978 | if (!of_property_read_u32(np, "st,click-threshold-y", &val)) | ||
979 | pdata->click_thresh_y = val; | ||
980 | if (!of_property_read_u32(np, "st,click-threshold-z", &val)) | ||
981 | pdata->click_thresh_z = val; | ||
982 | |||
983 | if (!of_property_read_u32(np, "st,click-time-limit", &val)) | ||
984 | pdata->click_time_limit = val; | ||
985 | if (!of_property_read_u32(np, "st,click-latency", &val)) | ||
986 | pdata->click_latency = val; | ||
987 | if (!of_property_read_u32(np, "st,click-window", &val)) | ||
988 | pdata->click_window = val; | ||
989 | |||
990 | if (of_get_property(np, "st,irq1-disable", NULL)) | ||
991 | pdata->irq_cfg |= LIS3_IRQ1_DISABLE; | ||
992 | if (of_get_property(np, "st,irq1-ff-wu-1", NULL)) | ||
993 | pdata->irq_cfg |= LIS3_IRQ1_FF_WU_1; | ||
994 | if (of_get_property(np, "st,irq1-ff-wu-2", NULL)) | ||
995 | pdata->irq_cfg |= LIS3_IRQ1_FF_WU_2; | ||
996 | if (of_get_property(np, "st,irq1-data-ready", NULL)) | ||
997 | pdata->irq_cfg |= LIS3_IRQ1_DATA_READY; | ||
998 | if (of_get_property(np, "st,irq1-click", NULL)) | ||
999 | pdata->irq_cfg |= LIS3_IRQ1_CLICK; | ||
1000 | |||
1001 | if (of_get_property(np, "st,irq2-disable", NULL)) | ||
1002 | pdata->irq_cfg |= LIS3_IRQ2_DISABLE; | ||
1003 | if (of_get_property(np, "st,irq2-ff-wu-1", NULL)) | ||
1004 | pdata->irq_cfg |= LIS3_IRQ2_FF_WU_1; | ||
1005 | if (of_get_property(np, "st,irq2-ff-wu-2", NULL)) | ||
1006 | pdata->irq_cfg |= LIS3_IRQ2_FF_WU_2; | ||
1007 | if (of_get_property(np, "st,irq2-data-ready", NULL)) | ||
1008 | pdata->irq_cfg |= LIS3_IRQ2_DATA_READY; | ||
1009 | if (of_get_property(np, "st,irq2-click", NULL)) | ||
1010 | pdata->irq_cfg |= LIS3_IRQ2_CLICK; | ||
1011 | |||
1012 | if (of_get_property(np, "st,irq-open-drain", NULL)) | ||
1013 | pdata->irq_cfg |= LIS3_IRQ_OPEN_DRAIN; | ||
1014 | if (of_get_property(np, "st,irq-active-low", NULL)) | ||
1015 | pdata->irq_cfg |= LIS3_IRQ_ACTIVE_LOW; | ||
1016 | |||
1017 | if (!of_property_read_u32(np, "st,wu-duration-1", &val)) | ||
1018 | pdata->duration1 = val; | ||
1019 | if (!of_property_read_u32(np, "st,wu-duration-2", &val)) | ||
1020 | pdata->duration2 = val; | ||
1021 | |||
1022 | if (of_get_property(np, "st,wakeup-x-lo", NULL)) | ||
1023 | pdata->wakeup_flags |= LIS3_WAKEUP_X_LO; | ||
1024 | if (of_get_property(np, "st,wakeup-x-hi", NULL)) | ||
1025 | pdata->wakeup_flags |= LIS3_WAKEUP_X_HI; | ||
1026 | if (of_get_property(np, "st,wakeup-y-lo", NULL)) | ||
1027 | pdata->wakeup_flags |= LIS3_WAKEUP_Y_LO; | ||
1028 | if (of_get_property(np, "st,wakeup-y-hi", NULL)) | ||
1029 | pdata->wakeup_flags |= LIS3_WAKEUP_Y_HI; | ||
1030 | if (of_get_property(np, "st,wakeup-z-lo", NULL)) | ||
1031 | pdata->wakeup_flags |= LIS3_WAKEUP_Z_LO; | ||
1032 | if (of_get_property(np, "st,wakeup-z-hi", NULL)) | ||
1033 | pdata->wakeup_flags |= LIS3_WAKEUP_Z_HI; | ||
1034 | |||
1035 | if (!of_property_read_u32(np, "st,highpass-cutoff-hz", &val)) { | ||
1036 | switch (val) { | ||
1037 | case 1: | ||
1038 | pdata->hipass_ctrl = LIS3_HIPASS_CUTFF_1HZ; | ||
1039 | break; | ||
1040 | case 2: | ||
1041 | pdata->hipass_ctrl = LIS3_HIPASS_CUTFF_2HZ; | ||
1042 | break; | ||
1043 | case 4: | ||
1044 | pdata->hipass_ctrl = LIS3_HIPASS_CUTFF_4HZ; | ||
1045 | break; | ||
1046 | case 8: | ||
1047 | pdata->hipass_ctrl = LIS3_HIPASS_CUTFF_8HZ; | ||
1048 | break; | ||
1049 | } | ||
1050 | } | ||
1051 | |||
1052 | if (of_get_property(np, "st,hipass1-disable", NULL)) | ||
1053 | pdata->hipass_ctrl |= LIS3_HIPASS1_DISABLE; | ||
1054 | if (of_get_property(np, "st,hipass2-disable", NULL)) | ||
1055 | pdata->hipass_ctrl |= LIS3_HIPASS2_DISABLE; | ||
1056 | |||
1057 | if (of_get_property(np, "st,axis-x", &val)) | ||
1058 | pdata->axis_x = val; | ||
1059 | if (of_get_property(np, "st,axis-y", &val)) | ||
1060 | pdata->axis_y = val; | ||
1061 | if (of_get_property(np, "st,axis-z", &val)) | ||
1062 | pdata->axis_z = val; | ||
1063 | |||
1064 | if (of_get_property(np, "st,default-rate", NULL)) | ||
1065 | pdata->default_rate = val; | ||
1066 | |||
1067 | if (of_get_property(np, "st,min-limit-x", &val)) | ||
1068 | pdata->st_min_limits[0] = val; | ||
1069 | if (of_get_property(np, "st,min-limit-y", &val)) | ||
1070 | pdata->st_min_limits[1] = val; | ||
1071 | if (of_get_property(np, "st,min-limit-z", &val)) | ||
1072 | pdata->st_min_limits[2] = val; | ||
1073 | |||
1074 | if (of_get_property(np, "st,max-limit-x", &val)) | ||
1075 | pdata->st_max_limits[0] = val; | ||
1076 | if (of_get_property(np, "st,max-limit-y", &val)) | ||
1077 | pdata->st_max_limits[1] = val; | ||
1078 | if (of_get_property(np, "st,max-limit-z", &val)) | ||
1079 | pdata->st_max_limits[2] = val; | ||
1080 | |||
1081 | |||
1082 | lis3->pdata = pdata; | ||
1083 | |||
1084 | return 0; | ||
1085 | } | ||
1086 | |||
1087 | #else | ||
1088 | int lis3lv02d_init_dt(struct lis3lv02d *lis3) | ||
1089 | { | ||
1090 | return 0; | ||
1091 | } | ||
1092 | #endif | ||
1093 | EXPORT_SYMBOL_GPL(lis3lv02d_init_dt); | ||
1094 | |||
915 | /* | 1095 | /* |
916 | * Initialise the accelerometer and the various subsystems. | 1096 | * Initialise the accelerometer and the various subsystems. |
917 | * Should be rather independent of the bus system. | 1097 | * Should be rather independent of the bus system. |
@@ -956,6 +1136,16 @@ int lis3lv02d_init_device(struct lis3lv02d *lis3) | |||
956 | lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; | 1136 | lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; |
957 | lis3->scale = LIS3_SENSITIVITY_8B; | 1137 | lis3->scale = LIS3_SENSITIVITY_8B; |
958 | break; | 1138 | break; |
1139 | case WAI_3DLH: | ||
1140 | pr_info("16 bits lis331dlh sensor found\n"); | ||
1141 | lis3->read_data = lis331dlh_read_data; | ||
1142 | lis3->mdps_max_val = 2048; /* 12 bits for 2G */ | ||
1143 | lis3->shift_adj = SHIFT_ADJ_2G; | ||
1144 | lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | ||
1145 | lis3->odrs = lis3_3dlh_rates; | ||
1146 | lis3->odr_mask = CTRL1_DR0 | CTRL1_DR1; | ||
1147 | lis3->scale = LIS3DLH_SENSITIVITY_2G; | ||
1148 | break; | ||
959 | default: | 1149 | default: |
960 | pr_err("unknown sensor type 0x%X\n", lis3->whoami); | 1150 | pr_err("unknown sensor type 0x%X\n", lis3->whoami); |
961 | return -EINVAL; | 1151 | return -EINVAL; |
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h index 2b1482ad3f16..c439c827eea8 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d.h +++ b/drivers/misc/lis3lv02d/lis3lv02d.h | |||
@@ -26,12 +26,12 @@ | |||
26 | /* | 26 | /* |
27 | * This driver tries to support the "digital" accelerometer chips from | 27 | * This driver tries to support the "digital" accelerometer chips from |
28 | * STMicroelectronics such as LIS3LV02DL, LIS302DL, LIS3L02DQ, LIS331DL, | 28 | * STMicroelectronics such as LIS3LV02DL, LIS302DL, LIS3L02DQ, LIS331DL, |
29 | * LIS35DE, or LIS202DL. They are very similar in terms of programming, with | 29 | * LIS331DLH, LIS35DE, or LIS202DL. They are very similar in terms of |
30 | * almost the same registers. In addition to differing on physical properties, | 30 | * programming, with almost the same registers. In addition to differing |
31 | * they differ on the number of axes (2/3), precision (8/12 bits), and special | 31 | * on physical properties, they differ on the number of axes (2/3), |
32 | * features (freefall detection, click...). Unfortunately, not all the | 32 | * precision (8/12 bits), and special features (freefall detection, |
33 | * differences can be probed via a register. | 33 | * click...). Unfortunately, not all the differences can be probed via |
34 | * They can be connected either via I²C or SPI. | 34 | * a register. They can be connected either via I²C or SPI. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/lis3lv02d.h> | 37 | #include <linux/lis3lv02d.h> |
@@ -96,12 +96,22 @@ enum lis3lv02d_reg { | |||
96 | }; | 96 | }; |
97 | 97 | ||
98 | enum lis3_who_am_i { | 98 | enum lis3_who_am_i { |
99 | WAI_3DLH = 0x32, /* 16 bits: LIS331DLH */ | ||
99 | WAI_3DC = 0x33, /* 8 bits: LIS3DC, HP3DC */ | 100 | WAI_3DC = 0x33, /* 8 bits: LIS3DC, HP3DC */ |
100 | WAI_12B = 0x3A, /* 12 bits: LIS3LV02D[LQ]... */ | 101 | WAI_12B = 0x3A, /* 12 bits: LIS3LV02D[LQ]... */ |
101 | WAI_8B = 0x3B, /* 8 bits: LIS[23]02D[LQ]... */ | 102 | WAI_8B = 0x3B, /* 8 bits: LIS[23]02D[LQ]... */ |
102 | WAI_6B = 0x52, /* 6 bits: LIS331DLF - not supported */ | 103 | WAI_6B = 0x52, /* 6 bits: LIS331DLF - not supported */ |
103 | }; | 104 | }; |
104 | 105 | ||
106 | enum lis3_type { | ||
107 | LIS3LV02D, | ||
108 | LIS3DC, | ||
109 | HP3DC, | ||
110 | LIS2302D, | ||
111 | LIS331DLF, | ||
112 | LIS331DLH, | ||
113 | }; | ||
114 | |||
105 | enum lis3lv02d_ctrl1_12b { | 115 | enum lis3lv02d_ctrl1_12b { |
106 | CTRL1_Xen = 0x01, | 116 | CTRL1_Xen = 0x01, |
107 | CTRL1_Yen = 0x02, | 117 | CTRL1_Yen = 0x02, |
@@ -129,6 +139,27 @@ enum lis3lv02d_ctrl1_3dc { | |||
129 | CTRL1_ODR3 = 0x80, | 139 | CTRL1_ODR3 = 0x80, |
130 | }; | 140 | }; |
131 | 141 | ||
142 | enum lis331dlh_ctrl1 { | ||
143 | CTRL1_DR0 = 0x08, | ||
144 | CTRL1_DR1 = 0x10, | ||
145 | CTRL1_PM0 = 0x20, | ||
146 | CTRL1_PM1 = 0x40, | ||
147 | CTRL1_PM2 = 0x80, | ||
148 | }; | ||
149 | |||
150 | enum lis331dlh_ctrl2 { | ||
151 | CTRL2_HPEN1 = 0x04, | ||
152 | CTRL2_HPEN2 = 0x08, | ||
153 | CTRL2_FDS_3DLH = 0x10, | ||
154 | CTRL2_BOOT_3DLH = 0x80, | ||
155 | }; | ||
156 | |||
157 | enum lis331dlh_ctrl4 { | ||
158 | CTRL4_STSIGN = 0x08, | ||
159 | CTRL4_BLE = 0x40, | ||
160 | CTRL4_BDU = 0x80, | ||
161 | }; | ||
162 | |||
132 | enum lis3lv02d_ctrl2 { | 163 | enum lis3lv02d_ctrl2 { |
133 | CTRL2_DAS = 0x01, | 164 | CTRL2_DAS = 0x01, |
134 | CTRL2_SIM = 0x02, | 165 | CTRL2_SIM = 0x02, |
@@ -279,9 +310,14 @@ struct lis3lv02d { | |||
279 | int data_ready_count[2]; | 310 | int data_ready_count[2]; |
280 | atomic_t wake_thread; | 311 | atomic_t wake_thread; |
281 | unsigned char irq_cfg; | 312 | unsigned char irq_cfg; |
313 | unsigned int shift_adj; | ||
282 | 314 | ||
283 | struct lis3lv02d_platform_data *pdata; /* for passing board config */ | 315 | struct lis3lv02d_platform_data *pdata; /* for passing board config */ |
284 | struct mutex mutex; /* Serialize poll and selftest */ | 316 | struct mutex mutex; /* Serialize poll and selftest */ |
317 | |||
318 | #ifdef CONFIG_OF | ||
319 | struct device_node *of_node; | ||
320 | #endif | ||
285 | }; | 321 | }; |
286 | 322 | ||
287 | int lis3lv02d_init_device(struct lis3lv02d *lis3); | 323 | int lis3lv02d_init_device(struct lis3lv02d *lis3); |
@@ -290,5 +326,6 @@ void lis3lv02d_joystick_disable(struct lis3lv02d *lis3); | |||
290 | void lis3lv02d_poweroff(struct lis3lv02d *lis3); | 326 | void lis3lv02d_poweroff(struct lis3lv02d *lis3); |
291 | int lis3lv02d_poweron(struct lis3lv02d *lis3); | 327 | int lis3lv02d_poweron(struct lis3lv02d *lis3); |
292 | int lis3lv02d_remove_fs(struct lis3lv02d *lis3); | 328 | int lis3lv02d_remove_fs(struct lis3lv02d *lis3); |
329 | int lis3lv02d_init_dt(struct lis3lv02d *lis3); | ||
293 | 330 | ||
294 | extern struct lis3lv02d lis3_dev; | 331 | extern struct lis3lv02d lis3_dev; |
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c index e8c0019da97a..60ec8689d6e3 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c | |||
@@ -31,6 +31,10 @@ | |||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/pm_runtime.h> | 32 | #include <linux/pm_runtime.h> |
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/of.h> | ||
35 | #include <linux/of_platform.h> | ||
36 | #include <linux/of_device.h> | ||
37 | |||
34 | #include "lis3lv02d.h" | 38 | #include "lis3lv02d.h" |
35 | 39 | ||
36 | #define DRV_NAME "lis3lv02d_i2c" | 40 | #define DRV_NAME "lis3lv02d_i2c" |
@@ -90,7 +94,11 @@ static int lis3_i2c_init(struct lis3lv02d *lis3) | |||
90 | if (ret < 0) | 94 | if (ret < 0) |
91 | return ret; | 95 | return ret; |
92 | 96 | ||
93 | reg |= CTRL1_PD0 | CTRL1_Xen | CTRL1_Yen | CTRL1_Zen; | 97 | if (lis3->whoami == WAI_3DLH) |
98 | reg |= CTRL1_PM0 | CTRL1_Xen | CTRL1_Yen | CTRL1_Zen; | ||
99 | else | ||
100 | reg |= CTRL1_PD0 | CTRL1_Xen | CTRL1_Yen | CTRL1_Zen; | ||
101 | |||
94 | return lis3->write(lis3, CTRL_REG1, reg); | 102 | return lis3->write(lis3, CTRL_REG1, reg); |
95 | } | 103 | } |
96 | 104 | ||
@@ -98,12 +106,30 @@ static int lis3_i2c_init(struct lis3lv02d *lis3) | |||
98 | static union axis_conversion lis3lv02d_axis_map = | 106 | static union axis_conversion lis3lv02d_axis_map = |
99 | { .as_array = { LIS3_DEV_X, LIS3_DEV_Y, LIS3_DEV_Z } }; | 107 | { .as_array = { LIS3_DEV_X, LIS3_DEV_Y, LIS3_DEV_Z } }; |
100 | 108 | ||
109 | #ifdef CONFIG_OF | ||
110 | static struct of_device_id lis3lv02d_i2c_dt_ids[] = { | ||
111 | { .compatible = "st,lis3lv02d" }, | ||
112 | {} | ||
113 | }; | ||
114 | MODULE_DEVICE_TABLE(of, lis3lv02d_i2c_dt_ids); | ||
115 | #endif | ||
116 | |||
101 | static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, | 117 | static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, |
102 | const struct i2c_device_id *id) | 118 | const struct i2c_device_id *id) |
103 | { | 119 | { |
104 | int ret = 0; | 120 | int ret = 0; |
105 | struct lis3lv02d_platform_data *pdata = client->dev.platform_data; | 121 | struct lis3lv02d_platform_data *pdata = client->dev.platform_data; |
106 | 122 | ||
123 | #ifdef CONFIG_OF | ||
124 | if (of_match_device(lis3lv02d_i2c_dt_ids, &client->dev)) { | ||
125 | lis3_dev.of_node = client->dev.of_node; | ||
126 | ret = lis3lv02d_init_dt(&lis3_dev); | ||
127 | if (ret) | ||
128 | return ret; | ||
129 | pdata = lis3_dev.pdata; | ||
130 | } | ||
131 | #endif | ||
132 | |||
107 | if (pdata) { | 133 | if (pdata) { |
108 | if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && | 134 | if ((pdata->driver_features & LIS3_USE_BLOCK_READ) && |
109 | (i2c_check_functionality(client->adapter, | 135 | (i2c_check_functionality(client->adapter, |
@@ -231,7 +257,8 @@ static int lis3_i2c_runtime_resume(struct device *dev) | |||
231 | #endif /* CONFIG_PM_RUNTIME */ | 257 | #endif /* CONFIG_PM_RUNTIME */ |
232 | 258 | ||
233 | static const struct i2c_device_id lis3lv02d_id[] = { | 259 | static const struct i2c_device_id lis3lv02d_id[] = { |
234 | {"lis3lv02d", 0 }, | 260 | {"lis3lv02d", LIS3LV02D}, |
261 | {"lis331dlh", LIS331DLH}, | ||
235 | {} | 262 | {} |
236 | }; | 263 | }; |
237 | 264 | ||
@@ -250,6 +277,7 @@ static struct i2c_driver lis3lv02d_i2c_driver = { | |||
250 | .name = DRV_NAME, | 277 | .name = DRV_NAME, |
251 | .owner = THIS_MODULE, | 278 | .owner = THIS_MODULE, |
252 | .pm = &lis3_pm_ops, | 279 | .pm = &lis3_pm_ops, |
280 | .of_match_table = of_match_ptr(lis3lv02d_i2c_dt_ids), | ||
253 | }, | 281 | }, |
254 | .probe = lis3lv02d_i2c_probe, | 282 | .probe = lis3lv02d_i2c_probe, |
255 | .remove = __devexit_p(lis3lv02d_i2c_remove), | 283 | .remove = __devexit_p(lis3lv02d_i2c_remove), |
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_spi.c b/drivers/misc/lis3lv02d/lis3lv02d_spi.c index 80880e984b4f..ccb6475fa059 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d_spi.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_spi.c | |||
@@ -17,6 +17,9 @@ | |||
17 | #include <linux/workqueue.h> | 17 | #include <linux/workqueue.h> |
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/pm.h> | 19 | #include <linux/pm.h> |
20 | #include <linux/of.h> | ||
21 | #include <linux/of_platform.h> | ||
22 | #include <linux/of_device.h> | ||
20 | 23 | ||
21 | #include "lis3lv02d.h" | 24 | #include "lis3lv02d.h" |
22 | 25 | ||
@@ -58,6 +61,14 @@ static int lis3_spi_init(struct lis3lv02d *lis3) | |||
58 | static union axis_conversion lis3lv02d_axis_normal = | 61 | static union axis_conversion lis3lv02d_axis_normal = |
59 | { .as_array = { 1, 2, 3 } }; | 62 | { .as_array = { 1, 2, 3 } }; |
60 | 63 | ||
64 | #ifdef CONFIG_OF | ||
65 | static struct of_device_id lis302dl_spi_dt_ids[] = { | ||
66 | { .compatible = "st,lis302dl-spi" }, | ||
67 | {} | ||
68 | }; | ||
69 | MODULE_DEVICE_TABLE(of, lis302dl_spi_dt_ids); | ||
70 | #endif | ||
71 | |||
61 | static int __devinit lis302dl_spi_probe(struct spi_device *spi) | 72 | static int __devinit lis302dl_spi_probe(struct spi_device *spi) |
62 | { | 73 | { |
63 | int ret; | 74 | int ret; |
@@ -75,6 +86,15 @@ static int __devinit lis302dl_spi_probe(struct spi_device *spi) | |||
75 | lis3_dev.irq = spi->irq; | 86 | lis3_dev.irq = spi->irq; |
76 | lis3_dev.ac = lis3lv02d_axis_normal; | 87 | lis3_dev.ac = lis3lv02d_axis_normal; |
77 | lis3_dev.pdata = spi->dev.platform_data; | 88 | lis3_dev.pdata = spi->dev.platform_data; |
89 | |||
90 | #ifdef CONFIG_OF | ||
91 | if (of_match_device(lis302dl_spi_dt_ids, &spi->dev)) { | ||
92 | lis3_dev.of_node = spi->dev.of_node; | ||
93 | ret = lis3lv02d_init_dt(&lis3_dev); | ||
94 | if (ret) | ||
95 | return ret; | ||
96 | } | ||
97 | #endif | ||
78 | spi_set_drvdata(spi, &lis3_dev); | 98 | spi_set_drvdata(spi, &lis3_dev); |
79 | 99 | ||
80 | return lis3lv02d_init_device(&lis3_dev); | 100 | return lis3lv02d_init_device(&lis3_dev); |
@@ -121,6 +141,7 @@ static struct spi_driver lis302dl_spi_driver = { | |||
121 | .name = DRV_NAME, | 141 | .name = DRV_NAME, |
122 | .owner = THIS_MODULE, | 142 | .owner = THIS_MODULE, |
123 | .pm = &lis3lv02d_spi_pm, | 143 | .pm = &lis3lv02d_spi_pm, |
144 | .of_match_table = of_match_ptr(lis302dl_spi_dt_ids), | ||
124 | }, | 145 | }, |
125 | .probe = lis302dl_spi_probe, | 146 | .probe = lis302dl_spi_probe, |
126 | .remove = __devexit_p(lis302dl_spi_remove), | 147 | .remove = __devexit_p(lis302dl_spi_remove), |
diff --git a/drivers/misc/mei/Kconfig b/drivers/misc/mei/Kconfig index 47d78a72db2e..5a79ccde2fdf 100644 --- a/drivers/misc/mei/Kconfig +++ b/drivers/misc/mei/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config INTEL_MEI | 1 | config INTEL_MEI |
2 | tristate "Intel Management Engine Interface (Intel MEI)" | 2 | tristate "Intel Management Engine Interface (Intel MEI)" |
3 | depends on X86 && PCI && EXPERIMENTAL && WATCHDOG_CORE | 3 | depends on X86 && PCI && WATCHDOG_CORE |
4 | help | 4 | help |
5 | The Intel Management Engine (Intel ME) provides Manageability, | 5 | The Intel Management Engine (Intel ME) provides Manageability, |
6 | Security and Media services for system containing Intel chipsets. | 6 | Security and Media services for system containing Intel chipsets. |
diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h index 24c4c962819e..9700532f02f6 100644 --- a/drivers/misc/mei/hw.h +++ b/drivers/misc/mei/hw.h | |||
@@ -40,47 +40,48 @@ | |||
40 | /* | 40 | /* |
41 | * MEI device IDs | 41 | * MEI device IDs |
42 | */ | 42 | */ |
43 | #define MEI_DEV_ID_82946GZ 0x2974 /* 82946GZ/GL */ | 43 | #define MEI_DEV_ID_82946GZ 0x2974 /* 82946GZ/GL */ |
44 | #define MEI_DEV_ID_82G35 0x2984 /* 82G35 Express */ | 44 | #define MEI_DEV_ID_82G35 0x2984 /* 82G35 Express */ |
45 | #define MEI_DEV_ID_82Q965 0x2994 /* 82Q963/Q965 */ | 45 | #define MEI_DEV_ID_82Q965 0x2994 /* 82Q963/Q965 */ |
46 | #define MEI_DEV_ID_82G965 0x29A4 /* 82P965/G965 */ | 46 | #define MEI_DEV_ID_82G965 0x29A4 /* 82P965/G965 */ |
47 | 47 | ||
48 | #define MEI_DEV_ID_82GM965 0x2A04 /* Mobile PM965/GM965 */ | 48 | #define MEI_DEV_ID_82GM965 0x2A04 /* Mobile PM965/GM965 */ |
49 | #define MEI_DEV_ID_82GME965 0x2A14 /* Mobile GME965/GLE960 */ | 49 | #define MEI_DEV_ID_82GME965 0x2A14 /* Mobile GME965/GLE960 */ |
50 | 50 | ||
51 | #define MEI_DEV_ID_ICH9_82Q35 0x29B4 /* 82Q35 Express */ | 51 | #define MEI_DEV_ID_ICH9_82Q35 0x29B4 /* 82Q35 Express */ |
52 | #define MEI_DEV_ID_ICH9_82G33 0x29C4 /* 82G33/G31/P35/P31 Express */ | 52 | #define MEI_DEV_ID_ICH9_82G33 0x29C4 /* 82G33/G31/P35/P31 Express */ |
53 | #define MEI_DEV_ID_ICH9_82Q33 0x29D4 /* 82Q33 Express */ | 53 | #define MEI_DEV_ID_ICH9_82Q33 0x29D4 /* 82Q33 Express */ |
54 | #define MEI_DEV_ID_ICH9_82X38 0x29E4 /* 82X38/X48 Express */ | 54 | #define MEI_DEV_ID_ICH9_82X38 0x29E4 /* 82X38/X48 Express */ |
55 | #define MEI_DEV_ID_ICH9_3200 0x29F4 /* 3200/3210 Server */ | 55 | #define MEI_DEV_ID_ICH9_3200 0x29F4 /* 3200/3210 Server */ |
56 | 56 | ||
57 | #define MEI_DEV_ID_ICH9_6 0x28B4 /* Bearlake */ | 57 | #define MEI_DEV_ID_ICH9_6 0x28B4 /* Bearlake */ |
58 | #define MEI_DEV_ID_ICH9_7 0x28C4 /* Bearlake */ | 58 | #define MEI_DEV_ID_ICH9_7 0x28C4 /* Bearlake */ |
59 | #define MEI_DEV_ID_ICH9_8 0x28D4 /* Bearlake */ | 59 | #define MEI_DEV_ID_ICH9_8 0x28D4 /* Bearlake */ |
60 | #define MEI_DEV_ID_ICH9_9 0x28E4 /* Bearlake */ | 60 | #define MEI_DEV_ID_ICH9_9 0x28E4 /* Bearlake */ |
61 | #define MEI_DEV_ID_ICH9_10 0x28F4 /* Bearlake */ | 61 | #define MEI_DEV_ID_ICH9_10 0x28F4 /* Bearlake */ |
62 | 62 | ||
63 | #define MEI_DEV_ID_ICH9M_1 0x2A44 /* Cantiga */ | 63 | #define MEI_DEV_ID_ICH9M_1 0x2A44 /* Cantiga */ |
64 | #define MEI_DEV_ID_ICH9M_2 0x2A54 /* Cantiga */ | 64 | #define MEI_DEV_ID_ICH9M_2 0x2A54 /* Cantiga */ |
65 | #define MEI_DEV_ID_ICH9M_3 0x2A64 /* Cantiga */ | 65 | #define MEI_DEV_ID_ICH9M_3 0x2A64 /* Cantiga */ |
66 | #define MEI_DEV_ID_ICH9M_4 0x2A74 /* Cantiga */ | 66 | #define MEI_DEV_ID_ICH9M_4 0x2A74 /* Cantiga */ |
67 | 67 | ||
68 | #define MEI_DEV_ID_ICH10_1 0x2E04 /* Eaglelake */ | 68 | #define MEI_DEV_ID_ICH10_1 0x2E04 /* Eaglelake */ |
69 | #define MEI_DEV_ID_ICH10_2 0x2E14 /* Eaglelake */ | 69 | #define MEI_DEV_ID_ICH10_2 0x2E14 /* Eaglelake */ |
70 | #define MEI_DEV_ID_ICH10_3 0x2E24 /* Eaglelake */ | 70 | #define MEI_DEV_ID_ICH10_3 0x2E24 /* Eaglelake */ |
71 | #define MEI_DEV_ID_ICH10_4 0x2E34 /* Eaglelake */ | 71 | #define MEI_DEV_ID_ICH10_4 0x2E34 /* Eaglelake */ |
72 | 72 | ||
73 | #define MEI_DEV_ID_IBXPK_1 0x3B64 /* Calpella */ | 73 | #define MEI_DEV_ID_IBXPK_1 0x3B64 /* Calpella */ |
74 | #define MEI_DEV_ID_IBXPK_2 0x3B65 /* Calpella */ | 74 | #define MEI_DEV_ID_IBXPK_2 0x3B65 /* Calpella */ |
75 | 75 | ||
76 | #define MEI_DEV_ID_CPT_1 0x1C3A /* Cougerpoint */ | 76 | #define MEI_DEV_ID_CPT_1 0x1C3A /* Couger Point */ |
77 | #define MEI_DEV_ID_PBG_1 0x1D3A /* PBG */ | 77 | #define MEI_DEV_ID_PBG_1 0x1D3A /* C600/X79 Patsburg */ |
78 | 78 | ||
79 | #define MEI_DEV_ID_PPT_1 0x1E3A /* Pantherpoint PPT */ | 79 | #define MEI_DEV_ID_PPT_1 0x1E3A /* Panther Point */ |
80 | #define MEI_DEV_ID_PPT_2 0x1CBA /* Pantherpoint PPT */ | 80 | #define MEI_DEV_ID_PPT_2 0x1CBA /* Panther Point */ |
81 | #define MEI_DEV_ID_PPT_3 0x1DBA /* Pantherpoint PPT */ | 81 | #define MEI_DEV_ID_PPT_3 0x1DBA /* Panther Point */ |
82 | 82 | ||
83 | 83 | #define MEI_DEV_ID_LPT 0x8C3A /* Lynx Point */ | |
84 | #define MEI_DEV_ID_LPT_LP 0x9C3A /* Lynx Point LP */ | ||
84 | /* | 85 | /* |
85 | * MEI HW Section | 86 | * MEI HW Section |
86 | */ | 87 | */ |
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index e77f86e69fb5..98f1430e3e14 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -24,6 +24,25 @@ | |||
24 | #include "interface.h" | 24 | #include "interface.h" |
25 | #include <linux/mei.h> | 25 | #include <linux/mei.h> |
26 | 26 | ||
27 | const char *mei_dev_state_str(int state) | ||
28 | { | ||
29 | #define MEI_DEV_STATE(state) case MEI_DEV_##state: return #state | ||
30 | switch (state) { | ||
31 | MEI_DEV_STATE(INITIALIZING); | ||
32 | MEI_DEV_STATE(INIT_CLIENTS); | ||
33 | MEI_DEV_STATE(ENABLED); | ||
34 | MEI_DEV_STATE(RESETING); | ||
35 | MEI_DEV_STATE(DISABLED); | ||
36 | MEI_DEV_STATE(RECOVERING_FROM_RESET); | ||
37 | MEI_DEV_STATE(POWER_DOWN); | ||
38 | MEI_DEV_STATE(POWER_UP); | ||
39 | default: | ||
40 | return "unkown"; | ||
41 | } | ||
42 | #undef MEI_DEV_STATE | ||
43 | } | ||
44 | |||
45 | |||
27 | const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac, | 46 | const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac, |
28 | 0xa8, 0x46, 0xe0, 0xff, 0x65, | 47 | 0xa8, 0x46, 0xe0, 0xff, 0x65, |
29 | 0x81, 0x4c); | 48 | 0x81, 0x4c); |
@@ -123,7 +142,7 @@ struct mei_device *mei_device_init(struct pci_dev *pdev) | |||
123 | mutex_init(&dev->device_lock); | 142 | mutex_init(&dev->device_lock); |
124 | init_waitqueue_head(&dev->wait_recvd_msg); | 143 | init_waitqueue_head(&dev->wait_recvd_msg); |
125 | init_waitqueue_head(&dev->wait_stop_wd); | 144 | init_waitqueue_head(&dev->wait_stop_wd); |
126 | dev->mei_state = MEI_INITIALIZING; | 145 | dev->dev_state = MEI_DEV_INITIALIZING; |
127 | dev->iamthif_state = MEI_IAMTHIF_IDLE; | 146 | dev->iamthif_state = MEI_IAMTHIF_IDLE; |
128 | dev->wd_interface_reg = false; | 147 | dev->wd_interface_reg = false; |
129 | 148 | ||
@@ -182,7 +201,7 @@ int mei_hw_init(struct mei_device *dev) | |||
182 | } | 201 | } |
183 | 202 | ||
184 | if (err <= 0 && !dev->recvd_msg) { | 203 | if (err <= 0 && !dev->recvd_msg) { |
185 | dev->mei_state = MEI_DISABLED; | 204 | dev->dev_state = MEI_DEV_DISABLED; |
186 | dev_dbg(&dev->pdev->dev, | 205 | dev_dbg(&dev->pdev->dev, |
187 | "wait_event_interruptible_timeout failed" | 206 | "wait_event_interruptible_timeout failed" |
188 | "on wait for ME to turn on ME_RDY.\n"); | 207 | "on wait for ME to turn on ME_RDY.\n"); |
@@ -192,7 +211,7 @@ int mei_hw_init(struct mei_device *dev) | |||
192 | 211 | ||
193 | if (!(((dev->host_hw_state & H_RDY) == H_RDY) && | 212 | if (!(((dev->host_hw_state & H_RDY) == H_RDY) && |
194 | ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) { | 213 | ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) { |
195 | dev->mei_state = MEI_DISABLED; | 214 | dev->dev_state = MEI_DEV_DISABLED; |
196 | dev_dbg(&dev->pdev->dev, | 215 | dev_dbg(&dev->pdev->dev, |
197 | "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", | 216 | "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n", |
198 | dev->host_hw_state, dev->me_hw_state); | 217 | dev->host_hw_state, dev->me_hw_state); |
@@ -258,15 +277,15 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
258 | struct mei_cl_cb *cb_next = NULL; | 277 | struct mei_cl_cb *cb_next = NULL; |
259 | bool unexpected; | 278 | bool unexpected; |
260 | 279 | ||
261 | if (dev->mei_state == MEI_RECOVERING_FROM_RESET) { | 280 | if (dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) { |
262 | dev->need_reset = true; | 281 | dev->need_reset = true; |
263 | return; | 282 | return; |
264 | } | 283 | } |
265 | 284 | ||
266 | unexpected = (dev->mei_state != MEI_INITIALIZING && | 285 | unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && |
267 | dev->mei_state != MEI_DISABLED && | 286 | dev->dev_state != MEI_DEV_DISABLED && |
268 | dev->mei_state != MEI_POWER_DOWN && | 287 | dev->dev_state != MEI_DEV_POWER_DOWN && |
269 | dev->mei_state != MEI_POWER_UP); | 288 | dev->dev_state != MEI_DEV_POWER_UP); |
270 | 289 | ||
271 | dev->host_hw_state = mei_hcsr_read(dev); | 290 | dev->host_hw_state = mei_hcsr_read(dev); |
272 | 291 | ||
@@ -285,10 +304,10 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
285 | 304 | ||
286 | dev->need_reset = false; | 305 | dev->need_reset = false; |
287 | 306 | ||
288 | if (dev->mei_state != MEI_INITIALIZING) { | 307 | if (dev->dev_state != MEI_DEV_INITIALIZING) { |
289 | if (dev->mei_state != MEI_DISABLED && | 308 | if (dev->dev_state != MEI_DEV_DISABLED && |
290 | dev->mei_state != MEI_POWER_DOWN) | 309 | dev->dev_state != MEI_DEV_POWER_DOWN) |
291 | dev->mei_state = MEI_RESETING; | 310 | dev->dev_state = MEI_DEV_RESETING; |
292 | 311 | ||
293 | list_for_each_entry_safe(cl_pos, | 312 | list_for_each_entry_safe(cl_pos, |
294 | cl_next, &dev->file_list, link) { | 313 | cl_next, &dev->file_list, link) { |
@@ -311,7 +330,6 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
311 | 330 | ||
312 | dev->me_clients_num = 0; | 331 | dev->me_clients_num = 0; |
313 | dev->rd_msg_hdr = 0; | 332 | dev->rd_msg_hdr = 0; |
314 | dev->stop = false; | ||
315 | dev->wd_pending = false; | 333 | dev->wd_pending = false; |
316 | 334 | ||
317 | /* update the state of the registers after reset */ | 335 | /* update the state of the registers after reset */ |
@@ -322,7 +340,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) | |||
322 | dev->host_hw_state, dev->me_hw_state); | 340 | dev->host_hw_state, dev->me_hw_state); |
323 | 341 | ||
324 | if (unexpected) | 342 | if (unexpected) |
325 | dev_warn(&dev->pdev->dev, "unexpected reset.\n"); | 343 | dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s\n", |
344 | mei_dev_state_str(dev->dev_state)); | ||
326 | 345 | ||
327 | /* Wake up all readings so they can be interrupted */ | 346 | /* Wake up all readings so they can be interrupted */ |
328 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { | 347 | list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) { |
@@ -371,7 +390,7 @@ void mei_host_start_message(struct mei_device *dev) | |||
371 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_start_req, | 390 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_start_req, |
372 | mei_hdr->length)) { | 391 | mei_hdr->length)) { |
373 | dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n"); | 392 | dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n"); |
374 | dev->mei_state = MEI_RESETING; | 393 | dev->dev_state = MEI_DEV_RESETING; |
375 | mei_reset(dev, 1); | 394 | mei_reset(dev, 1); |
376 | } | 395 | } |
377 | dev->init_clients_state = MEI_START_MESSAGE; | 396 | dev->init_clients_state = MEI_START_MESSAGE; |
@@ -403,7 +422,7 @@ void mei_host_enum_clients_message(struct mei_device *dev) | |||
403 | host_enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; | 422 | host_enum_req->hbm_cmd = HOST_ENUM_REQ_CMD; |
404 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_enum_req, | 423 | if (mei_write_message(dev, mei_hdr, (unsigned char *)host_enum_req, |
405 | mei_hdr->length)) { | 424 | mei_hdr->length)) { |
406 | dev->mei_state = MEI_RESETING; | 425 | dev->dev_state = MEI_DEV_RESETING; |
407 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); | 426 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); |
408 | mei_reset(dev, 1); | 427 | mei_reset(dev, 1); |
409 | } | 428 | } |
@@ -444,7 +463,7 @@ void mei_allocate_me_clients_storage(struct mei_device *dev) | |||
444 | sizeof(struct mei_me_client), GFP_KERNEL); | 463 | sizeof(struct mei_me_client), GFP_KERNEL); |
445 | if (!clients) { | 464 | if (!clients) { |
446 | dev_dbg(&dev->pdev->dev, "memory allocation for ME clients failed.\n"); | 465 | dev_dbg(&dev->pdev->dev, "memory allocation for ME clients failed.\n"); |
447 | dev->mei_state = MEI_RESETING; | 466 | dev->dev_state = MEI_DEV_RESETING; |
448 | mei_reset(dev, 1); | 467 | mei_reset(dev, 1); |
449 | return ; | 468 | return ; |
450 | } | 469 | } |
@@ -490,7 +509,7 @@ int mei_host_client_properties(struct mei_device *dev) | |||
490 | if (mei_write_message(dev, mei_header, | 509 | if (mei_write_message(dev, mei_header, |
491 | (unsigned char *)host_cli_req, | 510 | (unsigned char *)host_cli_req, |
492 | mei_header->length)) { | 511 | mei_header->length)) { |
493 | dev->mei_state = MEI_RESETING; | 512 | dev->dev_state = MEI_DEV_RESETING; |
494 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); | 513 | dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n"); |
495 | mei_reset(dev, 1); | 514 | mei_reset(dev, 1); |
496 | return -EIO; | 515 | return -EIO; |
@@ -522,12 +541,12 @@ void mei_cl_init(struct mei_cl *priv, struct mei_device *dev) | |||
522 | priv->dev = dev; | 541 | priv->dev = dev; |
523 | } | 542 | } |
524 | 543 | ||
525 | int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid) | 544 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid) |
526 | { | 545 | { |
527 | int i, res = -1; | 546 | int i, res = -ENOENT; |
528 | 547 | ||
529 | for (i = 0; i < dev->me_clients_num; ++i) | 548 | for (i = 0; i < dev->me_clients_num; ++i) |
530 | if (uuid_le_cmp(cuuid, | 549 | if (uuid_le_cmp(*cuuid, |
531 | dev->me_clients[i].props.protocol_name) == 0) { | 550 | dev->me_clients[i].props.protocol_name) == 0) { |
532 | res = i; | 551 | res = i; |
533 | break; | 552 | break; |
@@ -538,35 +557,35 @@ int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid) | |||
538 | 557 | ||
539 | 558 | ||
540 | /** | 559 | /** |
541 | * mei_find_me_client_update_filext - searches for ME client guid | 560 | * mei_me_cl_update_filext - searches for ME client guid |
542 | * sets client_id in mei_file_private if found | 561 | * sets client_id in mei_file_private if found |
543 | * @dev: the device structure | 562 | * @dev: the device structure |
544 | * @priv: private file structure to set client_id in | 563 | * @cl: private file structure to set client_id in |
545 | * @cguid: searched guid of ME client | 564 | * @cuuid: searched uuid of ME client |
546 | * @client_id: id of host client to be set in file private structure | 565 | * @client_id: id of host client to be set in file private structure |
547 | * | 566 | * |
548 | * returns ME client index | 567 | * returns ME client index |
549 | */ | 568 | */ |
550 | u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv, | 569 | int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl, |
551 | const uuid_le *cguid, u8 client_id) | 570 | const uuid_le *cuuid, u8 host_cl_id) |
552 | { | 571 | { |
553 | int i; | 572 | int i; |
554 | 573 | ||
555 | if (!dev || !priv || !cguid) | 574 | if (!dev || !cl || !cuuid) |
556 | return 0; | 575 | return -EINVAL; |
557 | 576 | ||
558 | /* check for valid client id */ | 577 | /* check for valid client id */ |
559 | i = mei_find_me_client_index(dev, *cguid); | 578 | i = mei_me_cl_by_uuid(dev, cuuid); |
560 | if (i >= 0) { | 579 | if (i >= 0) { |
561 | priv->me_client_id = dev->me_clients[i].client_id; | 580 | cl->me_client_id = dev->me_clients[i].client_id; |
562 | priv->state = MEI_FILE_CONNECTING; | 581 | cl->state = MEI_FILE_CONNECTING; |
563 | priv->host_client_id = client_id; | 582 | cl->host_client_id = host_cl_id; |
564 | 583 | ||
565 | list_add_tail(&priv->link, &dev->file_list); | 584 | list_add_tail(&cl->link, &dev->file_list); |
566 | return (u8)i; | 585 | return (u8)i; |
567 | } | 586 | } |
568 | 587 | ||
569 | return 0; | 588 | return -ENOENT; |
570 | } | 589 | } |
571 | 590 | ||
572 | /** | 591 | /** |
@@ -577,16 +596,16 @@ u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv, | |||
577 | */ | 596 | */ |
578 | void mei_host_init_iamthif(struct mei_device *dev) | 597 | void mei_host_init_iamthif(struct mei_device *dev) |
579 | { | 598 | { |
580 | u8 i; | 599 | int i; |
581 | unsigned char *msg_buf; | 600 | unsigned char *msg_buf; |
582 | 601 | ||
583 | mei_cl_init(&dev->iamthif_cl, dev); | 602 | mei_cl_init(&dev->iamthif_cl, dev); |
584 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; | 603 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTED; |
585 | 604 | ||
586 | /* find ME amthi client */ | 605 | /* find ME amthi client */ |
587 | i = mei_find_me_client_update_filext(dev, &dev->iamthif_cl, | 606 | i = mei_me_cl_update_filext(dev, &dev->iamthif_cl, |
588 | &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID); | 607 | &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID); |
589 | if (dev->iamthif_cl.state != MEI_FILE_CONNECTING) { | 608 | if (i < 0) { |
590 | dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n"); | 609 | dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n"); |
591 | return; | 610 | return; |
592 | } | 611 | } |
diff --git a/drivers/misc/mei/interface.h b/drivers/misc/mei/interface.h index fb5c7db4723b..ec6c785a3961 100644 --- a/drivers/misc/mei/interface.h +++ b/drivers/misc/mei/interface.h | |||
@@ -23,14 +23,6 @@ | |||
23 | #include "mei_dev.h" | 23 | #include "mei_dev.h" |
24 | 24 | ||
25 | 25 | ||
26 | #define AMT_WD_DEFAULT_TIMEOUT 120 /* seconds */ | ||
27 | #define AMT_WD_MIN_TIMEOUT 120 /* seconds */ | ||
28 | #define AMT_WD_MAX_TIMEOUT 65535 /* seconds */ | ||
29 | |||
30 | #define MEI_WATCHDOG_DATA_SIZE 16 | ||
31 | #define MEI_START_WD_DATA_SIZE 20 | ||
32 | #define MEI_WD_PARAMS_SIZE 4 | ||
33 | |||
34 | 26 | ||
35 | void mei_read_slots(struct mei_device *dev, | 27 | void mei_read_slots(struct mei_device *dev, |
36 | unsigned char *buffer, | 28 | unsigned char *buffer, |
@@ -64,7 +56,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); | |||
64 | 56 | ||
65 | 57 | ||
66 | int mei_wd_send(struct mei_device *dev); | 58 | int mei_wd_send(struct mei_device *dev); |
67 | int mei_wd_stop(struct mei_device *dev, bool preserve); | 59 | int mei_wd_stop(struct mei_device *dev); |
68 | int mei_wd_host_init(struct mei_device *dev); | 60 | int mei_wd_host_init(struct mei_device *dev); |
69 | /* | 61 | /* |
70 | * mei_watchdog_register - Registering watchdog interface | 62 | * mei_watchdog_register - Registering watchdog interface |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index c6ffbbe5a6c0..3533edde04a5 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
@@ -221,17 +221,10 @@ static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list, | |||
221 | cl->status = 0; | 221 | cl->status = 0; |
222 | list_del(&cb_pos->cb_list); | 222 | list_del(&cb_pos->cb_list); |
223 | dev_dbg(&dev->pdev->dev, | 223 | dev_dbg(&dev->pdev->dev, |
224 | "completed read host client = %d," | 224 | "completed read H cl = %d, ME cl = %d, length = %lu\n", |
225 | "ME client = %d, " | ||
226 | "data length = %lu\n", | ||
227 | cl->host_client_id, | 225 | cl->host_client_id, |
228 | cl->me_client_id, | 226 | cl->me_client_id, |
229 | cb_pos->information); | 227 | cb_pos->information); |
230 | |||
231 | *(cb_pos->response_buffer.data + | ||
232 | cb_pos->information) = '\0'; | ||
233 | dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n", | ||
234 | cb_pos->response_buffer.data); | ||
235 | list_add_tail(&cb_pos->cb_list, | 228 | list_add_tail(&cb_pos->cb_list, |
236 | &complete_list->mei_cb.cb_list); | 229 | &complete_list->mei_cb.cb_list); |
237 | } | 230 | } |
@@ -633,7 +626,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, | |||
633 | if (version_res->host_version_supported) { | 626 | if (version_res->host_version_supported) { |
634 | dev->version.major_version = HBM_MAJOR_VERSION; | 627 | dev->version.major_version = HBM_MAJOR_VERSION; |
635 | dev->version.minor_version = HBM_MINOR_VERSION; | 628 | dev->version.minor_version = HBM_MINOR_VERSION; |
636 | if (dev->mei_state == MEI_INIT_CLIENTS && | 629 | if (dev->dev_state == MEI_DEV_INIT_CLIENTS && |
637 | dev->init_clients_state == MEI_START_MESSAGE) { | 630 | dev->init_clients_state == MEI_START_MESSAGE) { |
638 | dev->init_clients_timer = 0; | 631 | dev->init_clients_timer = 0; |
639 | mei_host_enum_clients_message(dev); | 632 | mei_host_enum_clients_message(dev); |
@@ -707,7 +700,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, | |||
707 | dev->me_clients[dev->me_client_presentation_num].props | 700 | dev->me_clients[dev->me_client_presentation_num].props |
708 | = props_res->client_properties; | 701 | = props_res->client_properties; |
709 | 702 | ||
710 | if (dev->mei_state == MEI_INIT_CLIENTS && | 703 | if (dev->dev_state == MEI_DEV_INIT_CLIENTS && |
711 | dev->init_clients_state == | 704 | dev->init_clients_state == |
712 | MEI_CLIENT_PROPERTIES_MESSAGE) { | 705 | MEI_CLIENT_PROPERTIES_MESSAGE) { |
713 | dev->me_client_index++; | 706 | dev->me_client_index++; |
@@ -734,7 +727,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, | |||
734 | * Client ID 2 - Reserved for AMTHI | 727 | * Client ID 2 - Reserved for AMTHI |
735 | */ | 728 | */ |
736 | bitmap_set(dev->host_clients_map, 0, 3); | 729 | bitmap_set(dev->host_clients_map, 0, 3); |
737 | dev->mei_state = MEI_ENABLED; | 730 | dev->dev_state = MEI_DEV_ENABLED; |
738 | 731 | ||
739 | /* if wd initialization fails, initialization the AMTHI client, | 732 | /* if wd initialization fails, initialization the AMTHI client, |
740 | * otherwise the AMTHI client will be initialized after the WD client connect response | 733 | * otherwise the AMTHI client will be initialized after the WD client connect response |
@@ -759,7 +752,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, | |||
759 | case HOST_ENUM_RES_CMD: | 752 | case HOST_ENUM_RES_CMD: |
760 | enum_res = (struct hbm_host_enum_response *) mei_msg; | 753 | enum_res = (struct hbm_host_enum_response *) mei_msg; |
761 | memcpy(dev->me_clients_map, enum_res->valid_addresses, 32); | 754 | memcpy(dev->me_clients_map, enum_res->valid_addresses, 32); |
762 | if (dev->mei_state == MEI_INIT_CLIENTS && | 755 | if (dev->dev_state == MEI_DEV_INIT_CLIENTS && |
763 | dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) { | 756 | dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) { |
764 | dev->init_clients_timer = 0; | 757 | dev->init_clients_timer = 0; |
765 | dev->me_client_presentation_num = 0; | 758 | dev->me_client_presentation_num = 0; |
@@ -776,7 +769,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev, | |||
776 | break; | 769 | break; |
777 | 770 | ||
778 | case HOST_STOP_RES_CMD: | 771 | case HOST_STOP_RES_CMD: |
779 | dev->mei_state = MEI_DISABLED; | 772 | dev->dev_state = MEI_DEV_DISABLED; |
780 | dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n"); | 773 | dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n"); |
781 | mei_reset(dev, 1); | 774 | mei_reset(dev, 1); |
782 | break; | 775 | break; |
@@ -1224,10 +1217,9 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, | |||
1224 | } | 1217 | } |
1225 | } | 1218 | } |
1226 | 1219 | ||
1227 | if (dev->stop && !dev->wd_pending) { | 1220 | if (dev->wd_state == MEI_WD_STOPPING) { |
1228 | dev->wd_stopped = true; | 1221 | dev->wd_state = MEI_WD_IDLE; |
1229 | wake_up_interruptible(&dev->wait_stop_wd); | 1222 | wake_up_interruptible(&dev->wait_stop_wd); |
1230 | return 0; | ||
1231 | } | 1223 | } |
1232 | 1224 | ||
1233 | if (dev->extra_write_index) { | 1225 | if (dev->extra_write_index) { |
@@ -1240,7 +1232,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, | |||
1240 | *slots -= dev->extra_write_index; | 1232 | *slots -= dev->extra_write_index; |
1241 | dev->extra_write_index = 0; | 1233 | dev->extra_write_index = 0; |
1242 | } | 1234 | } |
1243 | if (dev->mei_state == MEI_ENABLED) { | 1235 | if (dev->dev_state == MEI_DEV_ENABLED) { |
1244 | if (dev->wd_pending && | 1236 | if (dev->wd_pending && |
1245 | mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { | 1237 | mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { |
1246 | if (mei_wd_send(dev)) | 1238 | if (mei_wd_send(dev)) |
@@ -1250,14 +1242,12 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list, | |||
1250 | 1242 | ||
1251 | dev->wd_pending = false; | 1243 | dev->wd_pending = false; |
1252 | 1244 | ||
1253 | if (dev->wd_timeout) | 1245 | if (dev->wd_state == MEI_WD_RUNNING) |
1254 | *slots -= mei_data2slots(MEI_START_WD_DATA_SIZE); | 1246 | *slots -= mei_data2slots(MEI_WD_START_MSG_SIZE); |
1255 | else | 1247 | else |
1256 | *slots -= mei_data2slots(MEI_START_WD_DATA_SIZE); | 1248 | *slots -= mei_data2slots(MEI_WD_STOP_MSG_SIZE); |
1257 | } | 1249 | } |
1258 | } | 1250 | } |
1259 | if (dev->stop) | ||
1260 | return -ENODEV; | ||
1261 | 1251 | ||
1262 | /* complete control write list CB */ | 1252 | /* complete control write list CB */ |
1263 | dev_dbg(&dev->pdev->dev, "complete control write list cb.\n"); | 1253 | dev_dbg(&dev->pdev->dev, "complete control write list cb.\n"); |
@@ -1361,8 +1351,8 @@ void mei_timer(struct work_struct *work) | |||
1361 | 1351 | ||
1362 | 1352 | ||
1363 | mutex_lock(&dev->device_lock); | 1353 | mutex_lock(&dev->device_lock); |
1364 | if (dev->mei_state != MEI_ENABLED) { | 1354 | if (dev->dev_state != MEI_DEV_ENABLED) { |
1365 | if (dev->mei_state == MEI_INIT_CLIENTS) { | 1355 | if (dev->dev_state == MEI_DEV_INIT_CLIENTS) { |
1366 | if (dev->init_clients_timer) { | 1356 | if (dev->init_clients_timer) { |
1367 | if (--dev->init_clients_timer == 0) { | 1357 | if (--dev->init_clients_timer == 0) { |
1368 | dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n", | 1358 | dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n", |
@@ -1484,8 +1474,8 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) | |||
1484 | 1474 | ||
1485 | /* check if ME wants a reset */ | 1475 | /* check if ME wants a reset */ |
1486 | if ((dev->me_hw_state & ME_RDY_HRA) == 0 && | 1476 | if ((dev->me_hw_state & ME_RDY_HRA) == 0 && |
1487 | dev->mei_state != MEI_RESETING && | 1477 | dev->dev_state != MEI_DEV_RESETING && |
1488 | dev->mei_state != MEI_INITIALIZING) { | 1478 | dev->dev_state != MEI_DEV_INITIALIZING) { |
1489 | dev_dbg(&dev->pdev->dev, "FW not ready.\n"); | 1479 | dev_dbg(&dev->pdev->dev, "FW not ready.\n"); |
1490 | mei_reset(dev, 1); | 1480 | mei_reset(dev, 1); |
1491 | mutex_unlock(&dev->device_lock); | 1481 | mutex_unlock(&dev->device_lock); |
@@ -1498,7 +1488,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) | |||
1498 | dev_dbg(&dev->pdev->dev, "we need to start the dev.\n"); | 1488 | dev_dbg(&dev->pdev->dev, "we need to start the dev.\n"); |
1499 | dev->host_hw_state |= (H_IE | H_IG | H_RDY); | 1489 | dev->host_hw_state |= (H_IE | H_IG | H_RDY); |
1500 | mei_hcsr_set(dev); | 1490 | mei_hcsr_set(dev); |
1501 | dev->mei_state = MEI_INIT_CLIENTS; | 1491 | dev->dev_state = MEI_DEV_INIT_CLIENTS; |
1502 | dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n"); | 1492 | dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n"); |
1503 | /* link is established | 1493 | /* link is established |
1504 | * start sending messages. | 1494 | * start sending messages. |
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c index 50f52e21f587..fcba98eb892e 100644 --- a/drivers/misc/mei/iorw.c +++ b/drivers/misc/mei/iorw.c | |||
@@ -38,7 +38,31 @@ | |||
38 | #include <linux/mei.h> | 38 | #include <linux/mei.h> |
39 | #include "interface.h" | 39 | #include "interface.h" |
40 | 40 | ||
41 | /** | ||
42 | * mei_me_cl_by_id return index to me_clients for client_id | ||
43 | * | ||
44 | * @dev: the device structure | ||
45 | * @client_id: me client id | ||
46 | * | ||
47 | * Locking: called under "dev->device_lock" lock | ||
48 | * | ||
49 | * returns index on success, -ENOENT on failure. | ||
50 | */ | ||
41 | 51 | ||
52 | int mei_me_cl_by_id(struct mei_device *dev, u8 client_id) | ||
53 | { | ||
54 | int i; | ||
55 | for (i = 0; i < dev->me_clients_num; i++) | ||
56 | if (dev->me_clients[i].client_id == client_id) | ||
57 | break; | ||
58 | if (WARN_ON(dev->me_clients[i].client_id != client_id)) | ||
59 | return -ENOENT; | ||
60 | |||
61 | if (i == dev->me_clients_num) | ||
62 | return -ENOENT; | ||
63 | |||
64 | return i; | ||
65 | } | ||
42 | 66 | ||
43 | /** | 67 | /** |
44 | * mei_ioctl_connect_client - the connect to fw client IOCTL function | 68 | * mei_ioctl_connect_client - the connect to fw client IOCTL function |
@@ -84,7 +108,7 @@ int mei_ioctl_connect_client(struct file *file, | |||
84 | 108 | ||
85 | cb->major_file_operations = MEI_IOCTL; | 109 | cb->major_file_operations = MEI_IOCTL; |
86 | 110 | ||
87 | if (dev->mei_state != MEI_ENABLED) { | 111 | if (dev->dev_state != MEI_DEV_ENABLED) { |
88 | rets = -ENODEV; | 112 | rets = -ENODEV; |
89 | goto end; | 113 | goto end; |
90 | } | 114 | } |
@@ -95,7 +119,7 @@ int mei_ioctl_connect_client(struct file *file, | |||
95 | } | 119 | } |
96 | 120 | ||
97 | /* find ME client we're trying to connect to */ | 121 | /* find ME client we're trying to connect to */ |
98 | i = mei_find_me_client_index(dev, data->in_client_uuid); | 122 | i = mei_me_cl_by_uuid(dev, &data->in_client_uuid); |
99 | if (i >= 0 && !dev->me_clients[i].props.fixed_address) { | 123 | if (i >= 0 && !dev->me_clients[i].props.fixed_address) { |
100 | cl->me_client_id = dev->me_clients[i].client_id; | 124 | cl->me_client_id = dev->me_clients[i].client_id; |
101 | cl->state = MEI_FILE_CONNECTING; | 125 | cl->state = MEI_FILE_CONNECTING; |
@@ -273,19 +297,12 @@ int amthi_read(struct mei_device *dev, struct file *file, | |||
273 | return -ETIMEDOUT; | 297 | return -ETIMEDOUT; |
274 | } | 298 | } |
275 | 299 | ||
276 | for (i = 0; i < dev->me_clients_num; i++) { | 300 | i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); |
277 | if (dev->me_clients[i].client_id == | ||
278 | dev->iamthif_cl.me_client_id) | ||
279 | break; | ||
280 | } | ||
281 | 301 | ||
282 | if (i == dev->me_clients_num) { | 302 | if (i < 0) { |
283 | dev_dbg(&dev->pdev->dev, "amthi client not found.\n"); | 303 | dev_dbg(&dev->pdev->dev, "amthi client not found.\n"); |
284 | return -ENODEV; | 304 | return -ENODEV; |
285 | } | 305 | } |
286 | if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) | ||
287 | return -ENODEV; | ||
288 | |||
289 | dev_dbg(&dev->pdev->dev, "checking amthi data\n"); | 306 | dev_dbg(&dev->pdev->dev, "checking amthi data\n"); |
290 | cb = find_amthi_read_list_entry(dev, file); | 307 | cb = find_amthi_read_list_entry(dev, file); |
291 | 308 | ||
@@ -316,8 +333,7 @@ int amthi_read(struct mei_device *dev, struct file *file, | |||
316 | dev->iamthif_timer = 0; | 333 | dev->iamthif_timer = 0; |
317 | 334 | ||
318 | if (cb) { | 335 | if (cb) { |
319 | timeout = cb->read_time + | 336 | timeout = cb->read_time + msecs_to_jiffies(IAMTHIF_READ_TIMER); |
320 | msecs_to_jiffies(IAMTHIF_READ_TIMER); | ||
321 | dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n", | 337 | dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n", |
322 | timeout); | 338 | timeout); |
323 | 339 | ||
@@ -386,7 +402,7 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl) | |||
386 | if (cl->state != MEI_FILE_CONNECTED) | 402 | if (cl->state != MEI_FILE_CONNECTED) |
387 | return -ENODEV; | 403 | return -ENODEV; |
388 | 404 | ||
389 | if (dev->mei_state != MEI_ENABLED) | 405 | if (dev->dev_state != MEI_DEV_ENABLED) |
390 | return -ENODEV; | 406 | return -ENODEV; |
391 | 407 | ||
392 | dev_dbg(&dev->pdev->dev, "check if read is pending.\n"); | 408 | dev_dbg(&dev->pdev->dev, "check if read is pending.\n"); |
@@ -401,19 +417,8 @@ int mei_start_read(struct mei_device *dev, struct mei_cl *cl) | |||
401 | 417 | ||
402 | dev_dbg(&dev->pdev->dev, "allocation call back successful. host client = %d, ME client = %d\n", | 418 | dev_dbg(&dev->pdev->dev, "allocation call back successful. host client = %d, ME client = %d\n", |
403 | cl->host_client_id, cl->me_client_id); | 419 | cl->host_client_id, cl->me_client_id); |
404 | 420 | i = mei_me_cl_by_id(dev, cl->me_client_id); | |
405 | for (i = 0; i < dev->me_clients_num; i++) { | 421 | if (i < 0) { |
406 | if (dev->me_clients[i].client_id == cl->me_client_id) | ||
407 | break; | ||
408 | |||
409 | } | ||
410 | |||
411 | if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) { | ||
412 | rets = -ENODEV; | ||
413 | goto unlock; | ||
414 | } | ||
415 | |||
416 | if (i == dev->me_clients_num) { | ||
417 | rets = -ENODEV; | 422 | rets = -ENODEV; |
418 | goto unlock; | 423 | goto unlock; |
419 | } | 424 | } |
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index 092330208869..e8b0858132c1 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
@@ -41,11 +41,8 @@ | |||
41 | #include <linux/mei.h> | 41 | #include <linux/mei.h> |
42 | #include "interface.h" | 42 | #include "interface.h" |
43 | 43 | ||
44 | static const char mei_driver_name[] = "mei"; | 44 | /* AMT device is a singleton on the platform */ |
45 | 45 | static struct pci_dev *mei_pdev; | |
46 | /* The device pointer */ | ||
47 | /* Currently this driver works as long as there is only a single AMT device. */ | ||
48 | struct pci_dev *mei_device; | ||
49 | 46 | ||
50 | /* mei_pci_tbl - PCI Device ID Table */ | 47 | /* mei_pci_tbl - PCI Device ID Table */ |
51 | static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { | 48 | static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { |
@@ -80,6 +77,8 @@ static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = { | |||
80 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)}, | 77 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)}, |
81 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)}, | 78 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)}, |
82 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)}, | 79 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)}, |
80 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT)}, | ||
81 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)}, | ||
83 | 82 | ||
84 | /* required last entry */ | 83 | /* required last entry */ |
85 | {0, } | 84 | {0, } |
@@ -220,10 +219,10 @@ static int mei_open(struct inode *inode, struct file *file) | |||
220 | int err; | 219 | int err; |
221 | 220 | ||
222 | err = -ENODEV; | 221 | err = -ENODEV; |
223 | if (!mei_device) | 222 | if (!mei_pdev) |
224 | goto out; | 223 | goto out; |
225 | 224 | ||
226 | dev = pci_get_drvdata(mei_device); | 225 | dev = pci_get_drvdata(mei_pdev); |
227 | if (!dev) | 226 | if (!dev) |
228 | goto out; | 227 | goto out; |
229 | 228 | ||
@@ -234,18 +233,24 @@ static int mei_open(struct inode *inode, struct file *file) | |||
234 | goto out_unlock; | 233 | goto out_unlock; |
235 | 234 | ||
236 | err = -ENODEV; | 235 | err = -ENODEV; |
237 | if (dev->mei_state != MEI_ENABLED) { | 236 | if (dev->dev_state != MEI_DEV_ENABLED) { |
238 | dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n", | 237 | dev_dbg(&dev->pdev->dev, "dev_state != MEI_ENABLED dev_state = %s\n", |
239 | dev->mei_state); | 238 | mei_dev_state_str(dev->dev_state)); |
240 | goto out_unlock; | 239 | goto out_unlock; |
241 | } | 240 | } |
242 | err = -EMFILE; | 241 | err = -EMFILE; |
243 | if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT) | 242 | if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT) { |
243 | dev_err(&dev->pdev->dev, "open_handle_count exceded %d", | ||
244 | MEI_MAX_OPEN_HANDLE_COUNT); | ||
244 | goto out_unlock; | 245 | goto out_unlock; |
246 | } | ||
245 | 247 | ||
246 | cl_id = find_first_zero_bit(dev->host_clients_map, MEI_CLIENTS_MAX); | 248 | cl_id = find_first_zero_bit(dev->host_clients_map, MEI_CLIENTS_MAX); |
247 | if (cl_id >= MEI_CLIENTS_MAX) | 249 | if (cl_id >= MEI_CLIENTS_MAX) { |
250 | dev_err(&dev->pdev->dev, "client_id exceded %d", | ||
251 | MEI_CLIENTS_MAX) ; | ||
248 | goto out_unlock; | 252 | goto out_unlock; |
253 | } | ||
249 | 254 | ||
250 | cl->host_client_id = cl_id; | 255 | cl->host_client_id = cl_id; |
251 | 256 | ||
@@ -386,17 +391,16 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, | |||
386 | dev = cl->dev; | 391 | dev = cl->dev; |
387 | 392 | ||
388 | mutex_lock(&dev->device_lock); | 393 | mutex_lock(&dev->device_lock); |
389 | if (dev->mei_state != MEI_ENABLED) { | 394 | if (dev->dev_state != MEI_DEV_ENABLED) { |
390 | rets = -ENODEV; | 395 | rets = -ENODEV; |
391 | goto out; | 396 | goto out; |
392 | } | 397 | } |
393 | 398 | ||
394 | if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { | 399 | if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) { |
395 | /* Do not allow to read watchdog client */ | 400 | /* Do not allow to read watchdog client */ |
396 | i = mei_find_me_client_index(dev, mei_wd_guid); | 401 | i = mei_me_cl_by_uuid(dev, &mei_wd_guid); |
397 | if (i >= 0) { | 402 | if (i >= 0) { |
398 | struct mei_me_client *me_client = &dev->me_clients[i]; | 403 | struct mei_me_client *me_client = &dev->me_clients[i]; |
399 | |||
400 | if (cl->me_client_id == me_client->client_id) { | 404 | if (cl->me_client_id == me_client->client_id) { |
401 | rets = -EBADF; | 405 | rets = -EBADF; |
402 | goto out; | 406 | goto out; |
@@ -541,7 +545,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
541 | 545 | ||
542 | mutex_lock(&dev->device_lock); | 546 | mutex_lock(&dev->device_lock); |
543 | 547 | ||
544 | if (dev->mei_state != MEI_ENABLED) { | 548 | if (dev->dev_state != MEI_DEV_ENABLED) { |
545 | mutex_unlock(&dev->device_lock); | 549 | mutex_unlock(&dev->device_lock); |
546 | return -ENODEV; | 550 | return -ENODEV; |
547 | } | 551 | } |
@@ -616,26 +620,16 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
616 | rets = -ENOMEM; | 620 | rets = -ENOMEM; |
617 | goto unlock_dev; | 621 | goto unlock_dev; |
618 | } | 622 | } |
619 | if (dev->mei_state != MEI_ENABLED) { | 623 | if (dev->dev_state != MEI_DEV_ENABLED) { |
620 | rets = -ENODEV; | 624 | rets = -ENODEV; |
621 | goto unlock_dev; | 625 | goto unlock_dev; |
622 | } | 626 | } |
623 | for (i = 0; i < dev->me_clients_num; i++) { | 627 | i = mei_me_cl_by_id(dev, dev->iamthif_cl.me_client_id); |
624 | if (dev->me_clients[i].client_id == | 628 | if (i < 0) { |
625 | dev->iamthif_cl.me_client_id) | ||
626 | break; | ||
627 | } | ||
628 | |||
629 | if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) { | ||
630 | rets = -ENODEV; | 629 | rets = -ENODEV; |
631 | goto unlock_dev; | 630 | goto unlock_dev; |
632 | } | 631 | } |
633 | if (i == dev->me_clients_num || | 632 | if (length > dev->me_clients[i].props.max_msg_length || |
634 | (dev->me_clients[i].client_id != | ||
635 | dev->iamthif_cl.me_client_id)) { | ||
636 | rets = -ENODEV; | ||
637 | goto unlock_dev; | ||
638 | } else if (length > dev->me_clients[i].props.max_msg_length || | ||
639 | length <= 0) { | 633 | length <= 0) { |
640 | rets = -EMSGSIZE; | 634 | rets = -EMSGSIZE; |
641 | goto unlock_dev; | 635 | goto unlock_dev; |
@@ -688,16 +682,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
688 | cl->me_client_id); | 682 | cl->me_client_id); |
689 | goto unlock_dev; | 683 | goto unlock_dev; |
690 | } | 684 | } |
691 | for (i = 0; i < dev->me_clients_num; i++) { | 685 | i = mei_me_cl_by_id(dev, cl->me_client_id); |
692 | if (dev->me_clients[i].client_id == | 686 | if (i < 0) { |
693 | cl->me_client_id) | ||
694 | break; | ||
695 | } | ||
696 | if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) { | ||
697 | rets = -ENODEV; | ||
698 | goto unlock_dev; | ||
699 | } | ||
700 | if (i == dev->me_clients_num) { | ||
701 | rets = -ENODEV; | 687 | rets = -ENODEV; |
702 | goto unlock_dev; | 688 | goto unlock_dev; |
703 | } | 689 | } |
@@ -790,7 +776,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) | |||
790 | dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd); | 776 | dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd); |
791 | 777 | ||
792 | mutex_lock(&dev->device_lock); | 778 | mutex_lock(&dev->device_lock); |
793 | if (dev->mei_state != MEI_ENABLED) { | 779 | if (dev->dev_state != MEI_DEV_ENABLED) { |
794 | rets = -ENODEV; | 780 | rets = -ENODEV; |
795 | goto out; | 781 | goto out; |
796 | } | 782 | } |
@@ -869,7 +855,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait) | |||
869 | 855 | ||
870 | mutex_lock(&dev->device_lock); | 856 | mutex_lock(&dev->device_lock); |
871 | 857 | ||
872 | if (dev->mei_state != MEI_ENABLED) | 858 | if (dev->dev_state != MEI_DEV_ENABLED) |
873 | goto out; | 859 | goto out; |
874 | 860 | ||
875 | 861 | ||
@@ -925,6 +911,27 @@ static struct miscdevice mei_misc_device = { | |||
925 | }; | 911 | }; |
926 | 912 | ||
927 | /** | 913 | /** |
914 | * mei_quirk_probe - probe for devices that doesn't valid ME interface | ||
915 | * @pdev: PCI device structure | ||
916 | * @ent: entry into pci_device_table | ||
917 | * | ||
918 | * returns true if ME Interface is valid, false otherwise | ||
919 | */ | ||
920 | static bool __devinit mei_quirk_probe(struct pci_dev *pdev, | ||
921 | const struct pci_device_id *ent) | ||
922 | { | ||
923 | u32 reg; | ||
924 | if (ent->device == MEI_DEV_ID_PBG_1) { | ||
925 | pci_read_config_dword(pdev, 0x48, ®); | ||
926 | /* make sure that bit 9 is up and bit 10 is down */ | ||
927 | if ((reg & 0x600) == 0x200) { | ||
928 | dev_info(&pdev->dev, "Device doesn't have valid ME Interface\n"); | ||
929 | return false; | ||
930 | } | ||
931 | } | ||
932 | return true; | ||
933 | } | ||
934 | /** | ||
928 | * mei_probe - Device Initialization Routine | 935 | * mei_probe - Device Initialization Routine |
929 | * | 936 | * |
930 | * @pdev: PCI device structure | 937 | * @pdev: PCI device structure |
@@ -939,7 +946,13 @@ static int __devinit mei_probe(struct pci_dev *pdev, | |||
939 | int err; | 946 | int err; |
940 | 947 | ||
941 | mutex_lock(&mei_mutex); | 948 | mutex_lock(&mei_mutex); |
942 | if (mei_device) { | 949 | |
950 | if (!mei_quirk_probe(pdev, ent)) { | ||
951 | err = -ENODEV; | ||
952 | goto end; | ||
953 | } | ||
954 | |||
955 | if (mei_pdev) { | ||
943 | err = -EEXIST; | 956 | err = -EEXIST; |
944 | goto end; | 957 | goto end; |
945 | } | 958 | } |
@@ -952,7 +965,7 @@ static int __devinit mei_probe(struct pci_dev *pdev, | |||
952 | /* set PCI host mastering */ | 965 | /* set PCI host mastering */ |
953 | pci_set_master(pdev); | 966 | pci_set_master(pdev); |
954 | /* pci request regions for mei driver */ | 967 | /* pci request regions for mei driver */ |
955 | err = pci_request_regions(pdev, mei_driver_name); | 968 | err = pci_request_regions(pdev, KBUILD_MODNAME); |
956 | if (err) { | 969 | if (err) { |
957 | dev_err(&pdev->dev, "failed to get pci regions.\n"); | 970 | dev_err(&pdev->dev, "failed to get pci regions.\n"); |
958 | goto disable_device; | 971 | goto disable_device; |
@@ -977,12 +990,12 @@ static int __devinit mei_probe(struct pci_dev *pdev, | |||
977 | err = request_threaded_irq(pdev->irq, | 990 | err = request_threaded_irq(pdev->irq, |
978 | NULL, | 991 | NULL, |
979 | mei_interrupt_thread_handler, | 992 | mei_interrupt_thread_handler, |
980 | IRQF_ONESHOT, mei_driver_name, dev); | 993 | IRQF_ONESHOT, KBUILD_MODNAME, dev); |
981 | else | 994 | else |
982 | err = request_threaded_irq(pdev->irq, | 995 | err = request_threaded_irq(pdev->irq, |
983 | mei_interrupt_quick_handler, | 996 | mei_interrupt_quick_handler, |
984 | mei_interrupt_thread_handler, | 997 | mei_interrupt_thread_handler, |
985 | IRQF_SHARED, mei_driver_name, dev); | 998 | IRQF_SHARED, KBUILD_MODNAME, dev); |
986 | 999 | ||
987 | if (err) { | 1000 | if (err) { |
988 | dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n", | 1001 | dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n", |
@@ -1000,7 +1013,7 @@ static int __devinit mei_probe(struct pci_dev *pdev, | |||
1000 | if (err) | 1013 | if (err) |
1001 | goto release_irq; | 1014 | goto release_irq; |
1002 | 1015 | ||
1003 | mei_device = pdev; | 1016 | mei_pdev = pdev; |
1004 | pci_set_drvdata(pdev, dev); | 1017 | pci_set_drvdata(pdev, dev); |
1005 | 1018 | ||
1006 | 1019 | ||
@@ -1045,7 +1058,7 @@ static void __devexit mei_remove(struct pci_dev *pdev) | |||
1045 | { | 1058 | { |
1046 | struct mei_device *dev; | 1059 | struct mei_device *dev; |
1047 | 1060 | ||
1048 | if (mei_device != pdev) | 1061 | if (mei_pdev != pdev) |
1049 | return; | 1062 | return; |
1050 | 1063 | ||
1051 | dev = pci_get_drvdata(pdev); | 1064 | dev = pci_get_drvdata(pdev); |
@@ -1054,9 +1067,11 @@ static void __devexit mei_remove(struct pci_dev *pdev) | |||
1054 | 1067 | ||
1055 | mutex_lock(&dev->device_lock); | 1068 | mutex_lock(&dev->device_lock); |
1056 | 1069 | ||
1057 | mei_wd_stop(dev, false); | 1070 | cancel_delayed_work(&dev->timer_work); |
1058 | 1071 | ||
1059 | mei_device = NULL; | 1072 | mei_wd_stop(dev); |
1073 | |||
1074 | mei_pdev = NULL; | ||
1060 | 1075 | ||
1061 | if (dev->iamthif_cl.state == MEI_FILE_CONNECTED) { | 1076 | if (dev->iamthif_cl.state == MEI_FILE_CONNECTED) { |
1062 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTING; | 1077 | dev->iamthif_cl.state = MEI_FILE_DISCONNECTING; |
@@ -1109,12 +1124,15 @@ static int mei_pci_suspend(struct device *device) | |||
1109 | if (!dev) | 1124 | if (!dev) |
1110 | return -ENODEV; | 1125 | return -ENODEV; |
1111 | mutex_lock(&dev->device_lock); | 1126 | mutex_lock(&dev->device_lock); |
1127 | |||
1128 | cancel_delayed_work(&dev->timer_work); | ||
1129 | |||
1112 | /* Stop watchdog if exists */ | 1130 | /* Stop watchdog if exists */ |
1113 | err = mei_wd_stop(dev, true); | 1131 | err = mei_wd_stop(dev); |
1114 | /* Set new mei state */ | 1132 | /* Set new mei state */ |
1115 | if (dev->mei_state == MEI_ENABLED || | 1133 | if (dev->dev_state == MEI_DEV_ENABLED || |
1116 | dev->mei_state == MEI_RECOVERING_FROM_RESET) { | 1134 | dev->dev_state == MEI_DEV_RECOVERING_FROM_RESET) { |
1117 | dev->mei_state = MEI_POWER_DOWN; | 1135 | dev->dev_state = MEI_DEV_POWER_DOWN; |
1118 | mei_reset(dev, 0); | 1136 | mei_reset(dev, 0); |
1119 | } | 1137 | } |
1120 | mutex_unlock(&dev->device_lock); | 1138 | mutex_unlock(&dev->device_lock); |
@@ -1142,12 +1160,12 @@ static int mei_pci_resume(struct device *device) | |||
1142 | err = request_threaded_irq(pdev->irq, | 1160 | err = request_threaded_irq(pdev->irq, |
1143 | NULL, | 1161 | NULL, |
1144 | mei_interrupt_thread_handler, | 1162 | mei_interrupt_thread_handler, |
1145 | IRQF_ONESHOT, mei_driver_name, dev); | 1163 | IRQF_ONESHOT, KBUILD_MODNAME, dev); |
1146 | else | 1164 | else |
1147 | err = request_threaded_irq(pdev->irq, | 1165 | err = request_threaded_irq(pdev->irq, |
1148 | mei_interrupt_quick_handler, | 1166 | mei_interrupt_quick_handler, |
1149 | mei_interrupt_thread_handler, | 1167 | mei_interrupt_thread_handler, |
1150 | IRQF_SHARED, mei_driver_name, dev); | 1168 | IRQF_SHARED, KBUILD_MODNAME, dev); |
1151 | 1169 | ||
1152 | if (err) { | 1170 | if (err) { |
1153 | dev_err(&pdev->dev, "request_threaded_irq failed: irq = %d.\n", | 1171 | dev_err(&pdev->dev, "request_threaded_irq failed: irq = %d.\n", |
@@ -1156,7 +1174,7 @@ static int mei_pci_resume(struct device *device) | |||
1156 | } | 1174 | } |
1157 | 1175 | ||
1158 | mutex_lock(&dev->device_lock); | 1176 | mutex_lock(&dev->device_lock); |
1159 | dev->mei_state = MEI_POWER_UP; | 1177 | dev->dev_state = MEI_DEV_POWER_UP; |
1160 | mei_reset(dev, 1); | 1178 | mei_reset(dev, 1); |
1161 | mutex_unlock(&dev->device_lock); | 1179 | mutex_unlock(&dev->device_lock); |
1162 | 1180 | ||
@@ -1174,7 +1192,7 @@ static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume); | |||
1174 | * PCI driver structure | 1192 | * PCI driver structure |
1175 | */ | 1193 | */ |
1176 | static struct pci_driver mei_driver = { | 1194 | static struct pci_driver mei_driver = { |
1177 | .name = mei_driver_name, | 1195 | .name = KBUILD_MODNAME, |
1178 | .id_table = mei_pci_tbl, | 1196 | .id_table = mei_pci_tbl, |
1179 | .probe = mei_probe, | 1197 | .probe = mei_probe, |
1180 | .remove = __devexit_p(mei_remove), | 1198 | .remove = __devexit_p(mei_remove), |
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index d61c4ddfc80c..adb35fb9281c 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -25,18 +25,20 @@ | |||
25 | /* | 25 | /* |
26 | * watch dog definition | 26 | * watch dog definition |
27 | */ | 27 | */ |
28 | #define MEI_WATCHDOG_DATA_SIZE 16 | 28 | #define MEI_WD_HDR_SIZE 4 |
29 | #define MEI_START_WD_DATA_SIZE 20 | 29 | #define MEI_WD_STOP_MSG_SIZE MEI_WD_HDR_SIZE |
30 | #define MEI_WD_PARAMS_SIZE 4 | 30 | #define MEI_WD_START_MSG_SIZE (MEI_WD_HDR_SIZE + 16) |
31 | |||
32 | #define MEI_WD_DEFAULT_TIMEOUT 120 /* seconds */ | ||
33 | #define MEI_WD_MIN_TIMEOUT 120 /* seconds */ | ||
34 | #define MEI_WD_MAX_TIMEOUT 65535 /* seconds */ | ||
35 | |||
36 | #define MEI_WD_STOP_TIMEOUT 10 /* msecs */ | ||
37 | |||
31 | #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) | 38 | #define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0) |
32 | 39 | ||
33 | #define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32)) | 40 | #define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32)) |
34 | 41 | ||
35 | /* | ||
36 | * MEI PCI Device object | ||
37 | */ | ||
38 | extern struct pci_dev *mei_device; | ||
39 | |||
40 | 42 | ||
41 | /* | 43 | /* |
42 | * AMTHI Client UUID | 44 | * AMTHI Client UUID |
@@ -54,19 +56,21 @@ extern const uuid_le mei_wd_guid; | |||
54 | extern const u8 mei_wd_state_independence_msg[3][4]; | 56 | extern const u8 mei_wd_state_independence_msg[3][4]; |
55 | 57 | ||
56 | /* | 58 | /* |
59 | * Number of Maximum MEI Clients | ||
60 | */ | ||
61 | #define MEI_CLIENTS_MAX 256 | ||
62 | |||
63 | /* | ||
57 | * Number of File descriptors/handles | 64 | * Number of File descriptors/handles |
58 | * that can be opened to the driver. | 65 | * that can be opened to the driver. |
59 | * | 66 | * |
60 | * Limit to 253: 255 Total Clients | 67 | * Limit to 253: 256 Total Clients |
68 | * minus internal client for MEI Bus Messags | ||
61 | * minus internal client for AMTHI | 69 | * minus internal client for AMTHI |
62 | * minus internal client for Watchdog | 70 | * minus internal client for Watchdog |
63 | */ | 71 | */ |
64 | #define MEI_MAX_OPEN_HANDLE_COUNT 253 | 72 | #define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 3) |
65 | 73 | ||
66 | /* | ||
67 | * Number of Maximum MEI Clients | ||
68 | */ | ||
69 | #define MEI_CLIENTS_MAX 255 | ||
70 | 74 | ||
71 | /* File state */ | 75 | /* File state */ |
72 | enum file_state { | 76 | enum file_state { |
@@ -78,17 +82,19 @@ enum file_state { | |||
78 | }; | 82 | }; |
79 | 83 | ||
80 | /* MEI device states */ | 84 | /* MEI device states */ |
81 | enum mei_states { | 85 | enum mei_dev_state { |
82 | MEI_INITIALIZING = 0, | 86 | MEI_DEV_INITIALIZING = 0, |
83 | MEI_INIT_CLIENTS, | 87 | MEI_DEV_INIT_CLIENTS, |
84 | MEI_ENABLED, | 88 | MEI_DEV_ENABLED, |
85 | MEI_RESETING, | 89 | MEI_DEV_RESETING, |
86 | MEI_DISABLED, | 90 | MEI_DEV_DISABLED, |
87 | MEI_RECOVERING_FROM_RESET, | 91 | MEI_DEV_RECOVERING_FROM_RESET, |
88 | MEI_POWER_DOWN, | 92 | MEI_DEV_POWER_DOWN, |
89 | MEI_POWER_UP | 93 | MEI_DEV_POWER_UP |
90 | }; | 94 | }; |
91 | 95 | ||
96 | const char *mei_dev_state_str(int state); | ||
97 | |||
92 | /* init clients states*/ | 98 | /* init clients states*/ |
93 | enum mei_init_clients_states { | 99 | enum mei_init_clients_states { |
94 | MEI_START_MESSAGE = 0, | 100 | MEI_START_MESSAGE = 0, |
@@ -113,6 +119,12 @@ enum mei_file_transaction_states { | |||
113 | MEI_READ_COMPLETE | 119 | MEI_READ_COMPLETE |
114 | }; | 120 | }; |
115 | 121 | ||
122 | enum mei_wd_states { | ||
123 | MEI_WD_IDLE, | ||
124 | MEI_WD_RUNNING, | ||
125 | MEI_WD_STOPPING, | ||
126 | }; | ||
127 | |||
116 | /* MEI CB */ | 128 | /* MEI CB */ |
117 | enum mei_cb_major_types { | 129 | enum mei_cb_major_types { |
118 | MEI_READ = 0, | 130 | MEI_READ = 0, |
@@ -128,7 +140,7 @@ enum mei_cb_major_types { | |||
128 | struct mei_message_data { | 140 | struct mei_message_data { |
129 | u32 size; | 141 | u32 size; |
130 | unsigned char *data; | 142 | unsigned char *data; |
131 | } __packed; | 143 | }; |
132 | 144 | ||
133 | 145 | ||
134 | struct mei_cl_cb { | 146 | struct mei_cl_cb { |
@@ -218,10 +230,9 @@ struct mei_device { | |||
218 | /* | 230 | /* |
219 | * mei device states | 231 | * mei device states |
220 | */ | 232 | */ |
221 | enum mei_states mei_state; | 233 | enum mei_dev_state dev_state; |
222 | enum mei_init_clients_states init_clients_state; | 234 | enum mei_init_clients_states init_clients_state; |
223 | u16 init_clients_timer; | 235 | u16 init_clients_timer; |
224 | bool stop; | ||
225 | bool need_reset; | 236 | bool need_reset; |
226 | 237 | ||
227 | u32 extra_write_index; | 238 | u32 extra_write_index; |
@@ -241,12 +252,11 @@ struct mei_device { | |||
241 | bool mei_host_buffer_is_empty; | 252 | bool mei_host_buffer_is_empty; |
242 | 253 | ||
243 | struct mei_cl wd_cl; | 254 | struct mei_cl wd_cl; |
255 | enum mei_wd_states wd_state; | ||
244 | bool wd_interface_reg; | 256 | bool wd_interface_reg; |
245 | bool wd_pending; | 257 | bool wd_pending; |
246 | bool wd_stopped; | 258 | u16 wd_timeout; |
247 | bool wd_bypass; /* if false, don't refresh watchdog ME client */ | 259 | unsigned char wd_data[MEI_WD_START_MSG_SIZE]; |
248 | u16 wd_timeout; /* seconds ((wd_data[1] << 8) + wd_data[0]) */ | ||
249 | unsigned char wd_data[MEI_START_WD_DATA_SIZE]; | ||
250 | 260 | ||
251 | 261 | ||
252 | struct file *iamthif_file_object; | 262 | struct file *iamthif_file_object; |
@@ -279,9 +289,10 @@ void mei_host_init_iamthif(struct mei_device *dev); | |||
279 | void mei_allocate_me_clients_storage(struct mei_device *dev); | 289 | void mei_allocate_me_clients_storage(struct mei_device *dev); |
280 | 290 | ||
281 | 291 | ||
282 | u8 mei_find_me_client_update_filext(struct mei_device *dev, | 292 | int mei_me_cl_update_filext(struct mei_device *dev, struct mei_cl *cl, |
283 | struct mei_cl *priv, | 293 | const uuid_le *cguid, u8 host_client_id); |
284 | const uuid_le *cguid, u8 client_id); | 294 | int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *cuuid); |
295 | int mei_me_cl_by_id(struct mei_device *dev, u8 client_id); | ||
285 | 296 | ||
286 | /* | 297 | /* |
287 | * MEI IO List Functions | 298 | * MEI IO List Functions |
@@ -348,7 +359,6 @@ void mei_run_next_iamthif_cmd(struct mei_device *dev); | |||
348 | 359 | ||
349 | void mei_free_cb_private(struct mei_cl_cb *priv_cb); | 360 | void mei_free_cb_private(struct mei_cl_cb *priv_cb); |
350 | 361 | ||
351 | int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid); | ||
352 | 362 | ||
353 | /* | 363 | /* |
354 | * Register Access Function | 364 | * Register Access Function |
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c index 5133fd77b91c..d96c537f046f 100644 --- a/drivers/misc/mei/wd.c +++ b/drivers/misc/mei/wd.c | |||
@@ -48,8 +48,8 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89, | |||
48 | static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) | 48 | static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout) |
49 | { | 49 | { |
50 | dev_dbg(&dev->pdev->dev, "wd: set timeout=%d.\n", timeout); | 50 | dev_dbg(&dev->pdev->dev, "wd: set timeout=%d.\n", timeout); |
51 | memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE); | 51 | memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE); |
52 | memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE, &timeout, sizeof(u16)); | 52 | memcpy(dev->wd_data + MEI_WD_HDR_SIZE, &timeout, sizeof(u16)); |
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
@@ -66,10 +66,11 @@ int mei_wd_host_init(struct mei_device *dev) | |||
66 | 66 | ||
67 | /* look for WD client and connect to it */ | 67 | /* look for WD client and connect to it */ |
68 | dev->wd_cl.state = MEI_FILE_DISCONNECTED; | 68 | dev->wd_cl.state = MEI_FILE_DISCONNECTED; |
69 | dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT; | 69 | dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT; |
70 | dev->wd_state = MEI_WD_IDLE; | ||
70 | 71 | ||
71 | /* find ME WD client */ | 72 | /* find ME WD client */ |
72 | mei_find_me_client_update_filext(dev, &dev->wd_cl, | 73 | mei_me_cl_update_filext(dev, &dev->wd_cl, |
73 | &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); | 74 | &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); |
74 | 75 | ||
75 | dev_dbg(&dev->pdev->dev, "wd: check client\n"); | 76 | dev_dbg(&dev->pdev->dev, "wd: check client\n"); |
@@ -108,10 +109,10 @@ int mei_wd_send(struct mei_device *dev) | |||
108 | mei_hdr->msg_complete = 1; | 109 | mei_hdr->msg_complete = 1; |
109 | mei_hdr->reserved = 0; | 110 | mei_hdr->reserved = 0; |
110 | 111 | ||
111 | if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE)) | 112 | if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_HDR_SIZE)) |
112 | mei_hdr->length = MEI_START_WD_DATA_SIZE; | 113 | mei_hdr->length = MEI_WD_START_MSG_SIZE; |
113 | else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE)) | 114 | else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_HDR_SIZE)) |
114 | mei_hdr->length = MEI_WD_PARAMS_SIZE; | 115 | mei_hdr->length = MEI_WD_STOP_MSG_SIZE; |
115 | else | 116 | else |
116 | return -EINVAL; | 117 | return -EINVAL; |
117 | 118 | ||
@@ -128,18 +129,17 @@ int mei_wd_send(struct mei_device *dev) | |||
128 | * -EIO when message send fails | 129 | * -EIO when message send fails |
129 | * -EINVAL when invalid message is to be sent | 130 | * -EINVAL when invalid message is to be sent |
130 | */ | 131 | */ |
131 | int mei_wd_stop(struct mei_device *dev, bool preserve) | 132 | int mei_wd_stop(struct mei_device *dev) |
132 | { | 133 | { |
133 | int ret; | 134 | int ret; |
134 | u16 wd_timeout = dev->wd_timeout; | ||
135 | 135 | ||
136 | cancel_delayed_work(&dev->timer_work); | 136 | if (dev->wd_cl.state != MEI_FILE_CONNECTED || |
137 | if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout) | 137 | dev->wd_state != MEI_WD_RUNNING) |
138 | return 0; | 138 | return 0; |
139 | 139 | ||
140 | dev->wd_timeout = 0; | 140 | memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_STOP_MSG_SIZE); |
141 | memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE); | 141 | |
142 | dev->stop = true; | 142 | dev->wd_state = MEI_WD_STOPPING; |
143 | 143 | ||
144 | ret = mei_flow_ctrl_creds(dev, &dev->wd_cl); | 144 | ret = mei_flow_ctrl_creds(dev, &dev->wd_cl); |
145 | if (ret < 0) | 145 | if (ret < 0) |
@@ -161,13 +161,14 @@ int mei_wd_stop(struct mei_device *dev, bool preserve) | |||
161 | } else { | 161 | } else { |
162 | dev->wd_pending = true; | 162 | dev->wd_pending = true; |
163 | } | 163 | } |
164 | dev->wd_stopped = false; | 164 | |
165 | mutex_unlock(&dev->device_lock); | 165 | mutex_unlock(&dev->device_lock); |
166 | 166 | ||
167 | ret = wait_event_interruptible_timeout(dev->wait_stop_wd, | 167 | ret = wait_event_interruptible_timeout(dev->wait_stop_wd, |
168 | dev->wd_stopped, 10 * HZ); | 168 | dev->wd_state == MEI_WD_IDLE, |
169 | msecs_to_jiffies(MEI_WD_STOP_TIMEOUT)); | ||
169 | mutex_lock(&dev->device_lock); | 170 | mutex_lock(&dev->device_lock); |
170 | if (dev->wd_stopped) { | 171 | if (dev->wd_state == MEI_WD_IDLE) { |
171 | dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret); | 172 | dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret); |
172 | ret = 0; | 173 | ret = 0; |
173 | } else { | 174 | } else { |
@@ -177,9 +178,6 @@ int mei_wd_stop(struct mei_device *dev, bool preserve) | |||
177 | "wd: stop failed to complete ret=%d.\n", ret); | 178 | "wd: stop failed to complete ret=%d.\n", ret); |
178 | } | 179 | } |
179 | 180 | ||
180 | if (preserve) | ||
181 | dev->wd_timeout = wd_timeout; | ||
182 | |||
183 | out: | 181 | out: |
184 | return ret; | 182 | return ret; |
185 | } | 183 | } |
@@ -196,16 +194,16 @@ static int mei_wd_ops_start(struct watchdog_device *wd_dev) | |||
196 | int err = -ENODEV; | 194 | int err = -ENODEV; |
197 | struct mei_device *dev; | 195 | struct mei_device *dev; |
198 | 196 | ||
199 | dev = pci_get_drvdata(mei_device); | 197 | dev = watchdog_get_drvdata(wd_dev); |
200 | if (!dev) | 198 | if (!dev) |
201 | return -ENODEV; | 199 | return -ENODEV; |
202 | 200 | ||
203 | mutex_lock(&dev->device_lock); | 201 | mutex_lock(&dev->device_lock); |
204 | 202 | ||
205 | if (dev->mei_state != MEI_ENABLED) { | 203 | if (dev->dev_state != MEI_DEV_ENABLED) { |
206 | dev_dbg(&dev->pdev->dev, | 204 | dev_dbg(&dev->pdev->dev, |
207 | "wd: mei_state != MEI_ENABLED mei_state = %d\n", | 205 | "wd: dev_state != MEI_DEV_ENABLED dev_state = %s\n", |
208 | dev->mei_state); | 206 | mei_dev_state_str(dev->dev_state)); |
209 | goto end_unlock; | 207 | goto end_unlock; |
210 | } | 208 | } |
211 | 209 | ||
@@ -233,13 +231,13 @@ end_unlock: | |||
233 | static int mei_wd_ops_stop(struct watchdog_device *wd_dev) | 231 | static int mei_wd_ops_stop(struct watchdog_device *wd_dev) |
234 | { | 232 | { |
235 | struct mei_device *dev; | 233 | struct mei_device *dev; |
236 | dev = pci_get_drvdata(mei_device); | ||
237 | 234 | ||
235 | dev = watchdog_get_drvdata(wd_dev); | ||
238 | if (!dev) | 236 | if (!dev) |
239 | return -ENODEV; | 237 | return -ENODEV; |
240 | 238 | ||
241 | mutex_lock(&dev->device_lock); | 239 | mutex_lock(&dev->device_lock); |
242 | mei_wd_stop(dev, false); | 240 | mei_wd_stop(dev); |
243 | mutex_unlock(&dev->device_lock); | 241 | mutex_unlock(&dev->device_lock); |
244 | 242 | ||
245 | return 0; | 243 | return 0; |
@@ -256,8 +254,8 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) | |||
256 | { | 254 | { |
257 | int ret = 0; | 255 | int ret = 0; |
258 | struct mei_device *dev; | 256 | struct mei_device *dev; |
259 | dev = pci_get_drvdata(mei_device); | ||
260 | 257 | ||
258 | dev = watchdog_get_drvdata(wd_dev); | ||
261 | if (!dev) | 259 | if (!dev) |
262 | return -ENODEV; | 260 | return -ENODEV; |
263 | 261 | ||
@@ -269,6 +267,8 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) | |||
269 | goto end; | 267 | goto end; |
270 | } | 268 | } |
271 | 269 | ||
270 | dev->wd_state = MEI_WD_RUNNING; | ||
271 | |||
272 | /* Check if we can send the ping to HW*/ | 272 | /* Check if we can send the ping to HW*/ |
273 | if (dev->mei_host_buffer_is_empty && | 273 | if (dev->mei_host_buffer_is_empty && |
274 | mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { | 274 | mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) { |
@@ -309,13 +309,13 @@ end: | |||
309 | static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout) | 309 | static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout) |
310 | { | 310 | { |
311 | struct mei_device *dev; | 311 | struct mei_device *dev; |
312 | dev = pci_get_drvdata(mei_device); | ||
313 | 312 | ||
313 | dev = watchdog_get_drvdata(wd_dev); | ||
314 | if (!dev) | 314 | if (!dev) |
315 | return -ENODEV; | 315 | return -ENODEV; |
316 | 316 | ||
317 | /* Check Timeout value */ | 317 | /* Check Timeout value */ |
318 | if (timeout < AMT_WD_MIN_TIMEOUT || timeout > AMT_WD_MAX_TIMEOUT) | 318 | if (timeout < MEI_WD_MIN_TIMEOUT || timeout > MEI_WD_MAX_TIMEOUT) |
319 | return -EINVAL; | 319 | return -EINVAL; |
320 | 320 | ||
321 | mutex_lock(&dev->device_lock); | 321 | mutex_lock(&dev->device_lock); |
@@ -341,37 +341,42 @@ static const struct watchdog_ops wd_ops = { | |||
341 | }; | 341 | }; |
342 | static const struct watchdog_info wd_info = { | 342 | static const struct watchdog_info wd_info = { |
343 | .identity = INTEL_AMT_WATCHDOG_ID, | 343 | .identity = INTEL_AMT_WATCHDOG_ID, |
344 | .options = WDIOF_KEEPALIVEPING | WDIOF_ALARMONLY, | 344 | .options = WDIOF_KEEPALIVEPING | |
345 | WDIOF_SETTIMEOUT | | ||
346 | WDIOF_ALARMONLY, | ||
345 | }; | 347 | }; |
346 | 348 | ||
347 | static struct watchdog_device amt_wd_dev = { | 349 | static struct watchdog_device amt_wd_dev = { |
348 | .info = &wd_info, | 350 | .info = &wd_info, |
349 | .ops = &wd_ops, | 351 | .ops = &wd_ops, |
350 | .timeout = AMT_WD_DEFAULT_TIMEOUT, | 352 | .timeout = MEI_WD_DEFAULT_TIMEOUT, |
351 | .min_timeout = AMT_WD_MIN_TIMEOUT, | 353 | .min_timeout = MEI_WD_MIN_TIMEOUT, |
352 | .max_timeout = AMT_WD_MAX_TIMEOUT, | 354 | .max_timeout = MEI_WD_MAX_TIMEOUT, |
353 | }; | 355 | }; |
354 | 356 | ||
355 | 357 | ||
356 | void mei_watchdog_register(struct mei_device *dev) | 358 | void mei_watchdog_register(struct mei_device *dev) |
357 | { | 359 | { |
358 | dev_dbg(&dev->pdev->dev, "dev->wd_timeout =%d.\n", dev->wd_timeout); | ||
359 | |||
360 | if (watchdog_register_device(&amt_wd_dev)) { | 360 | if (watchdog_register_device(&amt_wd_dev)) { |
361 | dev_err(&dev->pdev->dev, | 361 | dev_err(&dev->pdev->dev, |
362 | "wd: unable to register watchdog device.\n"); | 362 | "wd: unable to register watchdog device.\n"); |
363 | dev->wd_interface_reg = false; | 363 | dev->wd_interface_reg = false; |
364 | } else { | 364 | return; |
365 | dev_dbg(&dev->pdev->dev, | ||
366 | "wd: successfully register watchdog interface.\n"); | ||
367 | dev->wd_interface_reg = true; | ||
368 | } | 365 | } |
366 | |||
367 | dev_dbg(&dev->pdev->dev, | ||
368 | "wd: successfully register watchdog interface.\n"); | ||
369 | dev->wd_interface_reg = true; | ||
370 | watchdog_set_drvdata(&amt_wd_dev, dev); | ||
369 | } | 371 | } |
370 | 372 | ||
371 | void mei_watchdog_unregister(struct mei_device *dev) | 373 | void mei_watchdog_unregister(struct mei_device *dev) |
372 | { | 374 | { |
373 | if (dev->wd_interface_reg) | 375 | if (!dev->wd_interface_reg) |
374 | watchdog_unregister_device(&amt_wd_dev); | 376 | return; |
377 | |||
378 | watchdog_set_drvdata(&amt_wd_dev, NULL); | ||
379 | watchdog_unregister_device(&amt_wd_dev); | ||
375 | dev->wd_interface_reg = false; | 380 | dev->wd_interface_reg = false; |
376 | } | 381 | } |
377 | 382 | ||
diff --git a/drivers/misc/pch_phub.c b/drivers/misc/pch_phub.c index 9fbcacd703d5..c9f20dae1855 100644 --- a/drivers/misc/pch_phub.c +++ b/drivers/misc/pch_phub.c | |||
@@ -699,7 +699,7 @@ static int __devinit pch_phub_probe(struct pci_dev *pdev, | |||
699 | chip->pch_phub_base_address = pci_iomap(pdev, 1, 0); | 699 | chip->pch_phub_base_address = pci_iomap(pdev, 1, 0); |
700 | 700 | ||
701 | 701 | ||
702 | if (chip->pch_phub_base_address == 0) { | 702 | if (chip->pch_phub_base_address == NULL) { |
703 | dev_err(&pdev->dev, "%s : pci_iomap FAILED", __func__); | 703 | dev_err(&pdev->dev, "%s : pci_iomap FAILED", __func__); |
704 | ret = -ENOMEM; | 704 | ret = -ENOMEM; |
705 | goto err_pci_iomap; | 705 | goto err_pci_iomap; |
@@ -893,18 +893,7 @@ static struct pci_driver pch_phub_driver = { | |||
893 | .resume = pch_phub_resume | 893 | .resume = pch_phub_resume |
894 | }; | 894 | }; |
895 | 895 | ||
896 | static int __init pch_phub_pci_init(void) | 896 | module_pci_driver(pch_phub_driver); |
897 | { | ||
898 | return pci_register_driver(&pch_phub_driver); | ||
899 | } | ||
900 | |||
901 | static void __exit pch_phub_pci_exit(void) | ||
902 | { | ||
903 | pci_unregister_driver(&pch_phub_driver); | ||
904 | } | ||
905 | |||
906 | module_init(pch_phub_pci_init); | ||
907 | module_exit(pch_phub_pci_exit); | ||
908 | 897 | ||
909 | MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7223) PHUB"); | 898 | MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semiconductor IOH(ML7213/ML7223) PHUB"); |
910 | MODULE_LICENSE("GPL"); | 899 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c index b7eb545394b1..4999b34b7a60 100644 --- a/drivers/misc/pti.c +++ b/drivers/misc/pti.c | |||
@@ -60,7 +60,7 @@ struct pti_tty { | |||
60 | }; | 60 | }; |
61 | 61 | ||
62 | struct pti_dev { | 62 | struct pti_dev { |
63 | struct tty_port port; | 63 | struct tty_port port[PTITTY_MINOR_NUM]; |
64 | unsigned long pti_addr; | 64 | unsigned long pti_addr; |
65 | unsigned long aperture_base; | 65 | unsigned long aperture_base; |
66 | void __iomem *pti_ioaddr; | 66 | void __iomem *pti_ioaddr; |
@@ -76,7 +76,7 @@ struct pti_dev { | |||
76 | */ | 76 | */ |
77 | static DEFINE_MUTEX(alloclock); | 77 | static DEFINE_MUTEX(alloclock); |
78 | 78 | ||
79 | static struct pci_device_id pci_ids[] __devinitconst = { | 79 | static const struct pci_device_id pci_ids[] __devinitconst = { |
80 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x82B)}, | 80 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x82B)}, |
81 | {0} | 81 | {0} |
82 | }; | 82 | }; |
@@ -393,25 +393,6 @@ void pti_writedata(struct pti_masterchannel *mc, u8 *buf, int count) | |||
393 | } | 393 | } |
394 | EXPORT_SYMBOL_GPL(pti_writedata); | 394 | EXPORT_SYMBOL_GPL(pti_writedata); |
395 | 395 | ||
396 | /** | ||
397 | * pti_pci_remove()- Driver exit method to remove PTI from | ||
398 | * PCI bus. | ||
399 | * @pdev: variable containing pci info of PTI. | ||
400 | */ | ||
401 | static void __devexit pti_pci_remove(struct pci_dev *pdev) | ||
402 | { | ||
403 | struct pti_dev *drv_data; | ||
404 | |||
405 | drv_data = pci_get_drvdata(pdev); | ||
406 | if (drv_data != NULL) { | ||
407 | pci_iounmap(pdev, drv_data->pti_ioaddr); | ||
408 | pci_set_drvdata(pdev, NULL); | ||
409 | kfree(drv_data); | ||
410 | pci_release_region(pdev, 1); | ||
411 | pci_disable_device(pdev); | ||
412 | } | ||
413 | } | ||
414 | |||
415 | /* | 396 | /* |
416 | * for the tty_driver_*() basic function descriptions, see tty_driver.h. | 397 | * for the tty_driver_*() basic function descriptions, see tty_driver.h. |
417 | * Specific header comments made for PTI-related specifics. | 398 | * Specific header comments made for PTI-related specifics. |
@@ -446,7 +427,7 @@ static int pti_tty_driver_open(struct tty_struct *tty, struct file *filp) | |||
446 | * also removes a locking requirement for the actual write | 427 | * also removes a locking requirement for the actual write |
447 | * procedure. | 428 | * procedure. |
448 | */ | 429 | */ |
449 | return tty_port_open(&drv_data->port, tty, filp); | 430 | return tty_port_open(tty->port, tty, filp); |
450 | } | 431 | } |
451 | 432 | ||
452 | /** | 433 | /** |
@@ -462,7 +443,7 @@ static int pti_tty_driver_open(struct tty_struct *tty, struct file *filp) | |||
462 | */ | 443 | */ |
463 | static void pti_tty_driver_close(struct tty_struct *tty, struct file *filp) | 444 | static void pti_tty_driver_close(struct tty_struct *tty, struct file *filp) |
464 | { | 445 | { |
465 | tty_port_close(&drv_data->port, tty, filp); | 446 | tty_port_close(tty->port, tty, filp); |
466 | } | 447 | } |
467 | 448 | ||
468 | /** | 449 | /** |
@@ -818,6 +799,7 @@ static const struct tty_port_operations tty_port_ops = { | |||
818 | static int __devinit pti_pci_probe(struct pci_dev *pdev, | 799 | static int __devinit pti_pci_probe(struct pci_dev *pdev, |
819 | const struct pci_device_id *ent) | 800 | const struct pci_device_id *ent) |
820 | { | 801 | { |
802 | unsigned int a; | ||
821 | int retval = -EINVAL; | 803 | int retval = -EINVAL; |
822 | int pci_bar = 1; | 804 | int pci_bar = 1; |
823 | 805 | ||
@@ -830,7 +812,7 @@ static int __devinit pti_pci_probe(struct pci_dev *pdev, | |||
830 | __func__, __LINE__); | 812 | __func__, __LINE__); |
831 | pr_err("%s(%d): Error value returned: %d\n", | 813 | pr_err("%s(%d): Error value returned: %d\n", |
832 | __func__, __LINE__, retval); | 814 | __func__, __LINE__, retval); |
833 | return retval; | 815 | goto err; |
834 | } | 816 | } |
835 | 817 | ||
836 | retval = pci_enable_device(pdev); | 818 | retval = pci_enable_device(pdev); |
@@ -838,17 +820,16 @@ static int __devinit pti_pci_probe(struct pci_dev *pdev, | |||
838 | dev_err(&pdev->dev, | 820 | dev_err(&pdev->dev, |
839 | "%s: pci_enable_device() returned error %d\n", | 821 | "%s: pci_enable_device() returned error %d\n", |
840 | __func__, retval); | 822 | __func__, retval); |
841 | return retval; | 823 | goto err_unreg_misc; |
842 | } | 824 | } |
843 | 825 | ||
844 | drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); | 826 | drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); |
845 | |||
846 | if (drv_data == NULL) { | 827 | if (drv_data == NULL) { |
847 | retval = -ENOMEM; | 828 | retval = -ENOMEM; |
848 | dev_err(&pdev->dev, | 829 | dev_err(&pdev->dev, |
849 | "%s(%d): kmalloc() returned NULL memory.\n", | 830 | "%s(%d): kmalloc() returned NULL memory.\n", |
850 | __func__, __LINE__); | 831 | __func__, __LINE__); |
851 | return retval; | 832 | goto err_disable_pci; |
852 | } | 833 | } |
853 | drv_data->pti_addr = pci_resource_start(pdev, pci_bar); | 834 | drv_data->pti_addr = pci_resource_start(pdev, pci_bar); |
854 | 835 | ||
@@ -857,33 +838,65 @@ static int __devinit pti_pci_probe(struct pci_dev *pdev, | |||
857 | dev_err(&pdev->dev, | 838 | dev_err(&pdev->dev, |
858 | "%s(%d): pci_request_region() returned error %d\n", | 839 | "%s(%d): pci_request_region() returned error %d\n", |
859 | __func__, __LINE__, retval); | 840 | __func__, __LINE__, retval); |
860 | kfree(drv_data); | 841 | goto err_free_dd; |
861 | return retval; | ||
862 | } | 842 | } |
863 | drv_data->aperture_base = drv_data->pti_addr+APERTURE_14; | 843 | drv_data->aperture_base = drv_data->pti_addr+APERTURE_14; |
864 | drv_data->pti_ioaddr = | 844 | drv_data->pti_ioaddr = |
865 | ioremap_nocache((u32)drv_data->aperture_base, | 845 | ioremap_nocache((u32)drv_data->aperture_base, |
866 | APERTURE_LEN); | 846 | APERTURE_LEN); |
867 | if (!drv_data->pti_ioaddr) { | 847 | if (!drv_data->pti_ioaddr) { |
868 | pci_release_region(pdev, pci_bar); | ||
869 | retval = -ENOMEM; | 848 | retval = -ENOMEM; |
870 | kfree(drv_data); | 849 | goto err_rel_reg; |
871 | return retval; | ||
872 | } | 850 | } |
873 | 851 | ||
874 | pci_set_drvdata(pdev, drv_data); | 852 | pci_set_drvdata(pdev, drv_data); |
875 | 853 | ||
876 | tty_port_init(&drv_data->port); | 854 | for (a = 0; a < PTITTY_MINOR_NUM; a++) { |
877 | drv_data->port.ops = &tty_port_ops; | 855 | struct tty_port *port = &drv_data->port[a]; |
856 | tty_port_init(port); | ||
857 | port->ops = &tty_port_ops; | ||
878 | 858 | ||
879 | tty_register_device(pti_tty_driver, 0, &pdev->dev); | 859 | tty_port_register_device(port, pti_tty_driver, a, &pdev->dev); |
880 | tty_register_device(pti_tty_driver, 1, &pdev->dev); | 860 | } |
881 | 861 | ||
882 | register_console(&pti_console); | 862 | register_console(&pti_console); |
883 | 863 | ||
864 | return 0; | ||
865 | err_rel_reg: | ||
866 | pci_release_region(pdev, pci_bar); | ||
867 | err_free_dd: | ||
868 | kfree(drv_data); | ||
869 | err_disable_pci: | ||
870 | pci_disable_device(pdev); | ||
871 | err_unreg_misc: | ||
872 | misc_deregister(&pti_char_driver); | ||
873 | err: | ||
884 | return retval; | 874 | return retval; |
885 | } | 875 | } |
886 | 876 | ||
877 | /** | ||
878 | * pti_pci_remove()- Driver exit method to remove PTI from | ||
879 | * PCI bus. | ||
880 | * @pdev: variable containing pci info of PTI. | ||
881 | */ | ||
882 | static void __devexit pti_pci_remove(struct pci_dev *pdev) | ||
883 | { | ||
884 | struct pti_dev *drv_data = pci_get_drvdata(pdev); | ||
885 | |||
886 | unregister_console(&pti_console); | ||
887 | |||
888 | tty_unregister_device(pti_tty_driver, 0); | ||
889 | tty_unregister_device(pti_tty_driver, 1); | ||
890 | |||
891 | iounmap(drv_data->pti_ioaddr); | ||
892 | pci_set_drvdata(pdev, NULL); | ||
893 | kfree(drv_data); | ||
894 | pci_release_region(pdev, 1); | ||
895 | pci_disable_device(pdev); | ||
896 | |||
897 | misc_deregister(&pti_char_driver); | ||
898 | } | ||
899 | |||
887 | static struct pci_driver pti_pci_driver = { | 900 | static struct pci_driver pti_pci_driver = { |
888 | .name = PCINAME, | 901 | .name = PCINAME, |
889 | .id_table = pci_ids, | 902 | .id_table = pci_ids, |
@@ -933,25 +946,24 @@ static int __init pti_init(void) | |||
933 | pr_err("%s(%d): Error value returned: %d\n", | 946 | pr_err("%s(%d): Error value returned: %d\n", |
934 | __func__, __LINE__, retval); | 947 | __func__, __LINE__, retval); |
935 | 948 | ||
936 | pti_tty_driver = NULL; | 949 | goto put_tty; |
937 | return retval; | ||
938 | } | 950 | } |
939 | 951 | ||
940 | retval = pci_register_driver(&pti_pci_driver); | 952 | retval = pci_register_driver(&pti_pci_driver); |
941 | |||
942 | if (retval) { | 953 | if (retval) { |
943 | pr_err("%s(%d): PCI registration failed of pti driver\n", | 954 | pr_err("%s(%d): PCI registration failed of pti driver\n", |
944 | __func__, __LINE__); | 955 | __func__, __LINE__); |
945 | pr_err("%s(%d): Error value returned: %d\n", | 956 | pr_err("%s(%d): Error value returned: %d\n", |
946 | __func__, __LINE__, retval); | 957 | __func__, __LINE__, retval); |
947 | 958 | goto unreg_tty; | |
948 | tty_unregister_driver(pti_tty_driver); | ||
949 | pr_err("%s(%d): Unregistering TTY part of pti driver\n", | ||
950 | __func__, __LINE__); | ||
951 | pti_tty_driver = NULL; | ||
952 | return retval; | ||
953 | } | 959 | } |
954 | 960 | ||
961 | return 0; | ||
962 | unreg_tty: | ||
963 | tty_unregister_driver(pti_tty_driver); | ||
964 | put_tty: | ||
965 | put_tty_driver(pti_tty_driver); | ||
966 | pti_tty_driver = NULL; | ||
955 | return retval; | 967 | return retval; |
956 | } | 968 | } |
957 | 969 | ||
@@ -960,31 +972,9 @@ static int __init pti_init(void) | |||
960 | */ | 972 | */ |
961 | static void __exit pti_exit(void) | 973 | static void __exit pti_exit(void) |
962 | { | 974 | { |
963 | int retval; | 975 | tty_unregister_driver(pti_tty_driver); |
964 | |||
965 | tty_unregister_device(pti_tty_driver, 0); | ||
966 | tty_unregister_device(pti_tty_driver, 1); | ||
967 | |||
968 | retval = tty_unregister_driver(pti_tty_driver); | ||
969 | if (retval) { | ||
970 | pr_err("%s(%d): TTY unregistration failed of pti driver\n", | ||
971 | __func__, __LINE__); | ||
972 | pr_err("%s(%d): Error value returned: %d\n", | ||
973 | __func__, __LINE__, retval); | ||
974 | } | ||
975 | |||
976 | pci_unregister_driver(&pti_pci_driver); | 976 | pci_unregister_driver(&pti_pci_driver); |
977 | 977 | put_tty_driver(pti_tty_driver); | |
978 | retval = misc_deregister(&pti_char_driver); | ||
979 | if (retval) { | ||
980 | pr_err("%s(%d): CHAR unregistration failed of pti driver\n", | ||
981 | __func__, __LINE__); | ||
982 | pr_err("%s(%d): Error value returned: %d\n", | ||
983 | __func__, __LINE__, retval); | ||
984 | } | ||
985 | |||
986 | unregister_console(&pti_console); | ||
987 | return; | ||
988 | } | 978 | } |
989 | 979 | ||
990 | module_init(pti_init); | 980 | module_init(pti_init); |
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c index 87b251ab6ec5..b9e2000969f0 100644 --- a/drivers/misc/sgi-xp/xpc_uv.c +++ b/drivers/misc/sgi-xp/xpc_uv.c | |||
@@ -18,6 +18,8 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/cpu.h> | ||
22 | #include <linux/module.h> | ||
21 | #include <linux/err.h> | 23 | #include <linux/err.h> |
22 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
23 | #include <asm/uv/uv_hub.h> | 25 | #include <asm/uv/uv_hub.h> |
@@ -59,6 +61,8 @@ static struct xpc_heartbeat_uv *xpc_heartbeat_uv; | |||
59 | XPC_NOTIFY_MSG_SIZE_UV) | 61 | XPC_NOTIFY_MSG_SIZE_UV) |
60 | #define XPC_NOTIFY_IRQ_NAME "xpc_notify" | 62 | #define XPC_NOTIFY_IRQ_NAME "xpc_notify" |
61 | 63 | ||
64 | static int xpc_mq_node = -1; | ||
65 | |||
62 | static struct xpc_gru_mq_uv *xpc_activate_mq_uv; | 66 | static struct xpc_gru_mq_uv *xpc_activate_mq_uv; |
63 | static struct xpc_gru_mq_uv *xpc_notify_mq_uv; | 67 | static struct xpc_gru_mq_uv *xpc_notify_mq_uv; |
64 | 68 | ||
@@ -109,11 +113,8 @@ xpc_get_gru_mq_irq_uv(struct xpc_gru_mq_uv *mq, int cpu, char *irq_name) | |||
109 | #if defined CONFIG_X86_64 | 113 | #if defined CONFIG_X86_64 |
110 | mq->irq = uv_setup_irq(irq_name, cpu, mq->mmr_blade, mq->mmr_offset, | 114 | mq->irq = uv_setup_irq(irq_name, cpu, mq->mmr_blade, mq->mmr_offset, |
111 | UV_AFFINITY_CPU); | 115 | UV_AFFINITY_CPU); |
112 | if (mq->irq < 0) { | 116 | if (mq->irq < 0) |
113 | dev_err(xpc_part, "uv_setup_irq() returned error=%d\n", | ||
114 | -mq->irq); | ||
115 | return mq->irq; | 117 | return mq->irq; |
116 | } | ||
117 | 118 | ||
118 | mq->mmr_value = uv_read_global_mmr64(mmr_pnode, mq->mmr_offset); | 119 | mq->mmr_value = uv_read_global_mmr64(mmr_pnode, mq->mmr_offset); |
119 | 120 | ||
@@ -238,8 +239,9 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name, | |||
238 | mq->mmr_blade = uv_cpu_to_blade_id(cpu); | 239 | mq->mmr_blade = uv_cpu_to_blade_id(cpu); |
239 | 240 | ||
240 | nid = cpu_to_node(cpu); | 241 | nid = cpu_to_node(cpu); |
241 | page = alloc_pages_exact_node(nid, GFP_KERNEL | __GFP_ZERO | GFP_THISNODE, | 242 | page = alloc_pages_exact_node(nid, |
242 | pg_order); | 243 | GFP_KERNEL | __GFP_ZERO | GFP_THISNODE, |
244 | pg_order); | ||
243 | if (page == NULL) { | 245 | if (page == NULL) { |
244 | dev_err(xpc_part, "xpc_create_gru_mq_uv() failed to alloc %d " | 246 | dev_err(xpc_part, "xpc_create_gru_mq_uv() failed to alloc %d " |
245 | "bytes of memory on nid=%d for GRU mq\n", mq_size, nid); | 247 | "bytes of memory on nid=%d for GRU mq\n", mq_size, nid); |
@@ -1731,9 +1733,50 @@ static struct xpc_arch_operations xpc_arch_ops_uv = { | |||
1731 | .notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_uv, | 1733 | .notify_senders_of_disconnect = xpc_notify_senders_of_disconnect_uv, |
1732 | }; | 1734 | }; |
1733 | 1735 | ||
1736 | static int | ||
1737 | xpc_init_mq_node(int nid) | ||
1738 | { | ||
1739 | int cpu; | ||
1740 | |||
1741 | get_online_cpus(); | ||
1742 | |||
1743 | for_each_cpu(cpu, cpumask_of_node(nid)) { | ||
1744 | xpc_activate_mq_uv = | ||
1745 | xpc_create_gru_mq_uv(XPC_ACTIVATE_MQ_SIZE_UV, nid, | ||
1746 | XPC_ACTIVATE_IRQ_NAME, | ||
1747 | xpc_handle_activate_IRQ_uv); | ||
1748 | if (!IS_ERR(xpc_activate_mq_uv)) | ||
1749 | break; | ||
1750 | } | ||
1751 | if (IS_ERR(xpc_activate_mq_uv)) { | ||
1752 | put_online_cpus(); | ||
1753 | return PTR_ERR(xpc_activate_mq_uv); | ||
1754 | } | ||
1755 | |||
1756 | for_each_cpu(cpu, cpumask_of_node(nid)) { | ||
1757 | xpc_notify_mq_uv = | ||
1758 | xpc_create_gru_mq_uv(XPC_NOTIFY_MQ_SIZE_UV, nid, | ||
1759 | XPC_NOTIFY_IRQ_NAME, | ||
1760 | xpc_handle_notify_IRQ_uv); | ||
1761 | if (!IS_ERR(xpc_notify_mq_uv)) | ||
1762 | break; | ||
1763 | } | ||
1764 | if (IS_ERR(xpc_notify_mq_uv)) { | ||
1765 | xpc_destroy_gru_mq_uv(xpc_activate_mq_uv); | ||
1766 | put_online_cpus(); | ||
1767 | return PTR_ERR(xpc_notify_mq_uv); | ||
1768 | } | ||
1769 | |||
1770 | put_online_cpus(); | ||
1771 | return 0; | ||
1772 | } | ||
1773 | |||
1734 | int | 1774 | int |
1735 | xpc_init_uv(void) | 1775 | xpc_init_uv(void) |
1736 | { | 1776 | { |
1777 | int nid; | ||
1778 | int ret = 0; | ||
1779 | |||
1737 | xpc_arch_ops = xpc_arch_ops_uv; | 1780 | xpc_arch_ops = xpc_arch_ops_uv; |
1738 | 1781 | ||
1739 | if (sizeof(struct xpc_notify_mq_msghdr_uv) > XPC_MSG_HDR_MAX_SIZE) { | 1782 | if (sizeof(struct xpc_notify_mq_msghdr_uv) > XPC_MSG_HDR_MAX_SIZE) { |
@@ -1742,21 +1785,21 @@ xpc_init_uv(void) | |||
1742 | return -E2BIG; | 1785 | return -E2BIG; |
1743 | } | 1786 | } |
1744 | 1787 | ||
1745 | xpc_activate_mq_uv = xpc_create_gru_mq_uv(XPC_ACTIVATE_MQ_SIZE_UV, 0, | 1788 | if (xpc_mq_node < 0) |
1746 | XPC_ACTIVATE_IRQ_NAME, | 1789 | for_each_online_node(nid) { |
1747 | xpc_handle_activate_IRQ_uv); | 1790 | ret = xpc_init_mq_node(nid); |
1748 | if (IS_ERR(xpc_activate_mq_uv)) | ||
1749 | return PTR_ERR(xpc_activate_mq_uv); | ||
1750 | 1791 | ||
1751 | xpc_notify_mq_uv = xpc_create_gru_mq_uv(XPC_NOTIFY_MQ_SIZE_UV, 0, | 1792 | if (!ret) |
1752 | XPC_NOTIFY_IRQ_NAME, | 1793 | break; |
1753 | xpc_handle_notify_IRQ_uv); | 1794 | } |
1754 | if (IS_ERR(xpc_notify_mq_uv)) { | 1795 | else |
1755 | xpc_destroy_gru_mq_uv(xpc_activate_mq_uv); | 1796 | ret = xpc_init_mq_node(xpc_mq_node); |
1756 | return PTR_ERR(xpc_notify_mq_uv); | ||
1757 | } | ||
1758 | 1797 | ||
1759 | return 0; | 1798 | if (ret < 0) |
1799 | dev_err(xpc_part, "xpc_init_mq_node() returned error=%d\n", | ||
1800 | -ret); | ||
1801 | |||
1802 | return ret; | ||
1760 | } | 1803 | } |
1761 | 1804 | ||
1762 | void | 1805 | void |
@@ -1765,3 +1808,6 @@ xpc_exit_uv(void) | |||
1765 | xpc_destroy_gru_mq_uv(xpc_notify_mq_uv); | 1808 | xpc_destroy_gru_mq_uv(xpc_notify_mq_uv); |
1766 | xpc_destroy_gru_mq_uv(xpc_activate_mq_uv); | 1809 | xpc_destroy_gru_mq_uv(xpc_activate_mq_uv); |
1767 | } | 1810 | } |
1811 | |||
1812 | module_param(xpc_mq_node, int, 0); | ||
1813 | MODULE_PARM_DESC(xpc_mq_node, "Node number on which to allocate message queues."); | ||
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index acfaeeb9e01a..46937b107261 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c | |||
@@ -30,11 +30,13 @@ | |||
30 | 30 | ||
31 | #include <linux/ti_wilink_st.h> | 31 | #include <linux/ti_wilink_st.h> |
32 | 32 | ||
33 | extern void st_kim_recv(void *, const unsigned char *, long); | ||
34 | void st_int_recv(void *, const unsigned char *, long); | ||
33 | /* function pointer pointing to either, | 35 | /* function pointer pointing to either, |
34 | * st_kim_recv during registration to receive fw download responses | 36 | * st_kim_recv during registration to receive fw download responses |
35 | * st_int_recv after registration to receive proto stack responses | 37 | * st_int_recv after registration to receive proto stack responses |
36 | */ | 38 | */ |
37 | void (*st_recv) (void*, const unsigned char*, long); | 39 | static void (*st_recv) (void *, const unsigned char *, long); |
38 | 40 | ||
39 | /********************************************************************/ | 41 | /********************************************************************/ |
40 | static void add_channel_to_table(struct st_data_s *st_gdata, | 42 | static void add_channel_to_table(struct st_data_s *st_gdata, |
@@ -100,7 +102,7 @@ int st_int_write(struct st_data_s *st_gdata, | |||
100 | * push the skb received to relevant | 102 | * push the skb received to relevant |
101 | * protocol stacks | 103 | * protocol stacks |
102 | */ | 104 | */ |
103 | void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) | 105 | static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) |
104 | { | 106 | { |
105 | pr_debug(" %s(prot:%d) ", __func__, chnl_id); | 107 | pr_debug(" %s(prot:%d) ", __func__, chnl_id); |
106 | 108 | ||
@@ -140,7 +142,7 @@ void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) | |||
140 | * This function is being called with spin lock held, protocol drivers are | 142 | * This function is being called with spin lock held, protocol drivers are |
141 | * only expected to complete their waits and do nothing more than that. | 143 | * only expected to complete their waits and do nothing more than that. |
142 | */ | 144 | */ |
143 | void st_reg_complete(struct st_data_s *st_gdata, char err) | 145 | static void st_reg_complete(struct st_data_s *st_gdata, char err) |
144 | { | 146 | { |
145 | unsigned char i = 0; | 147 | unsigned char i = 0; |
146 | pr_info(" %s ", __func__); | 148 | pr_info(" %s ", __func__); |
@@ -379,7 +381,7 @@ done: | |||
379 | * completely, return that skb which has the pending data. | 381 | * completely, return that skb which has the pending data. |
380 | * In normal cases, return top of txq. | 382 | * In normal cases, return top of txq. |
381 | */ | 383 | */ |
382 | struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) | 384 | static struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) |
383 | { | 385 | { |
384 | struct sk_buff *returning_skb; | 386 | struct sk_buff *returning_skb; |
385 | 387 | ||
@@ -401,7 +403,7 @@ struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) | |||
401 | * txq and waitq needs protection since the other contexts | 403 | * txq and waitq needs protection since the other contexts |
402 | * may be sending data, waking up chip. | 404 | * may be sending data, waking up chip. |
403 | */ | 405 | */ |
404 | void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) | 406 | static void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) |
405 | { | 407 | { |
406 | unsigned long flags = 0; | 408 | unsigned long flags = 0; |
407 | 409 | ||
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c index 7c14f8fd98db..04a819944f6b 100644 --- a/drivers/misc/ti-st/st_kim.c +++ b/drivers/misc/ti-st/st_kim.c | |||
@@ -63,10 +63,27 @@ static struct platform_device *st_get_plat_device(int id) | |||
63 | * in case of error don't complete so that waiting for proper | 63 | * in case of error don't complete so that waiting for proper |
64 | * response times out | 64 | * response times out |
65 | */ | 65 | */ |
66 | void validate_firmware_response(struct kim_data_s *kim_gdata) | 66 | static void validate_firmware_response(struct kim_data_s *kim_gdata) |
67 | { | 67 | { |
68 | struct sk_buff *skb = kim_gdata->rx_skb; | 68 | struct sk_buff *skb = kim_gdata->rx_skb; |
69 | if (unlikely(skb->data[5] != 0)) { | 69 | if (!skb) |
70 | return; | ||
71 | |||
72 | /* these magic numbers are the position in the response buffer which | ||
73 | * allows us to distinguish whether the response is for the read | ||
74 | * version info. command | ||
75 | */ | ||
76 | if (skb->data[2] == 0x01 && skb->data[3] == 0x01 && | ||
77 | skb->data[4] == 0x10 && skb->data[5] == 0x00) { | ||
78 | /* fw version response */ | ||
79 | memcpy(kim_gdata->resp_buffer, | ||
80 | kim_gdata->rx_skb->data, | ||
81 | kim_gdata->rx_skb->len); | ||
82 | complete_all(&kim_gdata->kim_rcvd); | ||
83 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; | ||
84 | kim_gdata->rx_skb = NULL; | ||
85 | kim_gdata->rx_count = 0; | ||
86 | } else if (unlikely(skb->data[5] != 0)) { | ||
70 | pr_err("no proper response during fw download"); | 87 | pr_err("no proper response during fw download"); |
71 | pr_err("data6 %x", skb->data[5]); | 88 | pr_err("data6 %x", skb->data[5]); |
72 | kfree_skb(skb); | 89 | kfree_skb(skb); |
@@ -119,7 +136,7 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) | |||
119 | * have been observed to come in bursts of different | 136 | * have been observed to come in bursts of different |
120 | * tty_receive and hence the logic | 137 | * tty_receive and hence the logic |
121 | */ | 138 | */ |
122 | void kim_int_recv(struct kim_data_s *kim_gdata, | 139 | static void kim_int_recv(struct kim_data_s *kim_gdata, |
123 | const unsigned char *data, long count) | 140 | const unsigned char *data, long count) |
124 | { | 141 | { |
125 | const unsigned char *ptr; | 142 | const unsigned char *ptr; |
@@ -207,16 +224,19 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) | |||
207 | return -EIO; | 224 | return -EIO; |
208 | } | 225 | } |
209 | 226 | ||
210 | if (!wait_for_completion_timeout | 227 | if (!wait_for_completion_interruptible_timeout( |
211 | (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { | 228 | &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { |
212 | pr_err(" waiting for ver info- timed out "); | 229 | pr_err(" waiting for ver info- timed out "); |
213 | return -ETIMEDOUT; | 230 | return -ETIMEDOUT; |
214 | } | 231 | } |
215 | INIT_COMPLETION(kim_gdata->kim_rcvd); | 232 | INIT_COMPLETION(kim_gdata->kim_rcvd); |
233 | /* the positions 12 & 13 in the response buffer provide with the | ||
234 | * chip, major & minor numbers | ||
235 | */ | ||
216 | 236 | ||
217 | version = | 237 | version = |
218 | MAKEWORD(kim_gdata->resp_buffer[13], | 238 | MAKEWORD(kim_gdata->resp_buffer[12], |
219 | kim_gdata->resp_buffer[14]); | 239 | kim_gdata->resp_buffer[13]); |
220 | chip = (version & 0x7C00) >> 10; | 240 | chip = (version & 0x7C00) >> 10; |
221 | min_ver = (version & 0x007F); | 241 | min_ver = (version & 0x007F); |
222 | maj_ver = (version & 0x0380) >> 7; | 242 | maj_ver = (version & 0x0380) >> 7; |
@@ -236,7 +256,7 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) | |||
236 | return 0; | 256 | return 0; |
237 | } | 257 | } |
238 | 258 | ||
239 | void skip_change_remote_baud(unsigned char **ptr, long *len) | 259 | static void skip_change_remote_baud(unsigned char **ptr, long *len) |
240 | { | 260 | { |
241 | unsigned char *nxt_action, *cur_action; | 261 | unsigned char *nxt_action, *cur_action; |
242 | cur_action = *ptr; | 262 | cur_action = *ptr; |
@@ -370,9 +390,9 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
370 | break; | 390 | break; |
371 | case ACTION_WAIT_EVENT: /* wait */ | 391 | case ACTION_WAIT_EVENT: /* wait */ |
372 | pr_debug("W"); | 392 | pr_debug("W"); |
373 | if (!wait_for_completion_timeout | 393 | if (!wait_for_completion_interruptible_timeout( |
374 | (&kim_gdata->kim_rcvd, | 394 | &kim_gdata->kim_rcvd, |
375 | msecs_to_jiffies(CMD_RESP_TIME))) { | 395 | msecs_to_jiffies(CMD_RESP_TIME))) { |
376 | pr_err("response timeout during fw download "); | 396 | pr_err("response timeout during fw download "); |
377 | /* timed out */ | 397 | /* timed out */ |
378 | release_firmware(kim_gdata->fw_entry); | 398 | release_firmware(kim_gdata->fw_entry); |
@@ -410,16 +430,10 @@ void st_kim_recv(void *disc_data, const unsigned char *data, long count) | |||
410 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; | 430 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
411 | struct kim_data_s *kim_gdata = st_gdata->kim_data; | 431 | struct kim_data_s *kim_gdata = st_gdata->kim_data; |
412 | 432 | ||
413 | /* copy to local buffer */ | 433 | /* proceed to gather all data and distinguish read fw version response |
414 | if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { | 434 | * from other fw responses when data gathering is complete |
415 | /* must be the read_ver_cmd */ | 435 | */ |
416 | memcpy(kim_gdata->resp_buffer, data, count); | 436 | kim_int_recv(kim_gdata, data, count); |
417 | complete_all(&kim_gdata->kim_rcvd); | ||
418 | return; | ||
419 | } else { | ||
420 | kim_int_recv(kim_gdata, data, count); | ||
421 | /* either completes or times out */ | ||
422 | } | ||
423 | return; | 437 | return; |
424 | } | 438 | } |
425 | 439 | ||
@@ -454,11 +468,6 @@ long st_kim_start(void *kim_data) | |||
454 | if (pdata->chip_enable) | 468 | if (pdata->chip_enable) |
455 | pdata->chip_enable(kim_gdata); | 469 | pdata->chip_enable(kim_gdata); |
456 | 470 | ||
457 | /* Configure BT nShutdown to HIGH state */ | ||
458 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); | ||
459 | mdelay(5); /* FIXME: a proper toggle */ | ||
460 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); | ||
461 | mdelay(100); | ||
462 | /* re-initialize the completion */ | 471 | /* re-initialize the completion */ |
463 | INIT_COMPLETION(kim_gdata->ldisc_installed); | 472 | INIT_COMPLETION(kim_gdata->ldisc_installed); |
464 | /* send notification to UIM */ | 473 | /* send notification to UIM */ |
@@ -467,8 +476,8 @@ long st_kim_start(void *kim_data) | |||
467 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, | 476 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, |
468 | NULL, "install"); | 477 | NULL, "install"); |
469 | /* wait for ldisc to be installed */ | 478 | /* wait for ldisc to be installed */ |
470 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, | 479 | err = wait_for_completion_interruptible_timeout( |
471 | msecs_to_jiffies(LDISC_TIME)); | 480 | &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); |
472 | if (!err) { | 481 | if (!err) { |
473 | /* ldisc installation timeout, | 482 | /* ldisc installation timeout, |
474 | * flush uart, power cycle BT_EN */ | 483 | * flush uart, power cycle BT_EN */ |
@@ -500,8 +509,7 @@ long st_kim_start(void *kim_data) | |||
500 | * (b) upon failure to either install ldisc or download firmware. | 509 | * (b) upon failure to either install ldisc or download firmware. |
501 | * The function is responsible to (a) notify UIM about un-installation, | 510 | * The function is responsible to (a) notify UIM about un-installation, |
502 | * (b) flush UART if the ldisc was installed. | 511 | * (b) flush UART if the ldisc was installed. |
503 | * (c) reset BT_EN - pull down nshutdown at the end. | 512 | * (c) invoke platform's chip disabling routine. |
504 | * (d) invoke platform's chip disabling routine. | ||
505 | */ | 513 | */ |
506 | long st_kim_stop(void *kim_data) | 514 | long st_kim_stop(void *kim_data) |
507 | { | 515 | { |
@@ -526,20 +534,13 @@ long st_kim_stop(void *kim_data) | |||
526 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); | 534 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install"); |
527 | 535 | ||
528 | /* wait for ldisc to be un-installed */ | 536 | /* wait for ldisc to be un-installed */ |
529 | err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, | 537 | err = wait_for_completion_interruptible_timeout( |
530 | msecs_to_jiffies(LDISC_TIME)); | 538 | &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); |
531 | if (!err) { /* timeout */ | 539 | if (!err) { /* timeout */ |
532 | pr_err(" timed out waiting for ldisc to be un-installed"); | 540 | pr_err(" timed out waiting for ldisc to be un-installed"); |
533 | return -ETIMEDOUT; | 541 | err = -ETIMEDOUT; |
534 | } | 542 | } |
535 | 543 | ||
536 | /* By default configure BT nShutdown to LOW state */ | ||
537 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); | ||
538 | mdelay(1); | ||
539 | gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH); | ||
540 | mdelay(1); | ||
541 | gpio_set_value(kim_gdata->nshutdown, GPIO_LOW); | ||
542 | |||
543 | /* platform specific disable */ | 544 | /* platform specific disable */ |
544 | if (pdata->chip_disable) | 545 | if (pdata->chip_disable) |
545 | pdata->chip_disable(kim_gdata); | 546 | pdata->chip_disable(kim_gdata); |
@@ -701,7 +702,7 @@ static const struct file_operations list_debugfs_fops = { | |||
701 | * board-*.c file | 702 | * board-*.c file |
702 | */ | 703 | */ |
703 | 704 | ||
704 | struct dentry *kim_debugfs_dir; | 705 | static struct dentry *kim_debugfs_dir; |
705 | static int kim_probe(struct platform_device *pdev) | 706 | static int kim_probe(struct platform_device *pdev) |
706 | { | 707 | { |
707 | long status; | 708 | long status; |
@@ -731,20 +732,6 @@ static int kim_probe(struct platform_device *pdev) | |||
731 | /* refer to itself */ | 732 | /* refer to itself */ |
732 | kim_gdata->core_data->kim_data = kim_gdata; | 733 | kim_gdata->core_data->kim_data = kim_gdata; |
733 | 734 | ||
734 | /* Claim the chip enable nShutdown gpio from the system */ | ||
735 | kim_gdata->nshutdown = pdata->nshutdown_gpio; | ||
736 | status = gpio_request(kim_gdata->nshutdown, "kim"); | ||
737 | if (unlikely(status)) { | ||
738 | pr_err(" gpio %ld request failed ", kim_gdata->nshutdown); | ||
739 | return status; | ||
740 | } | ||
741 | |||
742 | /* Configure nShutdown GPIO as output=0 */ | ||
743 | status = gpio_direction_output(kim_gdata->nshutdown, 0); | ||
744 | if (unlikely(status)) { | ||
745 | pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown); | ||
746 | return status; | ||
747 | } | ||
748 | /* get reference of pdev for request_firmware | 735 | /* get reference of pdev for request_firmware |
749 | */ | 736 | */ |
750 | kim_gdata->kim_pdev = pdev; | 737 | kim_gdata->kim_pdev = pdev; |
@@ -780,18 +767,10 @@ static int kim_probe(struct platform_device *pdev) | |||
780 | 767 | ||
781 | static int kim_remove(struct platform_device *pdev) | 768 | static int kim_remove(struct platform_device *pdev) |
782 | { | 769 | { |
783 | /* free the GPIOs requested */ | ||
784 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | ||
785 | struct kim_data_s *kim_gdata; | 770 | struct kim_data_s *kim_gdata; |
786 | 771 | ||
787 | kim_gdata = dev_get_drvdata(&pdev->dev); | 772 | kim_gdata = dev_get_drvdata(&pdev->dev); |
788 | 773 | ||
789 | /* Free the Bluetooth/FM/GPIO | ||
790 | * nShutdown gpio from the system | ||
791 | */ | ||
792 | gpio_free(pdata->nshutdown_gpio); | ||
793 | pr_info("nshutdown GPIO Freed"); | ||
794 | |||
795 | debugfs_remove_recursive(kim_debugfs_dir); | 774 | debugfs_remove_recursive(kim_debugfs_dir); |
796 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); | 775 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); |
797 | pr_info("sysfs entries removed"); | 776 | pr_info("sysfs entries removed"); |
@@ -804,7 +783,7 @@ static int kim_remove(struct platform_device *pdev) | |||
804 | return 0; | 783 | return 0; |
805 | } | 784 | } |
806 | 785 | ||
807 | int kim_suspend(struct platform_device *pdev, pm_message_t state) | 786 | static int kim_suspend(struct platform_device *pdev, pm_message_t state) |
808 | { | 787 | { |
809 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | 788 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; |
810 | 789 | ||
@@ -814,7 +793,7 @@ int kim_suspend(struct platform_device *pdev, pm_message_t state) | |||
814 | return -EOPNOTSUPP; | 793 | return -EOPNOTSUPP; |
815 | } | 794 | } |
816 | 795 | ||
817 | int kim_resume(struct platform_device *pdev) | 796 | static int kim_resume(struct platform_device *pdev) |
818 | { | 797 | { |
819 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; | 798 | struct ti_st_plat_data *pdata = pdev->dev.platform_data; |
820 | 799 | ||
diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c index 1ff460a8e9c7..93b4d67cc4a3 100644 --- a/drivers/misc/ti-st/st_ll.c +++ b/drivers/misc/ti-st/st_ll.c | |||
@@ -87,7 +87,7 @@ static void ll_device_want_to_wakeup(struct st_data_s *st_data) | |||
87 | /* communicate to platform about chip wakeup */ | 87 | /* communicate to platform about chip wakeup */ |
88 | kim_data = st_data->kim_data; | 88 | kim_data = st_data->kim_data; |
89 | pdata = kim_data->kim_pdev->dev.platform_data; | 89 | pdata = kim_data->kim_pdev->dev.platform_data; |
90 | if (pdata->chip_asleep) | 90 | if (pdata->chip_awake) |
91 | pdata->chip_awake(NULL); | 91 | pdata->chip_awake(NULL); |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c index ba2479022670..f8d6654391e5 100644 --- a/drivers/misc/tifm_7xx1.c +++ b/drivers/misc/tifm_7xx1.c | |||
@@ -434,21 +434,9 @@ static struct pci_driver tifm_7xx1_driver = { | |||
434 | .resume = tifm_7xx1_resume, | 434 | .resume = tifm_7xx1_resume, |
435 | }; | 435 | }; |
436 | 436 | ||
437 | static int __init tifm_7xx1_init(void) | 437 | module_pci_driver(tifm_7xx1_driver); |
438 | { | ||
439 | return pci_register_driver(&tifm_7xx1_driver); | ||
440 | } | ||
441 | |||
442 | static void __exit tifm_7xx1_exit(void) | ||
443 | { | ||
444 | pci_unregister_driver(&tifm_7xx1_driver); | ||
445 | } | ||
446 | |||
447 | MODULE_AUTHOR("Alex Dubov"); | 438 | MODULE_AUTHOR("Alex Dubov"); |
448 | MODULE_DESCRIPTION("TI FlashMedia host driver"); | 439 | MODULE_DESCRIPTION("TI FlashMedia host driver"); |
449 | MODULE_LICENSE("GPL"); | 440 | MODULE_LICENSE("GPL"); |
450 | MODULE_DEVICE_TABLE(pci, tifm_7xx1_pci_tbl); | 441 | MODULE_DEVICE_TABLE(pci, tifm_7xx1_pci_tbl); |
451 | MODULE_VERSION(DRIVER_VERSION); | 442 | MODULE_VERSION(DRIVER_VERSION); |
452 | |||
453 | module_init(tifm_7xx1_init); | ||
454 | module_exit(tifm_7xx1_exit); | ||