diff options
Diffstat (limited to 'drivers')
144 files changed, 6648 insertions, 2536 deletions
diff --git a/drivers/char/mwave/Makefile b/drivers/char/mwave/Makefile index 26b4fce217b6..efa6a82e543d 100644 --- a/drivers/char/mwave/Makefile +++ b/drivers/char/mwave/Makefile | |||
@@ -9,7 +9,7 @@ obj-$(CONFIG_MWAVE) += mwave.o | |||
9 | mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o | 9 | mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o |
10 | 10 | ||
11 | # To have the mwave driver disable other uarts if necessary | 11 | # To have the mwave driver disable other uarts if necessary |
12 | # EXTRA_CFLAGS += -DMWAVE_FUTZ_WITH_OTHER_DEVICES | 12 | # ccflags-y := -DMWAVE_FUTZ_WITH_OTHER_DEVICES |
13 | 13 | ||
14 | # To compile in lots (~20 KiB) of run-time enablable printk()s for debugging: | 14 | # To compile in lots (~20 KiB) of run-time enablable printk()s for debugging: |
15 | ccflags-y := -DMW_TRACE | 15 | ccflags-y += -DMW_TRACE |
diff --git a/drivers/char/mwave/README b/drivers/char/mwave/README index 480251fc78e2..c2a58f428bc8 100644 --- a/drivers/char/mwave/README +++ b/drivers/char/mwave/README | |||
@@ -11,7 +11,7 @@ are not saved by the BIOS and so do not persist after unload and reload. | |||
11 | 0x0008 tp3780i tracing | 11 | 0x0008 tp3780i tracing |
12 | 12 | ||
13 | Tracing only occurs if the driver has been compiled with the | 13 | Tracing only occurs if the driver has been compiled with the |
14 | MW_TRACE macro #defined (i.e. let EXTRA_CFLAGS += -DMW_TRACE | 14 | MW_TRACE macro #defined (i.e. let ccflags-y := -DMW_TRACE |
15 | in the Makefile). | 15 | in the Makefile). |
16 | 16 | ||
17 | mwave_3780i_irq=5/7/10/11/15 | 17 | mwave_3780i_irq=5/7/10/11/15 |
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index 64b21f5cd740..1be065a62f8c 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile | |||
@@ -1,9 +1,5 @@ | |||
1 | ifeq ($(CONFIG_DMADEVICES_DEBUG),y) | 1 | ccflags-$(CONFIG_DMADEVICES_DEBUG) := -DDEBUG |
2 | ccflags-y += -DDEBUG | 2 | ccflags-$(CONFIG_DMADEVICES_VDEBUG) += -DVERBOSE_DEBUG |
3 | endif | ||
4 | ifeq ($(CONFIG_DMADEVICES_VDEBUG),y) | ||
5 | ccflags-y += -DVERBOSE_DEBUG | ||
6 | endif | ||
7 | 3 | ||
8 | obj-$(CONFIG_DMA_ENGINE) += dmaengine.o | 4 | obj-$(CONFIG_DMA_ENGINE) += dmaengine.o |
9 | obj-$(CONFIG_NET_DMA) += iovlock.o | 5 | obj-$(CONFIG_NET_DMA) += iovlock.o |
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 0c56989cd907..2be6f4520772 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig | |||
@@ -75,7 +75,8 @@ config FIREWIRE_NOSY | |||
75 | The following cards are known to be based on PCILynx or PCILynx-2: | 75 | The following cards are known to be based on PCILynx or PCILynx-2: |
76 | IOI IOI-1394TT (PCI card), Unibrain Fireboard 400 PCI Lynx-2 | 76 | IOI IOI-1394TT (PCI card), Unibrain Fireboard 400 PCI Lynx-2 |
77 | (PCI card), Newer Technology FireWire 2 Go (CardBus card), | 77 | (PCI card), Newer Technology FireWire 2 Go (CardBus card), |
78 | Apple Power Mac G3 blue & white (onboard controller). | 78 | Apple Power Mac G3 blue & white and G4 with PCI graphics |
79 | (onboard controller). | ||
79 | 80 | ||
80 | To compile this driver as a module, say M here: The module will be | 81 | To compile this driver as a module, say M here: The module will be |
81 | called nosy. Source code of a userspace interface to nosy, called | 82 | called nosy. Source code of a userspace interface to nosy, called |
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index 24ff35511e2b..3c44fbc81acb 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c | |||
@@ -75,6 +75,13 @@ static size_t config_rom_length = 1 + 4 + 1 + 1; | |||
75 | #define BIB_IRMC ((1) << 31) | 75 | #define BIB_IRMC ((1) << 31) |
76 | #define NODE_CAPABILITIES 0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */ | 76 | #define NODE_CAPABILITIES 0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */ |
77 | 77 | ||
78 | /* | ||
79 | * IEEE-1394 specifies a default SPLIT_TIMEOUT value of 800 cycles (100 ms), | ||
80 | * but we have to make it longer because there are many devices whose firmware | ||
81 | * is just too slow for that. | ||
82 | */ | ||
83 | #define DEFAULT_SPLIT_TIMEOUT (2 * 8000) | ||
84 | |||
78 | #define CANON_OUI 0x000085 | 85 | #define CANON_OUI 0x000085 |
79 | 86 | ||
80 | static void generate_config_rom(struct fw_card *card, __be32 *config_rom) | 87 | static void generate_config_rom(struct fw_card *card, __be32 *config_rom) |
@@ -233,7 +240,7 @@ static void br_work(struct work_struct *work) | |||
233 | 240 | ||
234 | /* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */ | 241 | /* Delay for 2s after last reset per IEEE 1394 clause 8.2.1. */ |
235 | if (card->reset_jiffies != 0 && | 242 | if (card->reset_jiffies != 0 && |
236 | time_is_after_jiffies(card->reset_jiffies + 2 * HZ)) { | 243 | time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) { |
237 | if (!schedule_delayed_work(&card->br_work, 2 * HZ)) | 244 | if (!schedule_delayed_work(&card->br_work, 2 * HZ)) |
238 | fw_card_put(card); | 245 | fw_card_put(card); |
239 | return; | 246 | return; |
@@ -316,7 +323,8 @@ static void bm_work(struct work_struct *work) | |||
316 | irm_id = card->irm_node->node_id; | 323 | irm_id = card->irm_node->node_id; |
317 | local_id = card->local_node->node_id; | 324 | local_id = card->local_node->node_id; |
318 | 325 | ||
319 | grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 8)); | 326 | grace = time_after64(get_jiffies_64(), |
327 | card->reset_jiffies + DIV_ROUND_UP(HZ, 8)); | ||
320 | 328 | ||
321 | if ((is_next_generation(generation, card->bm_generation) && | 329 | if ((is_next_generation(generation, card->bm_generation) && |
322 | !card->bm_abdicate) || | 330 | !card->bm_abdicate) || |
@@ -511,10 +519,11 @@ void fw_card_initialize(struct fw_card *card, | |||
511 | card->device = device; | 519 | card->device = device; |
512 | card->current_tlabel = 0; | 520 | card->current_tlabel = 0; |
513 | card->tlabel_mask = 0; | 521 | card->tlabel_mask = 0; |
514 | card->split_timeout_hi = 0; | 522 | card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000; |
515 | card->split_timeout_lo = 800 << 19; | 523 | card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; |
516 | card->split_timeout_cycles = 800; | 524 | card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT; |
517 | card->split_timeout_jiffies = DIV_ROUND_UP(HZ, 10); | 525 | card->split_timeout_jiffies = |
526 | DIV_ROUND_UP(DEFAULT_SPLIT_TIMEOUT * HZ, 8000); | ||
518 | card->color = 0; | 527 | card->color = 0; |
519 | card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; | 528 | card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; |
520 | 529 | ||
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 48ae712e2101..62ac111af243 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -64,6 +64,7 @@ struct client { | |||
64 | struct idr resource_idr; | 64 | struct idr resource_idr; |
65 | struct list_head event_list; | 65 | struct list_head event_list; |
66 | wait_queue_head_t wait; | 66 | wait_queue_head_t wait; |
67 | wait_queue_head_t tx_flush_wait; | ||
67 | u64 bus_reset_closure; | 68 | u64 bus_reset_closure; |
68 | 69 | ||
69 | struct fw_iso_context *iso_context; | 70 | struct fw_iso_context *iso_context; |
@@ -251,6 +252,7 @@ static int fw_device_op_open(struct inode *inode, struct file *file) | |||
251 | idr_init(&client->resource_idr); | 252 | idr_init(&client->resource_idr); |
252 | INIT_LIST_HEAD(&client->event_list); | 253 | INIT_LIST_HEAD(&client->event_list); |
253 | init_waitqueue_head(&client->wait); | 254 | init_waitqueue_head(&client->wait); |
255 | init_waitqueue_head(&client->tx_flush_wait); | ||
254 | INIT_LIST_HEAD(&client->phy_receiver_link); | 256 | INIT_LIST_HEAD(&client->phy_receiver_link); |
255 | kref_init(&client->kref); | 257 | kref_init(&client->kref); |
256 | 258 | ||
@@ -520,10 +522,6 @@ static int release_client_resource(struct client *client, u32 handle, | |||
520 | static void release_transaction(struct client *client, | 522 | static void release_transaction(struct client *client, |
521 | struct client_resource *resource) | 523 | struct client_resource *resource) |
522 | { | 524 | { |
523 | struct outbound_transaction_resource *r = container_of(resource, | ||
524 | struct outbound_transaction_resource, resource); | ||
525 | |||
526 | fw_cancel_transaction(client->device->card, &r->transaction); | ||
527 | } | 525 | } |
528 | 526 | ||
529 | static void complete_transaction(struct fw_card *card, int rcode, | 527 | static void complete_transaction(struct fw_card *card, int rcode, |
@@ -540,22 +538,9 @@ static void complete_transaction(struct fw_card *card, int rcode, | |||
540 | memcpy(rsp->data, payload, rsp->length); | 538 | memcpy(rsp->data, payload, rsp->length); |
541 | 539 | ||
542 | spin_lock_irqsave(&client->lock, flags); | 540 | spin_lock_irqsave(&client->lock, flags); |
543 | /* | 541 | idr_remove(&client->resource_idr, e->r.resource.handle); |
544 | * 1. If called while in shutdown, the idr tree must be left untouched. | 542 | if (client->in_shutdown) |
545 | * The idr handle will be removed and the client reference will be | 543 | wake_up(&client->tx_flush_wait); |
546 | * dropped later. | ||
547 | * 2. If the call chain was release_client_resource -> | ||
548 | * release_transaction -> complete_transaction (instead of a normal | ||
549 | * conclusion of the transaction), i.e. if this resource was already | ||
550 | * unregistered from the idr, the client reference will be dropped | ||
551 | * by release_client_resource and we must not drop it here. | ||
552 | */ | ||
553 | if (!client->in_shutdown && | ||
554 | idr_find(&client->resource_idr, e->r.resource.handle)) { | ||
555 | idr_remove(&client->resource_idr, e->r.resource.handle); | ||
556 | /* Drop the idr's reference */ | ||
557 | client_put(client); | ||
558 | } | ||
559 | spin_unlock_irqrestore(&client->lock, flags); | 544 | spin_unlock_irqrestore(&client->lock, flags); |
560 | 545 | ||
561 | rsp->type = FW_CDEV_EVENT_RESPONSE; | 546 | rsp->type = FW_CDEV_EVENT_RESPONSE; |
@@ -575,7 +560,7 @@ static void complete_transaction(struct fw_card *card, int rcode, | |||
575 | queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, | 560 | queue_event(client, &e->event, rsp, sizeof(*rsp) + rsp->length, |
576 | NULL, 0); | 561 | NULL, 0); |
577 | 562 | ||
578 | /* Drop the transaction callback's reference */ | 563 | /* Drop the idr's reference */ |
579 | client_put(client); | 564 | client_put(client); |
580 | } | 565 | } |
581 | 566 | ||
@@ -614,9 +599,6 @@ static int init_request(struct client *client, | |||
614 | if (ret < 0) | 599 | if (ret < 0) |
615 | goto failed; | 600 | goto failed; |
616 | 601 | ||
617 | /* Get a reference for the transaction callback */ | ||
618 | client_get(client); | ||
619 | |||
620 | fw_send_request(client->device->card, &e->r.transaction, | 602 | fw_send_request(client->device->card, &e->r.transaction, |
621 | request->tcode, destination_id, request->generation, | 603 | request->tcode, destination_id, request->generation, |
622 | speed, request->offset, e->response.data, | 604 | speed, request->offset, e->response.data, |
@@ -1223,7 +1205,8 @@ static void iso_resource_work(struct work_struct *work) | |||
1223 | todo = r->todo; | 1205 | todo = r->todo; |
1224 | /* Allow 1000ms grace period for other reallocations. */ | 1206 | /* Allow 1000ms grace period for other reallocations. */ |
1225 | if (todo == ISO_RES_ALLOC && | 1207 | if (todo == ISO_RES_ALLOC && |
1226 | time_is_after_jiffies(client->device->card->reset_jiffies + HZ)) { | 1208 | time_before64(get_jiffies_64(), |
1209 | client->device->card->reset_jiffies + HZ)) { | ||
1227 | schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3)); | 1210 | schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3)); |
1228 | skip = true; | 1211 | skip = true; |
1229 | } else { | 1212 | } else { |
@@ -1678,6 +1661,25 @@ static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) | |||
1678 | return ret; | 1661 | return ret; |
1679 | } | 1662 | } |
1680 | 1663 | ||
1664 | static int is_outbound_transaction_resource(int id, void *p, void *data) | ||
1665 | { | ||
1666 | struct client_resource *resource = p; | ||
1667 | |||
1668 | return resource->release == release_transaction; | ||
1669 | } | ||
1670 | |||
1671 | static int has_outbound_transactions(struct client *client) | ||
1672 | { | ||
1673 | int ret; | ||
1674 | |||
1675 | spin_lock_irq(&client->lock); | ||
1676 | ret = idr_for_each(&client->resource_idr, | ||
1677 | is_outbound_transaction_resource, NULL); | ||
1678 | spin_unlock_irq(&client->lock); | ||
1679 | |||
1680 | return ret; | ||
1681 | } | ||
1682 | |||
1681 | static int shutdown_resource(int id, void *p, void *data) | 1683 | static int shutdown_resource(int id, void *p, void *data) |
1682 | { | 1684 | { |
1683 | struct client_resource *resource = p; | 1685 | struct client_resource *resource = p; |
@@ -1713,6 +1715,8 @@ static int fw_device_op_release(struct inode *inode, struct file *file) | |||
1713 | client->in_shutdown = true; | 1715 | client->in_shutdown = true; |
1714 | spin_unlock_irq(&client->lock); | 1716 | spin_unlock_irq(&client->lock); |
1715 | 1717 | ||
1718 | wait_event(client->tx_flush_wait, !has_outbound_transactions(client)); | ||
1719 | |||
1716 | idr_for_each(&client->resource_idr, shutdown_resource, client); | 1720 | idr_for_each(&client->resource_idr, shutdown_resource, client); |
1717 | idr_remove_all(&client->resource_idr); | 1721 | idr_remove_all(&client->resource_idr); |
1718 | idr_destroy(&client->resource_idr); | 1722 | idr_destroy(&client->resource_idr); |
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 6113b896e790..9a262439e3a7 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -747,7 +747,8 @@ static void fw_device_shutdown(struct work_struct *work) | |||
747 | container_of(work, struct fw_device, work.work); | 747 | container_of(work, struct fw_device, work.work); |
748 | int minor = MINOR(device->device.devt); | 748 | int minor = MINOR(device->device.devt); |
749 | 749 | ||
750 | if (time_is_after_jiffies(device->card->reset_jiffies + SHUTDOWN_DELAY) | 750 | if (time_before64(get_jiffies_64(), |
751 | device->card->reset_jiffies + SHUTDOWN_DELAY) | ||
751 | && !list_empty(&device->card->link)) { | 752 | && !list_empty(&device->card->link)) { |
752 | schedule_delayed_work(&device->work, SHUTDOWN_DELAY); | 753 | schedule_delayed_work(&device->work, SHUTDOWN_DELAY); |
753 | return; | 754 | return; |
@@ -954,8 +955,9 @@ static void fw_device_init(struct work_struct *work) | |||
954 | device->config_rom_retries++; | 955 | device->config_rom_retries++; |
955 | schedule_delayed_work(&device->work, RETRY_DELAY); | 956 | schedule_delayed_work(&device->work, RETRY_DELAY); |
956 | } else { | 957 | } else { |
957 | fw_notify("giving up on config rom for node id %x\n", | 958 | if (device->node->link_on) |
958 | device->node_id); | 959 | fw_notify("giving up on config rom for node id %x\n", |
960 | device->node_id); | ||
959 | if (device->node == device->card->root_node) | 961 | if (device->node == device->card->root_node) |
960 | fw_schedule_bm_work(device->card, 0); | 962 | fw_schedule_bm_work(device->card, 0); |
961 | fw_device_release(&device->device); | 963 | fw_device_release(&device->device); |
@@ -1168,9 +1170,12 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | |||
1168 | 1170 | ||
1169 | switch (event) { | 1171 | switch (event) { |
1170 | case FW_NODE_CREATED: | 1172 | case FW_NODE_CREATED: |
1171 | case FW_NODE_LINK_ON: | 1173 | /* |
1172 | if (!node->link_on) | 1174 | * Attempt to scan the node, regardless whether its self ID has |
1173 | break; | 1175 | * the L (link active) flag set or not. Some broken devices |
1176 | * send L=0 but have an up-and-running link; others send L=1 | ||
1177 | * without actually having a link. | ||
1178 | */ | ||
1174 | create: | 1179 | create: |
1175 | device = kzalloc(sizeof(*device), GFP_ATOMIC); | 1180 | device = kzalloc(sizeof(*device), GFP_ATOMIC); |
1176 | if (device == NULL) | 1181 | if (device == NULL) |
@@ -1213,6 +1218,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | |||
1213 | break; | 1218 | break; |
1214 | 1219 | ||
1215 | case FW_NODE_INITIATED_RESET: | 1220 | case FW_NODE_INITIATED_RESET: |
1221 | case FW_NODE_LINK_ON: | ||
1216 | device = node->data; | 1222 | device = node->data; |
1217 | if (device == NULL) | 1223 | if (device == NULL) |
1218 | goto create; | 1224 | goto create; |
@@ -1230,10 +1236,10 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | |||
1230 | break; | 1236 | break; |
1231 | 1237 | ||
1232 | case FW_NODE_UPDATED: | 1238 | case FW_NODE_UPDATED: |
1233 | if (!node->link_on || node->data == NULL) | 1239 | device = node->data; |
1240 | if (device == NULL) | ||
1234 | break; | 1241 | break; |
1235 | 1242 | ||
1236 | device = node->data; | ||
1237 | device->node_id = node->node_id; | 1243 | device->node_id = node->node_id; |
1238 | smp_wmb(); /* update node_id before generation */ | 1244 | smp_wmb(); /* update node_id before generation */ |
1239 | device->generation = card->generation; | 1245 | device->generation = card->generation; |
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index c8658888e67b..481056df9268 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c | |||
@@ -235,45 +235,45 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation, | |||
235 | static int manage_channel(struct fw_card *card, int irm_id, int generation, | 235 | static int manage_channel(struct fw_card *card, int irm_id, int generation, |
236 | u32 channels_mask, u64 offset, bool allocate, __be32 data[2]) | 236 | u32 channels_mask, u64 offset, bool allocate, __be32 data[2]) |
237 | { | 237 | { |
238 | __be32 c, all, old; | 238 | __be32 bit, all, old; |
239 | int i, ret = -EIO, retry = 5; | 239 | int channel, ret = -EIO, retry = 5; |
240 | 240 | ||
241 | old = all = allocate ? cpu_to_be32(~0) : 0; | 241 | old = all = allocate ? cpu_to_be32(~0) : 0; |
242 | 242 | ||
243 | for (i = 0; i < 32; i++) { | 243 | for (channel = 0; channel < 32; channel++) { |
244 | if (!(channels_mask & 1 << i)) | 244 | if (!(channels_mask & 1 << channel)) |
245 | continue; | 245 | continue; |
246 | 246 | ||
247 | ret = -EBUSY; | 247 | ret = -EBUSY; |
248 | 248 | ||
249 | c = cpu_to_be32(1 << (31 - i)); | 249 | bit = cpu_to_be32(1 << (31 - channel)); |
250 | if ((old & c) != (all & c)) | 250 | if ((old & bit) != (all & bit)) |
251 | continue; | 251 | continue; |
252 | 252 | ||
253 | data[0] = old; | 253 | data[0] = old; |
254 | data[1] = old ^ c; | 254 | data[1] = old ^ bit; |
255 | switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, | 255 | switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, |
256 | irm_id, generation, SCODE_100, | 256 | irm_id, generation, SCODE_100, |
257 | offset, data, 8)) { | 257 | offset, data, 8)) { |
258 | case RCODE_GENERATION: | 258 | case RCODE_GENERATION: |
259 | /* A generation change frees all channels. */ | 259 | /* A generation change frees all channels. */ |
260 | return allocate ? -EAGAIN : i; | 260 | return allocate ? -EAGAIN : channel; |
261 | 261 | ||
262 | case RCODE_COMPLETE: | 262 | case RCODE_COMPLETE: |
263 | if (data[0] == old) | 263 | if (data[0] == old) |
264 | return i; | 264 | return channel; |
265 | 265 | ||
266 | old = data[0]; | 266 | old = data[0]; |
267 | 267 | ||
268 | /* Is the IRM 1394a-2000 compliant? */ | 268 | /* Is the IRM 1394a-2000 compliant? */ |
269 | if ((data[0] & c) == (data[1] & c)) | 269 | if ((data[0] & bit) == (data[1] & bit)) |
270 | continue; | 270 | continue; |
271 | 271 | ||
272 | /* 1394-1995 IRM, fall through to retry. */ | 272 | /* 1394-1995 IRM, fall through to retry. */ |
273 | default: | 273 | default: |
274 | if (retry) { | 274 | if (retry) { |
275 | retry--; | 275 | retry--; |
276 | i--; | 276 | channel--; |
277 | } else { | 277 | } else { |
278 | ret = -EIO; | 278 | ret = -EIO; |
279 | } | 279 | } |
diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c index 09be1a635505..193ed9233144 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c | |||
@@ -545,7 +545,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, | |||
545 | */ | 545 | */ |
546 | smp_wmb(); | 546 | smp_wmb(); |
547 | card->generation = generation; | 547 | card->generation = generation; |
548 | card->reset_jiffies = jiffies; | 548 | card->reset_jiffies = get_jiffies_64(); |
549 | card->bm_node_id = 0xffff; | 549 | card->bm_node_id = 0xffff; |
550 | card->bm_abdicate = bm_abdicate; | 550 | card->bm_abdicate = bm_abdicate; |
551 | fw_schedule_bm_work(card, 0); | 551 | fw_schedule_bm_work(card, 0); |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index bd3c61b6dd8d..f903d7b6f34a 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -208,9 +208,11 @@ struct fw_ohci { | |||
208 | struct context at_request_ctx; | 208 | struct context at_request_ctx; |
209 | struct context at_response_ctx; | 209 | struct context at_response_ctx; |
210 | 210 | ||
211 | u32 it_context_support; | ||
211 | u32 it_context_mask; /* unoccupied IT contexts */ | 212 | u32 it_context_mask; /* unoccupied IT contexts */ |
212 | struct iso_context *it_context_list; | 213 | struct iso_context *it_context_list; |
213 | u64 ir_context_channels; /* unoccupied channels */ | 214 | u64 ir_context_channels; /* unoccupied channels */ |
215 | u32 ir_context_support; | ||
214 | u32 ir_context_mask; /* unoccupied IR contexts */ | 216 | u32 ir_context_mask; /* unoccupied IR contexts */ |
215 | struct iso_context *ir_context_list; | 217 | struct iso_context *ir_context_list; |
216 | u64 mc_channels; /* channels in use by the multichannel IR context */ | 218 | u64 mc_channels; /* channels in use by the multichannel IR context */ |
@@ -338,7 +340,7 @@ static void log_irqs(u32 evt) | |||
338 | !(evt & OHCI1394_busReset)) | 340 | !(evt & OHCI1394_busReset)) |
339 | return; | 341 | return; |
340 | 342 | ||
341 | fw_notify("IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, | 343 | fw_notify("IRQ %08x%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", evt, |
342 | evt & OHCI1394_selfIDComplete ? " selfID" : "", | 344 | evt & OHCI1394_selfIDComplete ? " selfID" : "", |
343 | evt & OHCI1394_RQPkt ? " AR_req" : "", | 345 | evt & OHCI1394_RQPkt ? " AR_req" : "", |
344 | evt & OHCI1394_RSPkt ? " AR_resp" : "", | 346 | evt & OHCI1394_RSPkt ? " AR_resp" : "", |
@@ -351,6 +353,7 @@ static void log_irqs(u32 evt) | |||
351 | evt & OHCI1394_cycle64Seconds ? " cycle64Seconds" : "", | 353 | evt & OHCI1394_cycle64Seconds ? " cycle64Seconds" : "", |
352 | evt & OHCI1394_cycleInconsistent ? " cycleInconsistent" : "", | 354 | evt & OHCI1394_cycleInconsistent ? " cycleInconsistent" : "", |
353 | evt & OHCI1394_regAccessFail ? " regAccessFail" : "", | 355 | evt & OHCI1394_regAccessFail ? " regAccessFail" : "", |
356 | evt & OHCI1394_unrecoverableError ? " unrecoverableError" : "", | ||
354 | evt & OHCI1394_busReset ? " busReset" : "", | 357 | evt & OHCI1394_busReset ? " busReset" : "", |
355 | evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt | | 358 | evt & ~(OHCI1394_selfIDComplete | OHCI1394_RQPkt | |
356 | OHCI1394_RSPkt | OHCI1394_reqTxComplete | | 359 | OHCI1394_RSPkt | OHCI1394_reqTxComplete | |
@@ -1326,21 +1329,8 @@ static int at_context_queue_packet(struct context *ctx, | |||
1326 | DESCRIPTOR_IRQ_ALWAYS | | 1329 | DESCRIPTOR_IRQ_ALWAYS | |
1327 | DESCRIPTOR_BRANCH_ALWAYS); | 1330 | DESCRIPTOR_BRANCH_ALWAYS); |
1328 | 1331 | ||
1329 | /* | 1332 | /* FIXME: Document how the locking works. */ |
1330 | * If the controller and packet generations don't match, we need to | 1333 | if (ohci->generation != packet->generation) { |
1331 | * bail out and try again. If IntEvent.busReset is set, the AT context | ||
1332 | * is halted, so appending to the context and trying to run it is | ||
1333 | * futile. Most controllers do the right thing and just flush the AT | ||
1334 | * queue (per section 7.2.3.2 of the OHCI 1.1 specification), but | ||
1335 | * some controllers (like a JMicron JMB381 PCI-e) misbehave and wind | ||
1336 | * up stalling out. So we just bail out in software and try again | ||
1337 | * later, and everyone is happy. | ||
1338 | * FIXME: Test of IntEvent.busReset may no longer be necessary since we | ||
1339 | * flush AT queues in bus_reset_tasklet. | ||
1340 | * FIXME: Document how the locking works. | ||
1341 | */ | ||
1342 | if (ohci->generation != packet->generation || | ||
1343 | reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) { | ||
1344 | if (packet->payload_mapped) | 1334 | if (packet->payload_mapped) |
1345 | dma_unmap_single(ohci->card.device, payload_bus, | 1335 | dma_unmap_single(ohci->card.device, payload_bus, |
1346 | packet->payload_length, DMA_TO_DEVICE); | 1336 | packet->payload_length, DMA_TO_DEVICE); |
@@ -1590,6 +1580,47 @@ static void at_context_transmit(struct context *ctx, struct fw_packet *packet) | |||
1590 | 1580 | ||
1591 | } | 1581 | } |
1592 | 1582 | ||
1583 | static void detect_dead_context(struct fw_ohci *ohci, | ||
1584 | const char *name, unsigned int regs) | ||
1585 | { | ||
1586 | u32 ctl; | ||
1587 | |||
1588 | ctl = reg_read(ohci, CONTROL_SET(regs)); | ||
1589 | if (ctl & CONTEXT_DEAD) { | ||
1590 | #ifdef CONFIG_FIREWIRE_OHCI_DEBUG | ||
1591 | fw_error("DMA context %s has stopped, error code: %s\n", | ||
1592 | name, evts[ctl & 0x1f]); | ||
1593 | #else | ||
1594 | fw_error("DMA context %s has stopped, error code: %#x\n", | ||
1595 | name, ctl & 0x1f); | ||
1596 | #endif | ||
1597 | } | ||
1598 | } | ||
1599 | |||
1600 | static void handle_dead_contexts(struct fw_ohci *ohci) | ||
1601 | { | ||
1602 | unsigned int i; | ||
1603 | char name[8]; | ||
1604 | |||
1605 | detect_dead_context(ohci, "ATReq", OHCI1394_AsReqTrContextBase); | ||
1606 | detect_dead_context(ohci, "ATRsp", OHCI1394_AsRspTrContextBase); | ||
1607 | detect_dead_context(ohci, "ARReq", OHCI1394_AsReqRcvContextBase); | ||
1608 | detect_dead_context(ohci, "ARRsp", OHCI1394_AsRspRcvContextBase); | ||
1609 | for (i = 0; i < 32; ++i) { | ||
1610 | if (!(ohci->it_context_support & (1 << i))) | ||
1611 | continue; | ||
1612 | sprintf(name, "IT%u", i); | ||
1613 | detect_dead_context(ohci, name, OHCI1394_IsoXmitContextBase(i)); | ||
1614 | } | ||
1615 | for (i = 0; i < 32; ++i) { | ||
1616 | if (!(ohci->ir_context_support & (1 << i))) | ||
1617 | continue; | ||
1618 | sprintf(name, "IR%u", i); | ||
1619 | detect_dead_context(ohci, name, OHCI1394_IsoRcvContextBase(i)); | ||
1620 | } | ||
1621 | /* TODO: maybe try to flush and restart the dead contexts */ | ||
1622 | } | ||
1623 | |||
1593 | static u32 cycle_timer_ticks(u32 cycle_timer) | 1624 | static u32 cycle_timer_ticks(u32 cycle_timer) |
1594 | { | 1625 | { |
1595 | u32 ticks; | 1626 | u32 ticks; |
@@ -1904,6 +1935,9 @@ static irqreturn_t irq_handler(int irq, void *data) | |||
1904 | fw_notify("isochronous cycle inconsistent\n"); | 1935 | fw_notify("isochronous cycle inconsistent\n"); |
1905 | } | 1936 | } |
1906 | 1937 | ||
1938 | if (unlikely(event & OHCI1394_unrecoverableError)) | ||
1939 | handle_dead_contexts(ohci); | ||
1940 | |||
1907 | if (event & OHCI1394_cycle64Seconds) { | 1941 | if (event & OHCI1394_cycle64Seconds) { |
1908 | spin_lock(&ohci->lock); | 1942 | spin_lock(&ohci->lock); |
1909 | update_bus_time(ohci); | 1943 | update_bus_time(ohci); |
@@ -2141,7 +2175,9 @@ static int ohci_enable(struct fw_card *card, | |||
2141 | OHCI1394_selfIDComplete | | 2175 | OHCI1394_selfIDComplete | |
2142 | OHCI1394_regAccessFail | | 2176 | OHCI1394_regAccessFail | |
2143 | OHCI1394_cycle64Seconds | | 2177 | OHCI1394_cycle64Seconds | |
2144 | OHCI1394_cycleInconsistent | OHCI1394_cycleTooLong | | 2178 | OHCI1394_cycleInconsistent | |
2179 | OHCI1394_unrecoverableError | | ||
2180 | OHCI1394_cycleTooLong | | ||
2145 | OHCI1394_masterIntEnable; | 2181 | OHCI1394_masterIntEnable; |
2146 | if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS) | 2182 | if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS) |
2147 | irqs |= OHCI1394_busReset; | 2183 | irqs |= OHCI1394_busReset; |
@@ -2657,6 +2693,10 @@ static int ohci_start_iso(struct fw_iso_context *base, | |||
2657 | u32 control = IR_CONTEXT_ISOCH_HEADER, match; | 2693 | u32 control = IR_CONTEXT_ISOCH_HEADER, match; |
2658 | int index; | 2694 | int index; |
2659 | 2695 | ||
2696 | /* the controller cannot start without any queued packets */ | ||
2697 | if (ctx->context.last->branch_address == 0) | ||
2698 | return -ENODATA; | ||
2699 | |||
2660 | switch (ctx->base.type) { | 2700 | switch (ctx->base.type) { |
2661 | case FW_ISO_CONTEXT_TRANSMIT: | 2701 | case FW_ISO_CONTEXT_TRANSMIT: |
2662 | index = ctx - ohci->it_context_list; | 2702 | index = ctx - ohci->it_context_list; |
@@ -2715,6 +2755,7 @@ static int ohci_stop_iso(struct fw_iso_context *base) | |||
2715 | } | 2755 | } |
2716 | flush_writes(ohci); | 2756 | flush_writes(ohci); |
2717 | context_stop(&ctx->context); | 2757 | context_stop(&ctx->context); |
2758 | tasklet_kill(&ctx->context.tasklet); | ||
2718 | 2759 | ||
2719 | return 0; | 2760 | return 0; |
2720 | } | 2761 | } |
@@ -3207,15 +3248,17 @@ static int __devinit pci_probe(struct pci_dev *dev, | |||
3207 | 3248 | ||
3208 | reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); | 3249 | reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); |
3209 | ohci->ir_context_channels = ~0ULL; | 3250 | ohci->ir_context_channels = ~0ULL; |
3210 | ohci->ir_context_mask = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet); | 3251 | ohci->ir_context_support = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet); |
3211 | reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0); | 3252 | reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0); |
3253 | ohci->ir_context_mask = ohci->ir_context_support; | ||
3212 | ohci->n_ir = hweight32(ohci->ir_context_mask); | 3254 | ohci->n_ir = hweight32(ohci->ir_context_mask); |
3213 | size = sizeof(struct iso_context) * ohci->n_ir; | 3255 | size = sizeof(struct iso_context) * ohci->n_ir; |
3214 | ohci->ir_context_list = kzalloc(size, GFP_KERNEL); | 3256 | ohci->ir_context_list = kzalloc(size, GFP_KERNEL); |
3215 | 3257 | ||
3216 | reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); | 3258 | reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); |
3217 | ohci->it_context_mask = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); | 3259 | ohci->it_context_support = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); |
3218 | reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0); | 3260 | reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0); |
3261 | ohci->it_context_mask = ohci->it_context_support; | ||
3219 | ohci->n_it = hweight32(ohci->it_context_mask); | 3262 | ohci->n_it = hweight32(ohci->it_context_mask); |
3220 | size = sizeof(struct iso_context) * ohci->n_it; | 3263 | size = sizeof(struct iso_context) * ohci->n_it; |
3221 | ohci->it_context_list = kzalloc(size, GFP_KERNEL); | 3264 | ohci->it_context_list = kzalloc(size, GFP_KERNEL); |
@@ -3266,7 +3309,7 @@ static int __devinit pci_probe(struct pci_dev *dev, | |||
3266 | fail_disable: | 3309 | fail_disable: |
3267 | pci_disable_device(dev); | 3310 | pci_disable_device(dev); |
3268 | fail_free: | 3311 | fail_free: |
3269 | kfree(&ohci->card); | 3312 | kfree(ohci); |
3270 | pmac_ohci_off(dev); | 3313 | pmac_ohci_off(dev); |
3271 | fail: | 3314 | fail: |
3272 | if (err == -ENOMEM) | 3315 | if (err == -ENOMEM) |
@@ -3310,7 +3353,7 @@ static void pci_remove(struct pci_dev *dev) | |||
3310 | pci_iounmap(dev, ohci->registers); | 3353 | pci_iounmap(dev, ohci->registers); |
3311 | pci_release_region(dev, 0); | 3354 | pci_release_region(dev, 0); |
3312 | pci_disable_device(dev); | 3355 | pci_disable_device(dev); |
3313 | kfree(&ohci->card); | 3356 | kfree(ohci); |
3314 | pmac_ohci_off(dev); | 3357 | pmac_ohci_off(dev); |
3315 | 3358 | ||
3316 | fw_notify("Removed fw-ohci device.\n"); | 3359 | fw_notify("Removed fw-ohci device.\n"); |
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index afa576a75a8e..77ed589b360d 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -472,18 +472,12 @@ static void complete_transaction(struct fw_card *card, int rcode, | |||
472 | * So this callback only sets the rcode if it hasn't already | 472 | * So this callback only sets the rcode if it hasn't already |
473 | * been set and only does the cleanup if the transaction | 473 | * been set and only does the cleanup if the transaction |
474 | * failed and we didn't already get a status write. | 474 | * failed and we didn't already get a status write. |
475 | * | ||
476 | * Here we treat RCODE_CANCELLED like RCODE_COMPLETE because some | ||
477 | * OXUF936QSE firmwares occasionally respond after Split_Timeout and | ||
478 | * complete the ORB just fine. Note, we also get RCODE_CANCELLED | ||
479 | * from sbp2_cancel_orbs() if fw_cancel_transaction() == 0. | ||
480 | */ | 475 | */ |
481 | spin_lock_irqsave(&card->lock, flags); | 476 | spin_lock_irqsave(&card->lock, flags); |
482 | 477 | ||
483 | if (orb->rcode == -1) | 478 | if (orb->rcode == -1) |
484 | orb->rcode = rcode; | 479 | orb->rcode = rcode; |
485 | 480 | if (orb->rcode != RCODE_COMPLETE) { | |
486 | if (orb->rcode != RCODE_COMPLETE && orb->rcode != RCODE_CANCELLED) { | ||
487 | list_del(&orb->link); | 481 | list_del(&orb->link); |
488 | spin_unlock_irqrestore(&card->lock, flags); | 482 | spin_unlock_irqrestore(&card->lock, flags); |
489 | 483 | ||
@@ -532,7 +526,8 @@ static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) | |||
532 | 526 | ||
533 | list_for_each_entry_safe(orb, next, &list, link) { | 527 | list_for_each_entry_safe(orb, next, &list, link) { |
534 | retval = 0; | 528 | retval = 0; |
535 | fw_cancel_transaction(device->card, &orb->t); | 529 | if (fw_cancel_transaction(device->card, &orb->t) == 0) |
530 | continue; | ||
536 | 531 | ||
537 | orb->rcode = RCODE_CANCELLED; | 532 | orb->rcode = RCODE_CANCELLED; |
538 | orb->callback(orb, NULL); | 533 | orb->callback(orb, NULL); |
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 61aa71233392..b85744fe8464 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
@@ -481,6 +481,12 @@ static const struct hid_device_id apple_devices[] = { | |||
481 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | 481 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
482 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), | 482 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), |
483 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | 483 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
484 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI), | ||
485 | .driver_data = APPLE_HAS_FN }, | ||
486 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO), | ||
487 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
488 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS), | ||
489 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | ||
484 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), | 490 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), |
485 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 491 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
486 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), | 492 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index c3d66269ed7d..e9687768a335 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1333,6 +1333,9 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1333 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, | 1333 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
1334 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, | 1334 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
1335 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, | 1335 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
1336 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, | ||
1337 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, | ||
1338 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, | ||
1336 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, | 1339 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, |
1337 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, | 1340 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, |
1338 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, | 1341 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, |
@@ -1840,6 +1843,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { | |||
1840 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, | 1843 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, |
1841 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, | 1844 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, |
1842 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, | 1845 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, |
1846 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, | ||
1847 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, | ||
1848 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, | ||
1843 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1849 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1844 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1850 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1845 | { } | 1851 | { } |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index d485894ff4db..65ac53d7aecc 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -103,6 +103,9 @@ | |||
103 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 | 103 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 |
104 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 | 104 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 |
105 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 | 105 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 |
106 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245 | ||
107 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246 | ||
108 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247 | ||
106 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 | 109 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 |
107 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a | 110 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a |
108 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b | 111 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index cd74203c8178..33dde8724e02 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -900,8 +900,8 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
900 | hid->ll_driver->hidinput_input_event; | 900 | hid->ll_driver->hidinput_input_event; |
901 | input_dev->open = hidinput_open; | 901 | input_dev->open = hidinput_open; |
902 | input_dev->close = hidinput_close; | 902 | input_dev->close = hidinput_close; |
903 | input_dev->setkeycode_new = hidinput_setkeycode; | 903 | input_dev->setkeycode = hidinput_setkeycode; |
904 | input_dev->getkeycode_new = hidinput_getkeycode; | 904 | input_dev->getkeycode = hidinput_getkeycode; |
905 | 905 | ||
906 | input_dev->name = hid->name; | 906 | input_dev->name = hid->name; |
907 | input_dev->phys = hid->phys; | 907 | input_dev->phys = hid->phys; |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 1bfb4439e4e1..e4bd13b3cd8b 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -521,7 +521,7 @@ config SENSORS_LM75 | |||
521 | - Dallas Semiconductor DS75 and DS1775 | 521 | - Dallas Semiconductor DS75 and DS1775 |
522 | - Maxim MAX6625 and MAX6626 | 522 | - Maxim MAX6625 and MAX6626 |
523 | - Microchip MCP980x | 523 | - Microchip MCP980x |
524 | - National Semiconductor LM75 | 524 | - National Semiconductor LM75, LM75A |
525 | - NXP's LM75A | 525 | - NXP's LM75A |
526 | - ST Microelectronics STDS75 | 526 | - ST Microelectronics STDS75 |
527 | - TelCom (now Microchip) TCN75 | 527 | - TelCom (now Microchip) TCN75 |
@@ -959,6 +959,25 @@ config SENSORS_SMSC47B397 | |||
959 | This driver can also be built as a module. If so, the module | 959 | This driver can also be built as a module. If so, the module |
960 | will be called smsc47b397. | 960 | will be called smsc47b397. |
961 | 961 | ||
962 | config SENSORS_SCH5627 | ||
963 | tristate "SMSC SCH5627" | ||
964 | help | ||
965 | If you say yes here you get support for the hardware monitoring | ||
966 | features of the SMSC SCH5627 Super-I/O chip. | ||
967 | |||
968 | This driver can also be built as a module. If so, the module | ||
969 | will be called sch5627. | ||
970 | |||
971 | config SENSORS_ADS1015 | ||
972 | tristate "Texas Instruments ADS1015" | ||
973 | depends on I2C | ||
974 | help | ||
975 | If you say yes here you get support for Texas Instruments ADS1015 | ||
976 | 12-bit 4-input ADC device. | ||
977 | |||
978 | This driver can also be built as a module. If so, the module | ||
979 | will be called ads1015. | ||
980 | |||
962 | config SENSORS_ADS7828 | 981 | config SENSORS_ADS7828 |
963 | tristate "Texas Instruments ADS7828" | 982 | tristate "Texas Instruments ADS7828" |
964 | depends on I2C | 983 | depends on I2C |
@@ -1215,40 +1234,6 @@ config SENSORS_ULTRA45 | |||
1215 | This driver provides support for the Ultra45 workstation environmental | 1234 | This driver provides support for the Ultra45 workstation environmental |
1216 | sensors. | 1235 | sensors. |
1217 | 1236 | ||
1218 | config SENSORS_LIS3_SPI | ||
1219 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (SPI)" | ||
1220 | depends on !ACPI && SPI_MASTER && INPUT | ||
1221 | select INPUT_POLLDEV | ||
1222 | default n | ||
1223 | help | ||
1224 | This driver provides support for the LIS3LV02Dx accelerometer connected | ||
1225 | via SPI. The accelerometer data is readable via | ||
1226 | /sys/devices/platform/lis3lv02d. | ||
1227 | |||
1228 | This driver also provides an absolute input class device, allowing | ||
1229 | the laptop to act as a pinball machine-esque joystick. | ||
1230 | |||
1231 | This driver can also be built as modules. If so, the core module | ||
1232 | will be called lis3lv02d and a specific module for the SPI transport | ||
1233 | is called lis3lv02d_spi. | ||
1234 | |||
1235 | config SENSORS_LIS3_I2C | ||
1236 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (I2C)" | ||
1237 | depends on I2C && INPUT | ||
1238 | select INPUT_POLLDEV | ||
1239 | default n | ||
1240 | help | ||
1241 | This driver provides support for the LIS3LV02Dx accelerometer connected | ||
1242 | via I2C. The accelerometer data is readable via | ||
1243 | /sys/devices/platform/lis3lv02d. | ||
1244 | |||
1245 | This driver also provides an absolute input class device, allowing | ||
1246 | the device to act as a pinball machine-esque joystick. | ||
1247 | |||
1248 | This driver can also be built as modules. If so, the core module | ||
1249 | will be called lis3lv02d and a specific module for the I2C transport | ||
1250 | is called lis3lv02d_i2c. | ||
1251 | |||
1252 | config SENSORS_APPLESMC | 1237 | config SENSORS_APPLESMC |
1253 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" | 1238 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" |
1254 | depends on INPUT && X86 | 1239 | depends on INPUT && X86 |
@@ -1296,36 +1281,6 @@ config SENSORS_ATK0110 | |||
1296 | This driver can also be built as a module. If so, the module | 1281 | This driver can also be built as a module. If so, the module |
1297 | will be called asus_atk0110. | 1282 | will be called asus_atk0110. |
1298 | 1283 | ||
1299 | config SENSORS_LIS3LV02D | ||
1300 | tristate "STMicroeletronics LIS3* three-axis digital accelerometer" | ||
1301 | depends on INPUT | ||
1302 | select INPUT_POLLDEV | ||
1303 | select NEW_LEDS | ||
1304 | select LEDS_CLASS | ||
1305 | default n | ||
1306 | help | ||
1307 | This driver provides support for the LIS3* accelerometers, such as the | ||
1308 | LIS3LV02DL or the LIS331DL. In particular, it can be found in a number | ||
1309 | of HP laptops, which have the "Mobile Data Protection System 3D" or | ||
1310 | "3D DriveGuard" feature. On such systems the driver should load | ||
1311 | automatically (via ACPI alias). The accelerometer might also be found | ||
1312 | in other systems, connected via SPI or I2C. The accelerometer data is | ||
1313 | readable via /sys/devices/platform/lis3lv02d. | ||
1314 | |||
1315 | This driver also provides an absolute input class device, allowing | ||
1316 | a laptop to act as a pinball machine-esque joystick. It provides also | ||
1317 | a misc device which can be used to detect free-fall. On HP laptops, | ||
1318 | if the led infrastructure is activated, support for a led indicating | ||
1319 | disk protection will be provided as hp::hddprotect. For more | ||
1320 | information on the feature, refer to Documentation/hwmon/lis3lv02d. | ||
1321 | |||
1322 | This driver can also be built as modules. If so, the core module | ||
1323 | will be called lis3lv02d and a specific module for HP laptops will be | ||
1324 | called hp_accel. | ||
1325 | |||
1326 | Say Y here if you have an applicable laptop and want to experience | ||
1327 | the awesome power of lis3lv02d. | ||
1328 | |||
1329 | endif # ACPI | 1284 | endif # ACPI |
1330 | 1285 | ||
1331 | endif # HWMON | 1286 | endif # HWMON |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index bd0410e4b44f..54ca5939d028 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -29,6 +29,7 @@ obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o | |||
29 | obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o | 29 | obj-$(CONFIG_SENSORS_ADM1029) += adm1029.o |
30 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 30 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
31 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | 31 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o |
32 | obj-$(CONFIG_SENSORS_ADS1015) += ads1015.o | ||
32 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o | 33 | obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o |
33 | obj-$(CONFIG_SENSORS_ADS7871) += ads7871.o | 34 | obj-$(CONFIG_SENSORS_ADS7871) += ads7871.o |
34 | obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o | 35 | obj-$(CONFIG_SENSORS_ADT7411) += adt7411.o |
@@ -63,9 +64,6 @@ obj-$(CONFIG_SENSORS_JZ4740) += jz4740-hwmon.o | |||
63 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o | 64 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o |
64 | obj-$(CONFIG_SENSORS_K10TEMP) += k10temp.o | 65 | obj-$(CONFIG_SENSORS_K10TEMP) += k10temp.o |
65 | obj-$(CONFIG_SENSORS_LINEAGE) += lineage-pem.o | 66 | obj-$(CONFIG_SENSORS_LINEAGE) += lineage-pem.o |
66 | obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o | ||
67 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o | ||
68 | obj-$(CONFIG_SENSORS_LIS3_I2C) += lis3lv02d.o lis3lv02d_i2c.o | ||
69 | obj-$(CONFIG_SENSORS_LM63) += lm63.o | 67 | obj-$(CONFIG_SENSORS_LM63) += lm63.o |
70 | obj-$(CONFIG_SENSORS_LM70) += lm70.o | 68 | obj-$(CONFIG_SENSORS_LM70) += lm70.o |
71 | obj-$(CONFIG_SENSORS_LM73) += lm73.o | 69 | obj-$(CONFIG_SENSORS_LM73) += lm73.o |
@@ -93,6 +91,7 @@ obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | |||
93 | obj-$(CONFIG_SENSORS_PC87427) += pc87427.o | 91 | obj-$(CONFIG_SENSORS_PC87427) += pc87427.o |
94 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | 92 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o |
95 | obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o | 93 | obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o |
94 | obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o | ||
96 | obj-$(CONFIG_SENSORS_SHT15) += sht15.o | 95 | obj-$(CONFIG_SENSORS_SHT15) += sht15.o |
97 | obj-$(CONFIG_SENSORS_SHT21) += sht21.o | 96 | obj-$(CONFIG_SENSORS_SHT21) += sht21.o |
98 | obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o | 97 | obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o |
@@ -122,7 +121,5 @@ obj-$(CONFIG_SENSORS_MAX16064) += max16064.o | |||
122 | obj-$(CONFIG_SENSORS_MAX34440) += max34440.o | 121 | obj-$(CONFIG_SENSORS_MAX34440) += max34440.o |
123 | obj-$(CONFIG_SENSORS_MAX8688) += max8688.o | 122 | obj-$(CONFIG_SENSORS_MAX8688) += max8688.o |
124 | 123 | ||
125 | ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y) | 124 | ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG |
126 | EXTRA_CFLAGS += -DDEBUG | ||
127 | endif | ||
128 | 125 | ||
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c index 8f07a9dda152..0e05aa179eaa 100644 --- a/drivers/hwmon/abituguru.c +++ b/drivers/hwmon/abituguru.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | abituguru.c Copyright (c) 2005-2006 Hans de Goede <j.w.r.degoede@hhs.nl> | 2 | abituguru.c Copyright (c) 2005-2006 Hans de Goede <hdegoede@redhat.com> |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
@@ -1505,7 +1505,7 @@ static void __exit abituguru_exit(void) | |||
1505 | platform_driver_unregister(&abituguru_driver); | 1505 | platform_driver_unregister(&abituguru_driver); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); | 1508 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
1509 | MODULE_DESCRIPTION("Abit uGuru Sensor device"); | 1509 | MODULE_DESCRIPTION("Abit uGuru Sensor device"); |
1510 | MODULE_LICENSE("GPL"); | 1510 | MODULE_LICENSE("GPL"); |
1511 | 1511 | ||
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c index 48d21e22e930..034cebfcd273 100644 --- a/drivers/hwmon/abituguru3.c +++ b/drivers/hwmon/abituguru3.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | abituguru3.c | 2 | abituguru3.c |
3 | 3 | ||
4 | Copyright (c) 2006-2008 Hans de Goede <j.w.r.degoede@hhs.nl> | 4 | Copyright (c) 2006-2008 Hans de Goede <hdegoede@redhat.com> |
5 | Copyright (c) 2008 Alistair John Strachan <alistair@devzero.co.uk> | 5 | Copyright (c) 2008 Alistair John Strachan <alistair@devzero.co.uk> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
@@ -1266,7 +1266,7 @@ static void __exit abituguru3_exit(void) | |||
1266 | platform_driver_unregister(&abituguru3_driver); | 1266 | platform_driver_unregister(&abituguru3_driver); |
1267 | } | 1267 | } |
1268 | 1268 | ||
1269 | MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); | 1269 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
1270 | MODULE_DESCRIPTION("Abit uGuru3 Sensor device"); | 1270 | MODULE_DESCRIPTION("Abit uGuru3 Sensor device"); |
1271 | MODULE_LICENSE("GPL"); | 1271 | MODULE_LICENSE("GPL"); |
1272 | 1272 | ||
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c new file mode 100644 index 000000000000..e9beeda4cbe5 --- /dev/null +++ b/drivers/hwmon/ads1015.c | |||
@@ -0,0 +1,337 @@ | |||
1 | /* | ||
2 | * ads1015.c - lm_sensors driver for ads1015 12-bit 4-input ADC | ||
3 | * (C) Copyright 2010 | ||
4 | * Dirk Eibach, Guntermann & Drunck GmbH <eibach@gdsys.de> | ||
5 | * | ||
6 | * Based on the ads7828 driver by Steve Hardy. | ||
7 | * | ||
8 | * Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads1015.pdf | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <linux/i2c.h> | ||
30 | #include <linux/hwmon.h> | ||
31 | #include <linux/hwmon-sysfs.h> | ||
32 | #include <linux/err.h> | ||
33 | #include <linux/mutex.h> | ||
34 | #include <linux/of.h> | ||
35 | |||
36 | #include <linux/i2c/ads1015.h> | ||
37 | |||
38 | /* ADS1015 registers */ | ||
39 | enum { | ||
40 | ADS1015_CONVERSION = 0, | ||
41 | ADS1015_CONFIG = 1, | ||
42 | }; | ||
43 | |||
44 | /* PGA fullscale voltages in mV */ | ||
45 | static const unsigned int fullscale_table[8] = { | ||
46 | 6144, 4096, 2048, 1024, 512, 256, 256, 256 }; | ||
47 | |||
48 | /* Data rates in samples per second */ | ||
49 | static const unsigned int data_rate_table[8] = { | ||
50 | 128, 250, 490, 920, 1600, 2400, 3300, 3300 }; | ||
51 | |||
52 | #define ADS1015_DEFAULT_CHANNELS 0xff | ||
53 | #define ADS1015_DEFAULT_PGA 2 | ||
54 | #define ADS1015_DEFAULT_DATA_RATE 4 | ||
55 | |||
56 | struct ads1015_data { | ||
57 | struct device *hwmon_dev; | ||
58 | struct mutex update_lock; /* mutex protect updates */ | ||
59 | struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; | ||
60 | }; | ||
61 | |||
62 | static s32 ads1015_read_reg(struct i2c_client *client, unsigned int reg) | ||
63 | { | ||
64 | s32 data = i2c_smbus_read_word_data(client, reg); | ||
65 | |||
66 | return (data < 0) ? data : swab16(data); | ||
67 | } | ||
68 | |||
69 | static s32 ads1015_write_reg(struct i2c_client *client, unsigned int reg, | ||
70 | u16 val) | ||
71 | { | ||
72 | return i2c_smbus_write_word_data(client, reg, swab16(val)); | ||
73 | } | ||
74 | |||
75 | static int ads1015_read_value(struct i2c_client *client, unsigned int channel, | ||
76 | int *value) | ||
77 | { | ||
78 | u16 config; | ||
79 | s16 conversion; | ||
80 | struct ads1015_data *data = i2c_get_clientdata(client); | ||
81 | unsigned int pga = data->channel_data[channel].pga; | ||
82 | int fullscale; | ||
83 | unsigned int data_rate = data->channel_data[channel].data_rate; | ||
84 | unsigned int conversion_time_ms; | ||
85 | int res; | ||
86 | |||
87 | mutex_lock(&data->update_lock); | ||
88 | |||
89 | /* get channel parameters */ | ||
90 | res = ads1015_read_reg(client, ADS1015_CONFIG); | ||
91 | if (res < 0) | ||
92 | goto err_unlock; | ||
93 | config = res; | ||
94 | fullscale = fullscale_table[pga]; | ||
95 | conversion_time_ms = DIV_ROUND_UP(1000, data_rate_table[data_rate]); | ||
96 | |||
97 | /* setup and start single conversion */ | ||
98 | config &= 0x001f; | ||
99 | config |= (1 << 15) | (1 << 8); | ||
100 | config |= (channel & 0x0007) << 12; | ||
101 | config |= (pga & 0x0007) << 9; | ||
102 | config |= (data_rate & 0x0007) << 5; | ||
103 | |||
104 | res = ads1015_write_reg(client, ADS1015_CONFIG, config); | ||
105 | if (res < 0) | ||
106 | goto err_unlock; | ||
107 | |||
108 | /* wait until conversion finished */ | ||
109 | msleep(conversion_time_ms); | ||
110 | res = ads1015_read_reg(client, ADS1015_CONFIG); | ||
111 | if (res < 0) | ||
112 | goto err_unlock; | ||
113 | config = res; | ||
114 | if (!(config & (1 << 15))) { | ||
115 | /* conversion not finished in time */ | ||
116 | res = -EIO; | ||
117 | goto err_unlock; | ||
118 | } | ||
119 | |||
120 | res = ads1015_read_reg(client, ADS1015_CONVERSION); | ||
121 | if (res < 0) | ||
122 | goto err_unlock; | ||
123 | conversion = res; | ||
124 | |||
125 | mutex_unlock(&data->update_lock); | ||
126 | |||
127 | *value = DIV_ROUND_CLOSEST(conversion * fullscale, 0x7ff0); | ||
128 | |||
129 | return 0; | ||
130 | |||
131 | err_unlock: | ||
132 | mutex_unlock(&data->update_lock); | ||
133 | return res; | ||
134 | } | ||
135 | |||
136 | /* sysfs callback function */ | ||
137 | static ssize_t show_in(struct device *dev, struct device_attribute *da, | ||
138 | char *buf) | ||
139 | { | ||
140 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | ||
141 | struct i2c_client *client = to_i2c_client(dev); | ||
142 | int in; | ||
143 | int res; | ||
144 | |||
145 | res = ads1015_read_value(client, attr->index, &in); | ||
146 | |||
147 | return (res < 0) ? res : sprintf(buf, "%d\n", in); | ||
148 | } | ||
149 | |||
150 | static const struct sensor_device_attribute ads1015_in[] = { | ||
151 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), | ||
152 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
153 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
154 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
155 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
156 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
157 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
158 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
159 | }; | ||
160 | |||
161 | /* | ||
162 | * Driver interface | ||
163 | */ | ||
164 | |||
165 | static int ads1015_remove(struct i2c_client *client) | ||
166 | { | ||
167 | struct ads1015_data *data = i2c_get_clientdata(client); | ||
168 | int k; | ||
169 | |||
170 | hwmon_device_unregister(data->hwmon_dev); | ||
171 | for (k = 0; k < ADS1015_CHANNELS; ++k) | ||
172 | device_remove_file(&client->dev, &ads1015_in[k].dev_attr); | ||
173 | kfree(data); | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | #ifdef CONFIG_OF | ||
178 | static int ads1015_get_channels_config_of(struct i2c_client *client) | ||
179 | { | ||
180 | struct ads1015_data *data = i2c_get_clientdata(client); | ||
181 | struct device_node *node; | ||
182 | |||
183 | if (!client->dev.of_node | ||
184 | || !of_get_next_child(client->dev.of_node, NULL)) | ||
185 | return -EINVAL; | ||
186 | |||
187 | for_each_child_of_node(client->dev.of_node, node) { | ||
188 | const __be32 *property; | ||
189 | int len; | ||
190 | unsigned int channel; | ||
191 | unsigned int pga = ADS1015_DEFAULT_PGA; | ||
192 | unsigned int data_rate = ADS1015_DEFAULT_DATA_RATE; | ||
193 | |||
194 | property = of_get_property(node, "reg", &len); | ||
195 | if (!property || len != sizeof(int)) { | ||
196 | dev_err(&client->dev, "invalid reg on %s\n", | ||
197 | node->full_name); | ||
198 | continue; | ||
199 | } | ||
200 | |||
201 | channel = be32_to_cpup(property); | ||
202 | if (channel > ADS1015_CHANNELS) { | ||
203 | dev_err(&client->dev, | ||
204 | "invalid channel index %d on %s\n", | ||
205 | channel, node->full_name); | ||
206 | continue; | ||
207 | } | ||
208 | |||
209 | property = of_get_property(node, "ti,gain", &len); | ||
210 | if (property && len == sizeof(int)) { | ||
211 | pga = be32_to_cpup(property); | ||
212 | if (pga > 6) { | ||
213 | dev_err(&client->dev, | ||
214 | "invalid gain on %s\n", | ||
215 | node->full_name); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | property = of_get_property(node, "ti,datarate", &len); | ||
220 | if (property && len == sizeof(int)) { | ||
221 | data_rate = be32_to_cpup(property); | ||
222 | if (data_rate > 7) { | ||
223 | dev_err(&client->dev, | ||
224 | "invalid data_rate on %s\n", | ||
225 | node->full_name); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | data->channel_data[channel].enabled = true; | ||
230 | data->channel_data[channel].pga = pga; | ||
231 | data->channel_data[channel].data_rate = data_rate; | ||
232 | } | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | #endif | ||
237 | |||
238 | static void ads1015_get_channels_config(struct i2c_client *client) | ||
239 | { | ||
240 | unsigned int k; | ||
241 | struct ads1015_data *data = i2c_get_clientdata(client); | ||
242 | struct ads1015_platform_data *pdata = dev_get_platdata(&client->dev); | ||
243 | |||
244 | /* prefer platform data */ | ||
245 | if (pdata) { | ||
246 | memcpy(data->channel_data, pdata->channel_data, | ||
247 | sizeof(data->channel_data)); | ||
248 | return; | ||
249 | } | ||
250 | |||
251 | #ifdef CONFIG_OF | ||
252 | if (!ads1015_get_channels_config_of(client)) | ||
253 | return; | ||
254 | #endif | ||
255 | |||
256 | /* fallback on default configuration */ | ||
257 | for (k = 0; k < ADS1015_CHANNELS; ++k) { | ||
258 | data->channel_data[k].enabled = true; | ||
259 | data->channel_data[k].pga = ADS1015_DEFAULT_PGA; | ||
260 | data->channel_data[k].data_rate = ADS1015_DEFAULT_DATA_RATE; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | static int ads1015_probe(struct i2c_client *client, | ||
265 | const struct i2c_device_id *id) | ||
266 | { | ||
267 | struct ads1015_data *data; | ||
268 | int err; | ||
269 | unsigned int k; | ||
270 | |||
271 | data = kzalloc(sizeof(struct ads1015_data), GFP_KERNEL); | ||
272 | if (!data) { | ||
273 | err = -ENOMEM; | ||
274 | goto exit; | ||
275 | } | ||
276 | |||
277 | i2c_set_clientdata(client, data); | ||
278 | mutex_init(&data->update_lock); | ||
279 | |||
280 | /* build sysfs attribute group */ | ||
281 | ads1015_get_channels_config(client); | ||
282 | for (k = 0; k < ADS1015_CHANNELS; ++k) { | ||
283 | if (!data->channel_data[k].enabled) | ||
284 | continue; | ||
285 | err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); | ||
286 | if (err) | ||
287 | goto exit_free; | ||
288 | } | ||
289 | |||
290 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
291 | if (IS_ERR(data->hwmon_dev)) { | ||
292 | err = PTR_ERR(data->hwmon_dev); | ||
293 | goto exit_remove; | ||
294 | } | ||
295 | |||
296 | return 0; | ||
297 | |||
298 | exit_remove: | ||
299 | for (k = 0; k < ADS1015_CHANNELS; ++k) | ||
300 | device_remove_file(&client->dev, &ads1015_in[k].dev_attr); | ||
301 | exit_free: | ||
302 | kfree(data); | ||
303 | exit: | ||
304 | return err; | ||
305 | } | ||
306 | |||
307 | static const struct i2c_device_id ads1015_id[] = { | ||
308 | { "ads1015", 0 }, | ||
309 | { } | ||
310 | }; | ||
311 | MODULE_DEVICE_TABLE(i2c, ads1015_id); | ||
312 | |||
313 | static struct i2c_driver ads1015_driver = { | ||
314 | .driver = { | ||
315 | .name = "ads1015", | ||
316 | }, | ||
317 | .probe = ads1015_probe, | ||
318 | .remove = ads1015_remove, | ||
319 | .id_table = ads1015_id, | ||
320 | }; | ||
321 | |||
322 | static int __init sensors_ads1015_init(void) | ||
323 | { | ||
324 | return i2c_add_driver(&ads1015_driver); | ||
325 | } | ||
326 | |||
327 | static void __exit sensors_ads1015_exit(void) | ||
328 | { | ||
329 | i2c_del_driver(&ads1015_driver); | ||
330 | } | ||
331 | |||
332 | MODULE_AUTHOR("Dirk Eibach <eibach@gdsys.de>"); | ||
333 | MODULE_DESCRIPTION("ADS1015 driver"); | ||
334 | MODULE_LICENSE("GPL"); | ||
335 | |||
336 | module_init(sensors_ads1015_init); | ||
337 | module_exit(sensors_ads1015_exit); | ||
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index f36eb80d227f..ef902d5d06ab 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -232,13 +232,16 @@ static const struct i2c_device_id lm75_ids[] = { | |||
232 | }; | 232 | }; |
233 | MODULE_DEVICE_TABLE(i2c, lm75_ids); | 233 | MODULE_DEVICE_TABLE(i2c, lm75_ids); |
234 | 234 | ||
235 | #define LM75A_ID 0xA1 | ||
236 | |||
235 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 237 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
236 | static int lm75_detect(struct i2c_client *new_client, | 238 | static int lm75_detect(struct i2c_client *new_client, |
237 | struct i2c_board_info *info) | 239 | struct i2c_board_info *info) |
238 | { | 240 | { |
239 | struct i2c_adapter *adapter = new_client->adapter; | 241 | struct i2c_adapter *adapter = new_client->adapter; |
240 | int i; | 242 | int i; |
241 | int cur, conf, hyst, os; | 243 | int conf, hyst, os; |
244 | bool is_lm75a = 0; | ||
242 | 245 | ||
243 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 246 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
244 | I2C_FUNC_SMBUS_WORD_DATA)) | 247 | I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -250,37 +253,58 @@ static int lm75_detect(struct i2c_client *new_client, | |||
250 | addresses 0x04-0x07 returning the last read value. | 253 | addresses 0x04-0x07 returning the last read value. |
251 | The cycling+unused addresses combination is not tested, | 254 | The cycling+unused addresses combination is not tested, |
252 | since it would significantly slow the detection down and would | 255 | since it would significantly slow the detection down and would |
253 | hardly add any value. */ | 256 | hardly add any value. |
254 | 257 | ||
255 | /* Unused addresses */ | 258 | The National Semiconductor LM75A is different than earlier |
256 | cur = i2c_smbus_read_word_data(new_client, 0); | 259 | LM75s. It has an ID byte of 0xaX (where X is the chip |
257 | conf = i2c_smbus_read_byte_data(new_client, 1); | 260 | revision, with 1 being the only revision in existence) in |
258 | hyst = i2c_smbus_read_word_data(new_client, 2); | 261 | register 7, and unused registers return 0xff rather than the |
259 | if (i2c_smbus_read_word_data(new_client, 4) != hyst | 262 | last read value. */ |
260 | || i2c_smbus_read_word_data(new_client, 5) != hyst | ||
261 | || i2c_smbus_read_word_data(new_client, 6) != hyst | ||
262 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | ||
263 | return -ENODEV; | ||
264 | os = i2c_smbus_read_word_data(new_client, 3); | ||
265 | if (i2c_smbus_read_word_data(new_client, 4) != os | ||
266 | || i2c_smbus_read_word_data(new_client, 5) != os | ||
267 | || i2c_smbus_read_word_data(new_client, 6) != os | ||
268 | || i2c_smbus_read_word_data(new_client, 7) != os) | ||
269 | return -ENODEV; | ||
270 | 263 | ||
271 | /* Unused bits */ | 264 | /* Unused bits */ |
265 | conf = i2c_smbus_read_byte_data(new_client, 1); | ||
272 | if (conf & 0xe0) | 266 | if (conf & 0xe0) |
273 | return -ENODEV; | 267 | return -ENODEV; |
274 | 268 | ||
269 | /* First check for LM75A */ | ||
270 | if (i2c_smbus_read_byte_data(new_client, 7) == LM75A_ID) { | ||
271 | /* LM75A returns 0xff on unused registers so | ||
272 | just to be sure we check for that too. */ | ||
273 | if (i2c_smbus_read_byte_data(new_client, 4) != 0xff | ||
274 | || i2c_smbus_read_byte_data(new_client, 5) != 0xff | ||
275 | || i2c_smbus_read_byte_data(new_client, 6) != 0xff) | ||
276 | return -ENODEV; | ||
277 | is_lm75a = 1; | ||
278 | hyst = i2c_smbus_read_byte_data(new_client, 2); | ||
279 | os = i2c_smbus_read_byte_data(new_client, 3); | ||
280 | } else { /* Traditional style LM75 detection */ | ||
281 | /* Unused addresses */ | ||
282 | hyst = i2c_smbus_read_byte_data(new_client, 2); | ||
283 | if (i2c_smbus_read_byte_data(new_client, 4) != hyst | ||
284 | || i2c_smbus_read_byte_data(new_client, 5) != hyst | ||
285 | || i2c_smbus_read_byte_data(new_client, 6) != hyst | ||
286 | || i2c_smbus_read_byte_data(new_client, 7) != hyst) | ||
287 | return -ENODEV; | ||
288 | os = i2c_smbus_read_byte_data(new_client, 3); | ||
289 | if (i2c_smbus_read_byte_data(new_client, 4) != os | ||
290 | || i2c_smbus_read_byte_data(new_client, 5) != os | ||
291 | || i2c_smbus_read_byte_data(new_client, 6) != os | ||
292 | || i2c_smbus_read_byte_data(new_client, 7) != os) | ||
293 | return -ENODEV; | ||
294 | } | ||
295 | |||
275 | /* Addresses cycling */ | 296 | /* Addresses cycling */ |
276 | for (i = 8; i < 0xff; i += 8) { | 297 | for (i = 8; i <= 248; i += 40) { |
277 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | 298 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf |
278 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | 299 | || i2c_smbus_read_byte_data(new_client, i + 2) != hyst |
279 | || i2c_smbus_read_word_data(new_client, i + 3) != os) | 300 | || i2c_smbus_read_byte_data(new_client, i + 3) != os) |
301 | return -ENODEV; | ||
302 | if (is_lm75a && i2c_smbus_read_byte_data(new_client, i + 7) | ||
303 | != LM75A_ID) | ||
280 | return -ENODEV; | 304 | return -ENODEV; |
281 | } | 305 | } |
282 | 306 | ||
283 | strlcpy(info->type, "lm75", I2C_NAME_SIZE); | 307 | strlcpy(info->type, is_lm75a ? "lm75a" : "lm75", I2C_NAME_SIZE); |
284 | 308 | ||
285 | return 0; | 309 | return 0; |
286 | } | 310 | } |
diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c new file mode 100644 index 000000000000..9a51dcca9b0d --- /dev/null +++ b/drivers/hwmon/sch5627.c | |||
@@ -0,0 +1,858 @@ | |||
1 | /*************************************************************************** | ||
2 | * Copyright (C) 2010-2011 Hans de Goede <hdegoede@redhat.com> * | ||
3 | * * | ||
4 | * This program is free software; you can redistribute it and/or modify * | ||
5 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * (at your option) any later version. * | ||
8 | * * | ||
9 | * This program is distributed in the hope that it will be useful, * | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
12 | * GNU General Public License for more details. * | ||
13 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | ||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | ||
18 | ***************************************************************************/ | ||
19 | |||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/jiffies.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/hwmon.h> | ||
28 | #include <linux/hwmon-sysfs.h> | ||
29 | #include <linux/err.h> | ||
30 | #include <linux/mutex.h> | ||
31 | #include <linux/io.h> | ||
32 | #include <linux/acpi.h> | ||
33 | #include <linux/delay.h> | ||
34 | |||
35 | #define DRVNAME "sch5627" | ||
36 | #define DEVNAME DRVNAME /* We only support one model */ | ||
37 | |||
38 | #define SIO_SCH5627_EM_LD 0x0C /* Embedded Microcontroller LD */ | ||
39 | #define SIO_UNLOCK_KEY 0x55 /* Key to enable Super-I/O */ | ||
40 | #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */ | ||
41 | |||
42 | #define SIO_REG_LDSEL 0x07 /* Logical device select */ | ||
43 | #define SIO_REG_DEVID 0x20 /* Device ID */ | ||
44 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ | ||
45 | #define SIO_REG_ADDR 0x66 /* Logical device address (2 bytes) */ | ||
46 | |||
47 | #define SIO_SCH5627_ID 0xC6 /* Chipset ID */ | ||
48 | |||
49 | #define REGION_LENGTH 9 | ||
50 | |||
51 | #define SCH5627_HWMON_ID 0xa5 | ||
52 | #define SCH5627_COMPANY_ID 0x5c | ||
53 | #define SCH5627_PRIMARY_ID 0xa0 | ||
54 | |||
55 | #define SCH5627_REG_BUILD_CODE 0x39 | ||
56 | #define SCH5627_REG_BUILD_ID 0x3a | ||
57 | #define SCH5627_REG_HWMON_ID 0x3c | ||
58 | #define SCH5627_REG_HWMON_REV 0x3d | ||
59 | #define SCH5627_REG_COMPANY_ID 0x3e | ||
60 | #define SCH5627_REG_PRIMARY_ID 0x3f | ||
61 | #define SCH5627_REG_CTRL 0x40 | ||
62 | |||
63 | #define SCH5627_NO_TEMPS 8 | ||
64 | #define SCH5627_NO_FANS 4 | ||
65 | #define SCH5627_NO_IN 5 | ||
66 | |||
67 | static const u16 SCH5627_REG_TEMP_MSB[SCH5627_NO_TEMPS] = { | ||
68 | 0x2B, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x180, 0x181 }; | ||
69 | static const u16 SCH5627_REG_TEMP_LSN[SCH5627_NO_TEMPS] = { | ||
70 | 0xE2, 0xE1, 0xE1, 0xE5, 0xE5, 0xE6, 0x182, 0x182 }; | ||
71 | static const u16 SCH5627_REG_TEMP_HIGH_NIBBLE[SCH5627_NO_TEMPS] = { | ||
72 | 0, 0, 1, 1, 0, 0, 0, 1 }; | ||
73 | static const u16 SCH5627_REG_TEMP_HIGH[SCH5627_NO_TEMPS] = { | ||
74 | 0x61, 0x57, 0x59, 0x5B, 0x5D, 0x5F, 0x184, 0x186 }; | ||
75 | static const u16 SCH5627_REG_TEMP_ABS[SCH5627_NO_TEMPS] = { | ||
76 | 0x9B, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x1A8, 0x1A9 }; | ||
77 | |||
78 | static const u16 SCH5627_REG_FAN[SCH5627_NO_FANS] = { | ||
79 | 0x2C, 0x2E, 0x30, 0x32 }; | ||
80 | static const u16 SCH5627_REG_FAN_MIN[SCH5627_NO_FANS] = { | ||
81 | 0x62, 0x64, 0x66, 0x68 }; | ||
82 | |||
83 | static const u16 SCH5627_REG_IN_MSB[SCH5627_NO_IN] = { | ||
84 | 0x22, 0x23, 0x24, 0x25, 0x189 }; | ||
85 | static const u16 SCH5627_REG_IN_LSN[SCH5627_NO_IN] = { | ||
86 | 0xE4, 0xE4, 0xE3, 0xE3, 0x18A }; | ||
87 | static const u16 SCH5627_REG_IN_HIGH_NIBBLE[SCH5627_NO_IN] = { | ||
88 | 1, 0, 1, 0, 1 }; | ||
89 | static const u16 SCH5627_REG_IN_FACTOR[SCH5627_NO_IN] = { | ||
90 | 10745, 3660, 9765, 10745, 3660 }; | ||
91 | static const char * const SCH5627_IN_LABELS[SCH5627_NO_IN] = { | ||
92 | "VCC", "VTT", "VBAT", "VTR", "V_IN" }; | ||
93 | |||
94 | struct sch5627_data { | ||
95 | unsigned short addr; | ||
96 | struct device *hwmon_dev; | ||
97 | u8 temp_max[SCH5627_NO_TEMPS]; | ||
98 | u8 temp_crit[SCH5627_NO_TEMPS]; | ||
99 | u16 fan_min[SCH5627_NO_FANS]; | ||
100 | |||
101 | struct mutex update_lock; | ||
102 | char valid; /* !=0 if following fields are valid */ | ||
103 | unsigned long last_updated; /* In jiffies */ | ||
104 | u16 temp[SCH5627_NO_TEMPS]; | ||
105 | u16 fan[SCH5627_NO_FANS]; | ||
106 | u16 in[SCH5627_NO_IN]; | ||
107 | }; | ||
108 | |||
109 | static struct platform_device *sch5627_pdev; | ||
110 | |||
111 | /* Super I/O functions */ | ||
112 | static inline int superio_inb(int base, int reg) | ||
113 | { | ||
114 | outb(reg, base); | ||
115 | return inb(base + 1); | ||
116 | } | ||
117 | |||
118 | static inline int superio_enter(int base) | ||
119 | { | ||
120 | /* Don't step on other drivers' I/O space by accident */ | ||
121 | if (!request_muxed_region(base, 2, DRVNAME)) { | ||
122 | pr_err("I/O address 0x%04x already in use\n", base); | ||
123 | return -EBUSY; | ||
124 | } | ||
125 | |||
126 | outb(SIO_UNLOCK_KEY, base); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static inline void superio_select(int base, int ld) | ||
132 | { | ||
133 | outb(SIO_REG_LDSEL, base); | ||
134 | outb(ld, base + 1); | ||
135 | } | ||
136 | |||
137 | static inline void superio_exit(int base) | ||
138 | { | ||
139 | outb(SIO_LOCK_KEY, base); | ||
140 | release_region(base, 2); | ||
141 | } | ||
142 | |||
143 | static int sch5627_read_virtual_reg(struct sch5627_data *data, u16 reg) | ||
144 | { | ||
145 | u8 val; | ||
146 | int i; | ||
147 | /* | ||
148 | * According to SMSC for the commands we use the maximum time for | ||
149 | * the EM to respond is 15 ms, but testing shows in practice it | ||
150 | * responds within 15-32 reads, so we first busy poll, and if | ||
151 | * that fails sleep a bit and try again until we are way past | ||
152 | * the 15 ms maximum response time. | ||
153 | */ | ||
154 | const int max_busy_polls = 64; | ||
155 | const int max_lazy_polls = 32; | ||
156 | |||
157 | /* (Optional) Write-Clear the EC to Host Mailbox Register */ | ||
158 | val = inb(data->addr + 1); | ||
159 | outb(val, data->addr + 1); | ||
160 | |||
161 | /* Set Mailbox Address Pointer to first location in Region 1 */ | ||
162 | outb(0x00, data->addr + 2); | ||
163 | outb(0x80, data->addr + 3); | ||
164 | |||
165 | /* Write Request Packet Header */ | ||
166 | outb(0x02, data->addr + 4); /* Access Type: VREG read */ | ||
167 | outb(0x01, data->addr + 5); /* # of Entries: 1 Byte (8-bit) */ | ||
168 | outb(0x04, data->addr + 2); /* Mailbox AP to first data entry loc. */ | ||
169 | |||
170 | /* Write Address field */ | ||
171 | outb(reg & 0xff, data->addr + 6); | ||
172 | outb(reg >> 8, data->addr + 7); | ||
173 | |||
174 | /* Execute the Random Access Command */ | ||
175 | outb(0x01, data->addr); /* Write 01h to the Host-to-EC register */ | ||
176 | |||
177 | /* EM Interface Polling "Algorithm" */ | ||
178 | for (i = 0; i < max_busy_polls + max_lazy_polls; i++) { | ||
179 | if (i >= max_busy_polls) | ||
180 | msleep(1); | ||
181 | /* Read Interrupt source Register */ | ||
182 | val = inb(data->addr + 8); | ||
183 | /* Write Clear the interrupt source bits */ | ||
184 | if (val) | ||
185 | outb(val, data->addr + 8); | ||
186 | /* Command Completed ? */ | ||
187 | if (val & 0x01) | ||
188 | break; | ||
189 | } | ||
190 | if (i == max_busy_polls + max_lazy_polls) { | ||
191 | pr_err("Max retries exceeded reading virtual " | ||
192 | "register 0x%04hx (%d)\n", reg, 1); | ||
193 | return -EIO; | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * According to SMSC we may need to retry this, but sofar I've always | ||
198 | * seen this succeed in 1 try. | ||
199 | */ | ||
200 | for (i = 0; i < max_busy_polls; i++) { | ||
201 | /* Read EC-to-Host Register */ | ||
202 | val = inb(data->addr + 1); | ||
203 | /* Command Completed ? */ | ||
204 | if (val == 0x01) | ||
205 | break; | ||
206 | |||
207 | if (i == 0) | ||
208 | pr_warn("EC reports: 0x%02x reading virtual register " | ||
209 | "0x%04hx\n", (unsigned int)val, reg); | ||
210 | } | ||
211 | if (i == max_busy_polls) { | ||
212 | pr_err("Max retries exceeded reading virtual " | ||
213 | "register 0x%04hx (%d)\n", reg, 2); | ||
214 | return -EIO; | ||
215 | } | ||
216 | |||
217 | /* | ||
218 | * According to the SMSC app note we should now do: | ||
219 | * | ||
220 | * Set Mailbox Address Pointer to first location in Region 1 * | ||
221 | * outb(0x00, data->addr + 2); | ||
222 | * outb(0x80, data->addr + 3); | ||
223 | * | ||
224 | * But if we do that things don't work, so let's not. | ||
225 | */ | ||
226 | |||
227 | /* Read Data from Mailbox */ | ||
228 | return inb(data->addr + 4); | ||
229 | } | ||
230 | |||
231 | static int sch5627_read_virtual_reg16(struct sch5627_data *data, u16 reg) | ||
232 | { | ||
233 | int lsb, msb; | ||
234 | |||
235 | /* Read LSB first, this will cause the matching MSB to be latched */ | ||
236 | lsb = sch5627_read_virtual_reg(data, reg); | ||
237 | if (lsb < 0) | ||
238 | return lsb; | ||
239 | |||
240 | msb = sch5627_read_virtual_reg(data, reg + 1); | ||
241 | if (msb < 0) | ||
242 | return msb; | ||
243 | |||
244 | return lsb | (msb << 8); | ||
245 | } | ||
246 | |||
247 | static int sch5627_read_virtual_reg12(struct sch5627_data *data, u16 msb_reg, | ||
248 | u16 lsn_reg, int high_nibble) | ||
249 | { | ||
250 | int msb, lsn; | ||
251 | |||
252 | /* Read MSB first, this will cause the matching LSN to be latched */ | ||
253 | msb = sch5627_read_virtual_reg(data, msb_reg); | ||
254 | if (msb < 0) | ||
255 | return msb; | ||
256 | |||
257 | lsn = sch5627_read_virtual_reg(data, lsn_reg); | ||
258 | if (lsn < 0) | ||
259 | return lsn; | ||
260 | |||
261 | if (high_nibble) | ||
262 | return (msb << 4) | (lsn >> 4); | ||
263 | else | ||
264 | return (msb << 4) | (lsn & 0x0f); | ||
265 | } | ||
266 | |||
267 | static struct sch5627_data *sch5627_update_device(struct device *dev) | ||
268 | { | ||
269 | struct sch5627_data *data = dev_get_drvdata(dev); | ||
270 | struct sch5627_data *ret = data; | ||
271 | int i, val; | ||
272 | |||
273 | mutex_lock(&data->update_lock); | ||
274 | |||
275 | /* Cache the values for 1 second */ | ||
276 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | ||
277 | for (i = 0; i < SCH5627_NO_TEMPS; i++) { | ||
278 | val = sch5627_read_virtual_reg12(data, | ||
279 | SCH5627_REG_TEMP_MSB[i], | ||
280 | SCH5627_REG_TEMP_LSN[i], | ||
281 | SCH5627_REG_TEMP_HIGH_NIBBLE[i]); | ||
282 | if (unlikely(val < 0)) { | ||
283 | ret = ERR_PTR(val); | ||
284 | goto abort; | ||
285 | } | ||
286 | data->temp[i] = val; | ||
287 | } | ||
288 | |||
289 | for (i = 0; i < SCH5627_NO_FANS; i++) { | ||
290 | val = sch5627_read_virtual_reg16(data, | ||
291 | SCH5627_REG_FAN[i]); | ||
292 | if (unlikely(val < 0)) { | ||
293 | ret = ERR_PTR(val); | ||
294 | goto abort; | ||
295 | } | ||
296 | data->fan[i] = val; | ||
297 | } | ||
298 | |||
299 | for (i = 0; i < SCH5627_NO_IN; i++) { | ||
300 | val = sch5627_read_virtual_reg12(data, | ||
301 | SCH5627_REG_IN_MSB[i], | ||
302 | SCH5627_REG_IN_LSN[i], | ||
303 | SCH5627_REG_IN_HIGH_NIBBLE[i]); | ||
304 | if (unlikely(val < 0)) { | ||
305 | ret = ERR_PTR(val); | ||
306 | goto abort; | ||
307 | } | ||
308 | data->in[i] = val; | ||
309 | } | ||
310 | |||
311 | data->last_updated = jiffies; | ||
312 | data->valid = 1; | ||
313 | } | ||
314 | abort: | ||
315 | mutex_unlock(&data->update_lock); | ||
316 | return ret; | ||
317 | } | ||
318 | |||
319 | static int __devinit sch5627_read_limits(struct sch5627_data *data) | ||
320 | { | ||
321 | int i, val; | ||
322 | |||
323 | for (i = 0; i < SCH5627_NO_TEMPS; i++) { | ||
324 | /* | ||
325 | * Note what SMSC calls ABS, is what lm_sensors calls max | ||
326 | * (aka high), and HIGH is what lm_sensors calls crit. | ||
327 | */ | ||
328 | val = sch5627_read_virtual_reg(data, SCH5627_REG_TEMP_ABS[i]); | ||
329 | if (val < 0) | ||
330 | return val; | ||
331 | data->temp_max[i] = val; | ||
332 | |||
333 | val = sch5627_read_virtual_reg(data, SCH5627_REG_TEMP_HIGH[i]); | ||
334 | if (val < 0) | ||
335 | return val; | ||
336 | data->temp_crit[i] = val; | ||
337 | } | ||
338 | for (i = 0; i < SCH5627_NO_FANS; i++) { | ||
339 | val = sch5627_read_virtual_reg16(data, SCH5627_REG_FAN_MIN[i]); | ||
340 | if (val < 0) | ||
341 | return val; | ||
342 | data->fan_min[i] = val; | ||
343 | } | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static int reg_to_temp(u16 reg) | ||
349 | { | ||
350 | return (reg * 625) / 10 - 64000; | ||
351 | } | ||
352 | |||
353 | static int reg_to_temp_limit(u8 reg) | ||
354 | { | ||
355 | return (reg - 64) * 1000; | ||
356 | } | ||
357 | |||
358 | static int reg_to_rpm(u16 reg) | ||
359 | { | ||
360 | if (reg == 0) | ||
361 | return -EIO; | ||
362 | if (reg == 0xffff) | ||
363 | return 0; | ||
364 | |||
365 | return 5400540 / reg; | ||
366 | } | ||
367 | |||
368 | static ssize_t show_name(struct device *dev, struct device_attribute *devattr, | ||
369 | char *buf) | ||
370 | { | ||
371 | return snprintf(buf, PAGE_SIZE, "%s\n", DEVNAME); | ||
372 | } | ||
373 | |||
374 | static ssize_t show_temp(struct device *dev, struct device_attribute | ||
375 | *devattr, char *buf) | ||
376 | { | ||
377 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
378 | struct sch5627_data *data = sch5627_update_device(dev); | ||
379 | int val; | ||
380 | |||
381 | if (IS_ERR(data)) | ||
382 | return PTR_ERR(data); | ||
383 | |||
384 | val = reg_to_temp(data->temp[attr->index]); | ||
385 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
386 | } | ||
387 | |||
388 | static ssize_t show_temp_fault(struct device *dev, struct device_attribute | ||
389 | *devattr, char *buf) | ||
390 | { | ||
391 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
392 | struct sch5627_data *data = sch5627_update_device(dev); | ||
393 | |||
394 | if (IS_ERR(data)) | ||
395 | return PTR_ERR(data); | ||
396 | |||
397 | return snprintf(buf, PAGE_SIZE, "%d\n", data->temp[attr->index] == 0); | ||
398 | } | ||
399 | |||
400 | static ssize_t show_temp_max(struct device *dev, struct device_attribute | ||
401 | *devattr, char *buf) | ||
402 | { | ||
403 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
404 | struct sch5627_data *data = dev_get_drvdata(dev); | ||
405 | int val; | ||
406 | |||
407 | val = reg_to_temp_limit(data->temp_max[attr->index]); | ||
408 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
409 | } | ||
410 | |||
411 | static ssize_t show_temp_crit(struct device *dev, struct device_attribute | ||
412 | *devattr, char *buf) | ||
413 | { | ||
414 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
415 | struct sch5627_data *data = dev_get_drvdata(dev); | ||
416 | int val; | ||
417 | |||
418 | val = reg_to_temp_limit(data->temp_crit[attr->index]); | ||
419 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
420 | } | ||
421 | |||
422 | static ssize_t show_fan(struct device *dev, struct device_attribute | ||
423 | *devattr, char *buf) | ||
424 | { | ||
425 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
426 | struct sch5627_data *data = sch5627_update_device(dev); | ||
427 | int val; | ||
428 | |||
429 | if (IS_ERR(data)) | ||
430 | return PTR_ERR(data); | ||
431 | |||
432 | val = reg_to_rpm(data->fan[attr->index]); | ||
433 | if (val < 0) | ||
434 | return val; | ||
435 | |||
436 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
437 | } | ||
438 | |||
439 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute | ||
440 | *devattr, char *buf) | ||
441 | { | ||
442 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
443 | struct sch5627_data *data = sch5627_update_device(dev); | ||
444 | |||
445 | if (IS_ERR(data)) | ||
446 | return PTR_ERR(data); | ||
447 | |||
448 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
449 | data->fan[attr->index] == 0xffff); | ||
450 | } | ||
451 | |||
452 | static ssize_t show_fan_min(struct device *dev, struct device_attribute | ||
453 | *devattr, char *buf) | ||
454 | { | ||
455 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
456 | struct sch5627_data *data = dev_get_drvdata(dev); | ||
457 | int val = reg_to_rpm(data->fan_min[attr->index]); | ||
458 | if (val < 0) | ||
459 | return val; | ||
460 | |||
461 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
462 | } | ||
463 | |||
464 | static ssize_t show_in(struct device *dev, struct device_attribute | ||
465 | *devattr, char *buf) | ||
466 | { | ||
467 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
468 | struct sch5627_data *data = sch5627_update_device(dev); | ||
469 | int val; | ||
470 | |||
471 | if (IS_ERR(data)) | ||
472 | return PTR_ERR(data); | ||
473 | |||
474 | val = DIV_ROUND_CLOSEST( | ||
475 | data->in[attr->index] * SCH5627_REG_IN_FACTOR[attr->index], | ||
476 | 10000); | ||
477 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | ||
478 | } | ||
479 | |||
480 | static ssize_t show_in_label(struct device *dev, struct device_attribute | ||
481 | *devattr, char *buf) | ||
482 | { | ||
483 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
484 | |||
485 | return snprintf(buf, PAGE_SIZE, "%s\n", | ||
486 | SCH5627_IN_LABELS[attr->index]); | ||
487 | } | ||
488 | |||
489 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | ||
490 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | ||
491 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | ||
492 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); | ||
493 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); | ||
494 | static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); | ||
495 | static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5); | ||
496 | static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp, NULL, 6); | ||
497 | static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp, NULL, 7); | ||
498 | static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); | ||
499 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); | ||
500 | static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2); | ||
501 | static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3); | ||
502 | static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_temp_fault, NULL, 4); | ||
503 | static SENSOR_DEVICE_ATTR(temp6_fault, S_IRUGO, show_temp_fault, NULL, 5); | ||
504 | static SENSOR_DEVICE_ATTR(temp7_fault, S_IRUGO, show_temp_fault, NULL, 6); | ||
505 | static SENSOR_DEVICE_ATTR(temp8_fault, S_IRUGO, show_temp_fault, NULL, 7); | ||
506 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_max, NULL, 0); | ||
507 | static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO, show_temp_max, NULL, 1); | ||
508 | static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO, show_temp_max, NULL, 2); | ||
509 | static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO, show_temp_max, NULL, 3); | ||
510 | static SENSOR_DEVICE_ATTR(temp5_max, S_IRUGO, show_temp_max, NULL, 4); | ||
511 | static SENSOR_DEVICE_ATTR(temp6_max, S_IRUGO, show_temp_max, NULL, 5); | ||
512 | static SENSOR_DEVICE_ATTR(temp7_max, S_IRUGO, show_temp_max, NULL, 6); | ||
513 | static SENSOR_DEVICE_ATTR(temp8_max, S_IRUGO, show_temp_max, NULL, 7); | ||
514 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL, 0); | ||
515 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL, 1); | ||
516 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit, NULL, 2); | ||
517 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL, 3); | ||
518 | static SENSOR_DEVICE_ATTR(temp5_crit, S_IRUGO, show_temp_crit, NULL, 4); | ||
519 | static SENSOR_DEVICE_ATTR(temp6_crit, S_IRUGO, show_temp_crit, NULL, 5); | ||
520 | static SENSOR_DEVICE_ATTR(temp7_crit, S_IRUGO, show_temp_crit, NULL, 6); | ||
521 | static SENSOR_DEVICE_ATTR(temp8_crit, S_IRUGO, show_temp_crit, NULL, 7); | ||
522 | |||
523 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | ||
524 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | ||
525 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); | ||
526 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); | ||
527 | static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL, 0); | ||
528 | static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_fan_fault, NULL, 1); | ||
529 | static SENSOR_DEVICE_ATTR(fan3_fault, S_IRUGO, show_fan_fault, NULL, 2); | ||
530 | static SENSOR_DEVICE_ATTR(fan4_fault, S_IRUGO, show_fan_fault, NULL, 3); | ||
531 | static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, show_fan_min, NULL, 0); | ||
532 | static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO, show_fan_min, NULL, 1); | ||
533 | static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO, show_fan_min, NULL, 2); | ||
534 | static SENSOR_DEVICE_ATTR(fan4_min, S_IRUGO, show_fan_min, NULL, 3); | ||
535 | |||
536 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0); | ||
537 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); | ||
538 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2); | ||
539 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3); | ||
540 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4); | ||
541 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_in_label, NULL, 0); | ||
542 | static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_in_label, NULL, 1); | ||
543 | static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_in_label, NULL, 2); | ||
544 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_in_label, NULL, 3); | ||
545 | |||
546 | static struct attribute *sch5627_attributes[] = { | ||
547 | &dev_attr_name.attr, | ||
548 | |||
549 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
550 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
551 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
552 | &sensor_dev_attr_temp4_input.dev_attr.attr, | ||
553 | &sensor_dev_attr_temp5_input.dev_attr.attr, | ||
554 | &sensor_dev_attr_temp6_input.dev_attr.attr, | ||
555 | &sensor_dev_attr_temp7_input.dev_attr.attr, | ||
556 | &sensor_dev_attr_temp8_input.dev_attr.attr, | ||
557 | &sensor_dev_attr_temp1_fault.dev_attr.attr, | ||
558 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | ||
559 | &sensor_dev_attr_temp3_fault.dev_attr.attr, | ||
560 | &sensor_dev_attr_temp4_fault.dev_attr.attr, | ||
561 | &sensor_dev_attr_temp5_fault.dev_attr.attr, | ||
562 | &sensor_dev_attr_temp6_fault.dev_attr.attr, | ||
563 | &sensor_dev_attr_temp7_fault.dev_attr.attr, | ||
564 | &sensor_dev_attr_temp8_fault.dev_attr.attr, | ||
565 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
566 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
567 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
568 | &sensor_dev_attr_temp4_max.dev_attr.attr, | ||
569 | &sensor_dev_attr_temp5_max.dev_attr.attr, | ||
570 | &sensor_dev_attr_temp6_max.dev_attr.attr, | ||
571 | &sensor_dev_attr_temp7_max.dev_attr.attr, | ||
572 | &sensor_dev_attr_temp8_max.dev_attr.attr, | ||
573 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | ||
574 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | ||
575 | &sensor_dev_attr_temp3_crit.dev_attr.attr, | ||
576 | &sensor_dev_attr_temp4_crit.dev_attr.attr, | ||
577 | &sensor_dev_attr_temp5_crit.dev_attr.attr, | ||
578 | &sensor_dev_attr_temp6_crit.dev_attr.attr, | ||
579 | &sensor_dev_attr_temp7_crit.dev_attr.attr, | ||
580 | &sensor_dev_attr_temp8_crit.dev_attr.attr, | ||
581 | |||
582 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
583 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
584 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
585 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
586 | &sensor_dev_attr_fan1_fault.dev_attr.attr, | ||
587 | &sensor_dev_attr_fan2_fault.dev_attr.attr, | ||
588 | &sensor_dev_attr_fan3_fault.dev_attr.attr, | ||
589 | &sensor_dev_attr_fan4_fault.dev_attr.attr, | ||
590 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
591 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
592 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
593 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
594 | |||
595 | &sensor_dev_attr_in0_input.dev_attr.attr, | ||
596 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
597 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
598 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
599 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
600 | &sensor_dev_attr_in0_label.dev_attr.attr, | ||
601 | &sensor_dev_attr_in1_label.dev_attr.attr, | ||
602 | &sensor_dev_attr_in2_label.dev_attr.attr, | ||
603 | &sensor_dev_attr_in3_label.dev_attr.attr, | ||
604 | /* No in4_label as in4 is a generic input pin */ | ||
605 | |||
606 | NULL | ||
607 | }; | ||
608 | |||
609 | static const struct attribute_group sch5627_group = { | ||
610 | .attrs = sch5627_attributes, | ||
611 | }; | ||
612 | |||
613 | static int sch5627_remove(struct platform_device *pdev) | ||
614 | { | ||
615 | struct sch5627_data *data = platform_get_drvdata(pdev); | ||
616 | |||
617 | if (data->hwmon_dev) | ||
618 | hwmon_device_unregister(data->hwmon_dev); | ||
619 | |||
620 | sysfs_remove_group(&pdev->dev.kobj, &sch5627_group); | ||
621 | platform_set_drvdata(pdev, NULL); | ||
622 | kfree(data); | ||
623 | |||
624 | return 0; | ||
625 | } | ||
626 | |||
627 | static int __devinit sch5627_probe(struct platform_device *pdev) | ||
628 | { | ||
629 | struct sch5627_data *data; | ||
630 | int err, build_code, build_id, hwmon_rev, val; | ||
631 | |||
632 | data = kzalloc(sizeof(struct sch5627_data), GFP_KERNEL); | ||
633 | if (!data) | ||
634 | return -ENOMEM; | ||
635 | |||
636 | data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; | ||
637 | mutex_init(&data->update_lock); | ||
638 | platform_set_drvdata(pdev, data); | ||
639 | |||
640 | val = sch5627_read_virtual_reg(data, SCH5627_REG_HWMON_ID); | ||
641 | if (val < 0) { | ||
642 | err = val; | ||
643 | goto error; | ||
644 | } | ||
645 | if (val != SCH5627_HWMON_ID) { | ||
646 | pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "hwmon", | ||
647 | val, SCH5627_HWMON_ID); | ||
648 | err = -ENODEV; | ||
649 | goto error; | ||
650 | } | ||
651 | |||
652 | val = sch5627_read_virtual_reg(data, SCH5627_REG_COMPANY_ID); | ||
653 | if (val < 0) { | ||
654 | err = val; | ||
655 | goto error; | ||
656 | } | ||
657 | if (val != SCH5627_COMPANY_ID) { | ||
658 | pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "company", | ||
659 | val, SCH5627_COMPANY_ID); | ||
660 | err = -ENODEV; | ||
661 | goto error; | ||
662 | } | ||
663 | |||
664 | val = sch5627_read_virtual_reg(data, SCH5627_REG_PRIMARY_ID); | ||
665 | if (val < 0) { | ||
666 | err = val; | ||
667 | goto error; | ||
668 | } | ||
669 | if (val != SCH5627_PRIMARY_ID) { | ||
670 | pr_err("invalid %s id: 0x%02X (expected 0x%02X)\n", "primary", | ||
671 | val, SCH5627_PRIMARY_ID); | ||
672 | err = -ENODEV; | ||
673 | goto error; | ||
674 | } | ||
675 | |||
676 | build_code = sch5627_read_virtual_reg(data, SCH5627_REG_BUILD_CODE); | ||
677 | if (build_code < 0) { | ||
678 | err = build_code; | ||
679 | goto error; | ||
680 | } | ||
681 | |||
682 | build_id = sch5627_read_virtual_reg16(data, SCH5627_REG_BUILD_ID); | ||
683 | if (build_id < 0) { | ||
684 | err = build_id; | ||
685 | goto error; | ||
686 | } | ||
687 | |||
688 | hwmon_rev = sch5627_read_virtual_reg(data, SCH5627_REG_HWMON_REV); | ||
689 | if (hwmon_rev < 0) { | ||
690 | err = hwmon_rev; | ||
691 | goto error; | ||
692 | } | ||
693 | |||
694 | val = sch5627_read_virtual_reg(data, SCH5627_REG_CTRL); | ||
695 | if (val < 0) { | ||
696 | err = val; | ||
697 | goto error; | ||
698 | } | ||
699 | if (!(val & 0x01)) { | ||
700 | pr_err("hardware monitoring not enabled\n"); | ||
701 | err = -ENODEV; | ||
702 | goto error; | ||
703 | } | ||
704 | |||
705 | /* | ||
706 | * Read limits, we do this only once as reading a register on | ||
707 | * the sch5627 is quite expensive (and they don't change). | ||
708 | */ | ||
709 | err = sch5627_read_limits(data); | ||
710 | if (err) | ||
711 | goto error; | ||
712 | |||
713 | pr_info("firmware build: code 0x%02X, id 0x%04X, hwmon: rev 0x%02X\n", | ||
714 | build_code, build_id, hwmon_rev); | ||
715 | |||
716 | /* Register sysfs interface files */ | ||
717 | err = sysfs_create_group(&pdev->dev.kobj, &sch5627_group); | ||
718 | if (err) | ||
719 | goto error; | ||
720 | |||
721 | data->hwmon_dev = hwmon_device_register(&pdev->dev); | ||
722 | if (IS_ERR(data->hwmon_dev)) { | ||
723 | err = PTR_ERR(data->hwmon_dev); | ||
724 | data->hwmon_dev = NULL; | ||
725 | goto error; | ||
726 | } | ||
727 | |||
728 | return 0; | ||
729 | |||
730 | error: | ||
731 | sch5627_remove(pdev); | ||
732 | return err; | ||
733 | } | ||
734 | |||
735 | static int __init sch5627_find(int sioaddr, unsigned short *address) | ||
736 | { | ||
737 | u8 devid; | ||
738 | int err = superio_enter(sioaddr); | ||
739 | if (err) | ||
740 | return err; | ||
741 | |||
742 | devid = superio_inb(sioaddr, SIO_REG_DEVID); | ||
743 | if (devid != SIO_SCH5627_ID) { | ||
744 | pr_debug("Unsupported device id: 0x%02x\n", | ||
745 | (unsigned int)devid); | ||
746 | err = -ENODEV; | ||
747 | goto exit; | ||
748 | } | ||
749 | |||
750 | superio_select(sioaddr, SIO_SCH5627_EM_LD); | ||
751 | |||
752 | if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { | ||
753 | pr_warn("Device not activated\n"); | ||
754 | err = -ENODEV; | ||
755 | goto exit; | ||
756 | } | ||
757 | |||
758 | /* | ||
759 | * Warning the order of the low / high byte is the other way around | ||
760 | * as on most other superio devices!! | ||
761 | */ | ||
762 | *address = superio_inb(sioaddr, SIO_REG_ADDR) | | ||
763 | superio_inb(sioaddr, SIO_REG_ADDR + 1) << 8; | ||
764 | if (*address == 0) { | ||
765 | pr_warn("Base address not set\n"); | ||
766 | err = -ENODEV; | ||
767 | goto exit; | ||
768 | } | ||
769 | |||
770 | pr_info("Found %s chip at %#hx\n", DEVNAME, *address); | ||
771 | exit: | ||
772 | superio_exit(sioaddr); | ||
773 | return err; | ||
774 | } | ||
775 | |||
776 | static int __init sch5627_device_add(unsigned short address) | ||
777 | { | ||
778 | struct resource res = { | ||
779 | .start = address, | ||
780 | .end = address + REGION_LENGTH - 1, | ||
781 | .flags = IORESOURCE_IO, | ||
782 | }; | ||
783 | int err; | ||
784 | |||
785 | sch5627_pdev = platform_device_alloc(DRVNAME, address); | ||
786 | if (!sch5627_pdev) | ||
787 | return -ENOMEM; | ||
788 | |||
789 | res.name = sch5627_pdev->name; | ||
790 | err = acpi_check_resource_conflict(&res); | ||
791 | if (err) | ||
792 | goto exit_device_put; | ||
793 | |||
794 | err = platform_device_add_resources(sch5627_pdev, &res, 1); | ||
795 | if (err) { | ||
796 | pr_err("Device resource addition failed\n"); | ||
797 | goto exit_device_put; | ||
798 | } | ||
799 | |||
800 | err = platform_device_add(sch5627_pdev); | ||
801 | if (err) { | ||
802 | pr_err("Device addition failed\n"); | ||
803 | goto exit_device_put; | ||
804 | } | ||
805 | |||
806 | return 0; | ||
807 | |||
808 | exit_device_put: | ||
809 | platform_device_put(sch5627_pdev); | ||
810 | |||
811 | return err; | ||
812 | } | ||
813 | |||
814 | static struct platform_driver sch5627_driver = { | ||
815 | .driver = { | ||
816 | .owner = THIS_MODULE, | ||
817 | .name = DRVNAME, | ||
818 | }, | ||
819 | .probe = sch5627_probe, | ||
820 | .remove = sch5627_remove, | ||
821 | }; | ||
822 | |||
823 | static int __init sch5627_init(void) | ||
824 | { | ||
825 | int err = -ENODEV; | ||
826 | unsigned short address; | ||
827 | |||
828 | if (sch5627_find(0x4e, &address) && sch5627_find(0x2e, &address)) | ||
829 | goto exit; | ||
830 | |||
831 | err = platform_driver_register(&sch5627_driver); | ||
832 | if (err) | ||
833 | goto exit; | ||
834 | |||
835 | err = sch5627_device_add(address); | ||
836 | if (err) | ||
837 | goto exit_driver; | ||
838 | |||
839 | return 0; | ||
840 | |||
841 | exit_driver: | ||
842 | platform_driver_unregister(&sch5627_driver); | ||
843 | exit: | ||
844 | return err; | ||
845 | } | ||
846 | |||
847 | static void __exit sch5627_exit(void) | ||
848 | { | ||
849 | platform_device_unregister(sch5627_pdev); | ||
850 | platform_driver_unregister(&sch5627_driver); | ||
851 | } | ||
852 | |||
853 | MODULE_DESCRIPTION("SMSC SCH5627 Hardware Monitoring Driver"); | ||
854 | MODULE_AUTHOR("Hans de Goede (hdegoede@redhat.com)"); | ||
855 | MODULE_LICENSE("GPL"); | ||
856 | |||
857 | module_init(sch5627_init); | ||
858 | module_exit(sch5627_exit); | ||
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index a610e7880fb3..1a9c32d6893a 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -333,11 +333,11 @@ static inline int sht15_calc_humid(struct sht15_data *data) | |||
333 | 333 | ||
334 | const int c1 = -4; | 334 | const int c1 = -4; |
335 | const int c2 = 40500; /* x 10 ^ -6 */ | 335 | const int c2 = 40500; /* x 10 ^ -6 */ |
336 | const int c3 = -2800; /* x10 ^ -9 */ | 336 | const int c3 = -28; /* x 10 ^ -7 */ |
337 | 337 | ||
338 | RHlinear = c1*1000 | 338 | RHlinear = c1*1000 |
339 | + c2 * data->val_humid/1000 | 339 | + c2 * data->val_humid/1000 |
340 | + (data->val_humid * data->val_humid * c3)/1000000; | 340 | + (data->val_humid * data->val_humid * c3) / 10000; |
341 | return (temp - 25000) * (10000 + 80 * data->val_humid) | 341 | return (temp - 25000) * (10000 + 80 * data->val_humid) |
342 | / 1000000 + RHlinear; | 342 | / 1000000 + RHlinear; |
343 | } | 343 | } |
@@ -610,7 +610,7 @@ static int __devexit sht15_remove(struct platform_device *pdev) | |||
610 | struct sht15_data *data = platform_get_drvdata(pdev); | 610 | struct sht15_data *data = platform_get_drvdata(pdev); |
611 | 611 | ||
612 | /* Make sure any reads from the device are done and | 612 | /* Make sure any reads from the device are done and |
613 | * prevent new ones beginnning */ | 613 | * prevent new ones from beginning */ |
614 | mutex_lock(&data->read_lock); | 614 | mutex_lock(&data->read_lock); |
615 | hwmon_device_unregister(data->hwmon_dev); | 615 | hwmon_device_unregister(data->hwmon_dev); |
616 | sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group); | 616 | sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group); |
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 23ac61e2db39..beee6b2d361d 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile | |||
@@ -10,3 +10,4 @@ obj-$(CONFIG_I2C_MUX) += i2c-mux.o | |||
10 | obj-y += algos/ busses/ muxes/ | 10 | obj-y += algos/ busses/ muxes/ |
11 | 11 | ||
12 | ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG | 12 | ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG |
13 | CFLAGS_i2c-core.o := -Wno-deprecated-declarations | ||
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 230601e8853f..ad415e6ec5a1 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -98,8 +98,9 @@ config I2C_I801 | |||
98 | EP80579 (Tolapai) | 98 | EP80579 (Tolapai) |
99 | ICH10 | 99 | ICH10 |
100 | 5/3400 Series (PCH) | 100 | 5/3400 Series (PCH) |
101 | Cougar Point (PCH) | 101 | 6 Series (PCH) |
102 | Patsburg (PCH) | 102 | Patsburg (PCH) |
103 | DH89xxCC (PCH) | ||
103 | 104 | ||
104 | This driver can also be built as a module. If so, the module | 105 | This driver can also be built as a module. If so, the module |
105 | will be called i2c-i801. | 106 | will be called i2c-i801. |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 7979aef7ee7b..ed2e0c5ea37c 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -44,11 +44,12 @@ | |||
44 | ICH10 0x3a30 32 hard yes yes yes | 44 | ICH10 0x3a30 32 hard yes yes yes |
45 | ICH10 0x3a60 32 hard yes yes yes | 45 | ICH10 0x3a60 32 hard yes yes yes |
46 | 5/3400 Series (PCH) 0x3b30 32 hard yes yes yes | 46 | 5/3400 Series (PCH) 0x3b30 32 hard yes yes yes |
47 | Cougar Point (PCH) 0x1c22 32 hard yes yes yes | 47 | 6 Series (PCH) 0x1c22 32 hard yes yes yes |
48 | Patsburg (PCH) 0x1d22 32 hard yes yes yes | 48 | Patsburg (PCH) 0x1d22 32 hard yes yes yes |
49 | Patsburg (PCH) IDF 0x1d70 32 hard yes yes yes | 49 | Patsburg (PCH) IDF 0x1d70 32 hard yes yes yes |
50 | Patsburg (PCH) IDF 0x1d71 32 hard yes yes yes | 50 | Patsburg (PCH) IDF 0x1d71 32 hard yes yes yes |
51 | Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes | 51 | Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes |
52 | DH89xxCC (PCH) 0x2330 32 hard yes yes yes | ||
52 | 53 | ||
53 | Features supported by this driver: | 54 | Features supported by this driver: |
54 | Software PEC no | 55 | Software PEC no |
@@ -621,6 +622,7 @@ static const struct pci_device_id i801_ids[] = { | |||
621 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0) }, | 622 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0) }, |
622 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1) }, | 623 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1) }, |
623 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, | 624 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, |
625 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, | ||
624 | { 0, } | 626 | { 0, } |
625 | }; | 627 | }; |
626 | 628 | ||
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index 7e6a63b57165..3ca2e012e789 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * i2c-boardinfo.h - collect pre-declarations of I2C devices | 2 | * i2c-boardinfo.c - collect pre-declarations of I2C devices |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 045ba6efea48..e5f76a0372fd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -797,6 +797,9 @@ static int i2c_do_add_adapter(struct i2c_driver *driver, | |||
797 | 797 | ||
798 | /* Let legacy drivers scan this bus for matching devices */ | 798 | /* Let legacy drivers scan this bus for matching devices */ |
799 | if (driver->attach_adapter) { | 799 | if (driver->attach_adapter) { |
800 | dev_warn(&adap->dev, "attach_adapter method is deprecated\n"); | ||
801 | dev_warn(&adap->dev, "Please use another way to instantiate " | ||
802 | "your i2c_client\n"); | ||
800 | /* We ignore the return code; if it fails, too bad */ | 803 | /* We ignore the return code; if it fails, too bad */ |
801 | driver->attach_adapter(adap); | 804 | driver->attach_adapter(adap); |
802 | } | 805 | } |
@@ -981,6 +984,7 @@ static int i2c_do_del_adapter(struct i2c_driver *driver, | |||
981 | 984 | ||
982 | if (!driver->detach_adapter) | 985 | if (!driver->detach_adapter) |
983 | return 0; | 986 | return 0; |
987 | dev_warn(&adapter->dev, "detach_adapter method is deprecated\n"); | ||
984 | res = driver->detach_adapter(adapter); | 988 | res = driver->detach_adapter(adapter); |
985 | if (res) | 989 | if (res) |
986 | dev_err(&adapter->dev, "detach_adapter failed (%d) " | 990 | dev_err(&adapter->dev, "detach_adapter failed (%d) " |
@@ -1091,6 +1095,18 @@ EXPORT_SYMBOL(i2c_del_adapter); | |||
1091 | 1095 | ||
1092 | /* ------------------------------------------------------------------------- */ | 1096 | /* ------------------------------------------------------------------------- */ |
1093 | 1097 | ||
1098 | int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *)) | ||
1099 | { | ||
1100 | int res; | ||
1101 | |||
1102 | mutex_lock(&core_lock); | ||
1103 | res = bus_for_each_dev(&i2c_bus_type, NULL, data, fn); | ||
1104 | mutex_unlock(&core_lock); | ||
1105 | |||
1106 | return res; | ||
1107 | } | ||
1108 | EXPORT_SYMBOL_GPL(i2c_for_each_dev); | ||
1109 | |||
1094 | static int __process_new_driver(struct device *dev, void *data) | 1110 | static int __process_new_driver(struct device *dev, void *data) |
1095 | { | 1111 | { |
1096 | if (dev->type != &i2c_adapter_type) | 1112 | if (dev->type != &i2c_adapter_type) |
@@ -1134,9 +1150,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
1134 | 1150 | ||
1135 | INIT_LIST_HEAD(&driver->clients); | 1151 | INIT_LIST_HEAD(&driver->clients); |
1136 | /* Walk the adapters that are already present */ | 1152 | /* Walk the adapters that are already present */ |
1137 | mutex_lock(&core_lock); | 1153 | i2c_for_each_dev(driver, __process_new_driver); |
1138 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_new_driver); | ||
1139 | mutex_unlock(&core_lock); | ||
1140 | 1154 | ||
1141 | return 0; | 1155 | return 0; |
1142 | } | 1156 | } |
@@ -1156,9 +1170,7 @@ static int __process_removed_driver(struct device *dev, void *data) | |||
1156 | */ | 1170 | */ |
1157 | void i2c_del_driver(struct i2c_driver *driver) | 1171 | void i2c_del_driver(struct i2c_driver *driver) |
1158 | { | 1172 | { |
1159 | mutex_lock(&core_lock); | 1173 | i2c_for_each_dev(driver, __process_removed_driver); |
1160 | bus_for_each_dev(&i2c_bus_type, NULL, driver, __process_removed_driver); | ||
1161 | mutex_unlock(&core_lock); | ||
1162 | 1174 | ||
1163 | driver_unregister(&driver->driver); | 1175 | driver_unregister(&driver->driver); |
1164 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); | 1176 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); |
@@ -1581,12 +1593,12 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1581 | } | 1593 | } |
1582 | EXPORT_SYMBOL_GPL(i2c_new_probed_device); | 1594 | EXPORT_SYMBOL_GPL(i2c_new_probed_device); |
1583 | 1595 | ||
1584 | struct i2c_adapter *i2c_get_adapter(int id) | 1596 | struct i2c_adapter *i2c_get_adapter(int nr) |
1585 | { | 1597 | { |
1586 | struct i2c_adapter *adapter; | 1598 | struct i2c_adapter *adapter; |
1587 | 1599 | ||
1588 | mutex_lock(&core_lock); | 1600 | mutex_lock(&core_lock); |
1589 | adapter = idr_find(&i2c_adapter_idr, id); | 1601 | adapter = idr_find(&i2c_adapter_idr, nr); |
1590 | if (adapter && !try_module_get(adapter->owner)) | 1602 | if (adapter && !try_module_get(adapter->owner)) |
1591 | adapter = NULL; | 1603 | adapter = NULL; |
1592 | 1604 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index cec0f3ba97f8..c90ce50b619f 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/device.h> | ||
32 | #include <linux/notifier.h> | ||
31 | #include <linux/fs.h> | 33 | #include <linux/fs.h> |
32 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
33 | #include <linux/init.h> | 35 | #include <linux/init.h> |
@@ -37,16 +39,13 @@ | |||
37 | #include <linux/jiffies.h> | 39 | #include <linux/jiffies.h> |
38 | #include <linux/uaccess.h> | 40 | #include <linux/uaccess.h> |
39 | 41 | ||
40 | static struct i2c_driver i2cdev_driver; | ||
41 | |||
42 | /* | 42 | /* |
43 | * An i2c_dev represents an i2c_adapter ... an I2C or SMBus master, not a | 43 | * An i2c_dev represents an i2c_adapter ... an I2C or SMBus master, not a |
44 | * slave (i2c_client) with which messages will be exchanged. It's coupled | 44 | * slave (i2c_client) with which messages will be exchanged. It's coupled |
45 | * with a character special file which is accessed by user mode drivers. | 45 | * with a character special file which is accessed by user mode drivers. |
46 | * | 46 | * |
47 | * The list of i2c_dev structures is parallel to the i2c_adapter lists | 47 | * The list of i2c_dev structures is parallel to the i2c_adapter lists |
48 | * maintained by the driver model, and is updated using notifications | 48 | * maintained by the driver model, and is updated using bus notifications. |
49 | * delivered to the i2cdev_driver. | ||
50 | */ | 49 | */ |
51 | struct i2c_dev { | 50 | struct i2c_dev { |
52 | struct list_head list; | 51 | struct list_head list; |
@@ -491,7 +490,6 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
491 | return -ENOMEM; | 490 | return -ENOMEM; |
492 | } | 491 | } |
493 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); | 492 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); |
494 | client->driver = &i2cdev_driver; | ||
495 | 493 | ||
496 | client->adapter = adap; | 494 | client->adapter = adap; |
497 | file->private_data = client; | 495 | file->private_data = client; |
@@ -522,19 +520,18 @@ static const struct file_operations i2cdev_fops = { | |||
522 | 520 | ||
523 | /* ------------------------------------------------------------------------- */ | 521 | /* ------------------------------------------------------------------------- */ |
524 | 522 | ||
525 | /* | ||
526 | * The legacy "i2cdev_driver" is used primarily to get notifications when | ||
527 | * I2C adapters are added or removed, so that each one gets an i2c_dev | ||
528 | * and is thus made available to userspace driver code. | ||
529 | */ | ||
530 | |||
531 | static struct class *i2c_dev_class; | 523 | static struct class *i2c_dev_class; |
532 | 524 | ||
533 | static int i2cdev_attach_adapter(struct i2c_adapter *adap) | 525 | static int i2cdev_attach_adapter(struct device *dev, void *dummy) |
534 | { | 526 | { |
527 | struct i2c_adapter *adap; | ||
535 | struct i2c_dev *i2c_dev; | 528 | struct i2c_dev *i2c_dev; |
536 | int res; | 529 | int res; |
537 | 530 | ||
531 | if (dev->type != &i2c_adapter_type) | ||
532 | return 0; | ||
533 | adap = to_i2c_adapter(dev); | ||
534 | |||
538 | i2c_dev = get_free_i2c_dev(adap); | 535 | i2c_dev = get_free_i2c_dev(adap); |
539 | if (IS_ERR(i2c_dev)) | 536 | if (IS_ERR(i2c_dev)) |
540 | return PTR_ERR(i2c_dev); | 537 | return PTR_ERR(i2c_dev); |
@@ -561,10 +558,15 @@ error: | |||
561 | return res; | 558 | return res; |
562 | } | 559 | } |
563 | 560 | ||
564 | static int i2cdev_detach_adapter(struct i2c_adapter *adap) | 561 | static int i2cdev_detach_adapter(struct device *dev, void *dummy) |
565 | { | 562 | { |
563 | struct i2c_adapter *adap; | ||
566 | struct i2c_dev *i2c_dev; | 564 | struct i2c_dev *i2c_dev; |
567 | 565 | ||
566 | if (dev->type != &i2c_adapter_type) | ||
567 | return 0; | ||
568 | adap = to_i2c_adapter(dev); | ||
569 | |||
568 | i2c_dev = i2c_dev_get_by_minor(adap->nr); | 570 | i2c_dev = i2c_dev_get_by_minor(adap->nr); |
569 | if (!i2c_dev) /* attach_adapter must have failed */ | 571 | if (!i2c_dev) /* attach_adapter must have failed */ |
570 | return 0; | 572 | return 0; |
@@ -577,12 +579,23 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
577 | return 0; | 579 | return 0; |
578 | } | 580 | } |
579 | 581 | ||
580 | static struct i2c_driver i2cdev_driver = { | 582 | int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action, |
581 | .driver = { | 583 | void *data) |
582 | .name = "dev_driver", | 584 | { |
583 | }, | 585 | struct device *dev = data; |
584 | .attach_adapter = i2cdev_attach_adapter, | 586 | |
585 | .detach_adapter = i2cdev_detach_adapter, | 587 | switch (action) { |
588 | case BUS_NOTIFY_ADD_DEVICE: | ||
589 | return i2cdev_attach_adapter(dev, NULL); | ||
590 | case BUS_NOTIFY_DEL_DEVICE: | ||
591 | return i2cdev_detach_adapter(dev, NULL); | ||
592 | } | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | static struct notifier_block i2cdev_notifier = { | ||
598 | .notifier_call = i2cdev_notifier_call, | ||
586 | }; | 599 | }; |
587 | 600 | ||
588 | /* ------------------------------------------------------------------------- */ | 601 | /* ------------------------------------------------------------------------- */ |
@@ -607,10 +620,14 @@ static int __init i2c_dev_init(void) | |||
607 | goto out_unreg_chrdev; | 620 | goto out_unreg_chrdev; |
608 | } | 621 | } |
609 | 622 | ||
610 | res = i2c_add_driver(&i2cdev_driver); | 623 | /* Keep track of adapters which will be added or removed later */ |
624 | res = bus_register_notifier(&i2c_bus_type, &i2cdev_notifier); | ||
611 | if (res) | 625 | if (res) |
612 | goto out_unreg_class; | 626 | goto out_unreg_class; |
613 | 627 | ||
628 | /* Bind to already existing adapters right away */ | ||
629 | i2c_for_each_dev(NULL, i2cdev_attach_adapter); | ||
630 | |||
614 | return 0; | 631 | return 0; |
615 | 632 | ||
616 | out_unreg_class: | 633 | out_unreg_class: |
@@ -624,7 +641,8 @@ out: | |||
624 | 641 | ||
625 | static void __exit i2c_dev_exit(void) | 642 | static void __exit i2c_dev_exit(void) |
626 | { | 643 | { |
627 | i2c_del_driver(&i2cdev_driver); | 644 | bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier); |
645 | i2c_for_each_dev(NULL, i2cdev_detach_adapter); | ||
628 | class_destroy(i2c_dev_class); | 646 | class_destroy(i2c_dev_class); |
629 | unregister_chrdev(I2C_MAJOR, "i2c"); | 647 | unregister_chrdev(I2C_MAJOR, "i2c"); |
630 | } | 648 | } |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 81df925f0e8b..7f879b2397b0 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # link order is important here | 2 | # link order is important here |
3 | # | 3 | # |
4 | 4 | ||
5 | EXTRA_CFLAGS += -Idrivers/ide | 5 | ccflags-y := -Idrivers/ide |
6 | 6 | ||
7 | ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ | 7 | ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ |
8 | ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ | 8 | ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ |
diff --git a/drivers/ieee802154/Makefile b/drivers/ieee802154/Makefile index e0e8e1a184ff..68999137dedf 100644 --- a/drivers/ieee802154/Makefile +++ b/drivers/ieee802154/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | obj-$(CONFIG_IEEE802154_FAKEHARD) += fakehard.o | 1 | obj-$(CONFIG_IEEE802154_FAKEHARD) += fakehard.o |
2 | 2 | ||
3 | EXTRA_CFLAGS += -DDEBUG -DCONFIG_FFD | 3 | ccflags-y := -DDEBUG -DCONFIG_FFD |
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 1903c0f5b925..23e82e46656d 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig | |||
@@ -161,16 +161,6 @@ config INPUT_APMPOWER | |||
161 | To compile this driver as a module, choose M here: the | 161 | To compile this driver as a module, choose M here: the |
162 | module will be called apm-power. | 162 | module will be called apm-power. |
163 | 163 | ||
164 | config XEN_KBDDEV_FRONTEND | ||
165 | tristate "Xen virtual keyboard and mouse support" | ||
166 | depends on XEN_FBDEV_FRONTEND | ||
167 | default y | ||
168 | select XEN_XENBUS_FRONTEND | ||
169 | help | ||
170 | This driver implements the front-end of the Xen virtual | ||
171 | keyboard and mouse device driver. It communicates with a back-end | ||
172 | in another domain. | ||
173 | |||
174 | comment "Input Device Drivers" | 164 | comment "Input Device Drivers" |
175 | 165 | ||
176 | source "drivers/input/keyboard/Kconfig" | 166 | source "drivers/input/keyboard/Kconfig" |
diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 09614ce74961..0c789490e0b3 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile | |||
@@ -24,5 +24,3 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/ | |||
24 | obj-$(CONFIG_INPUT_MISC) += misc/ | 24 | obj-$(CONFIG_INPUT_MISC) += misc/ |
25 | 25 | ||
26 | obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o | 26 | obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o |
27 | |||
28 | obj-$(CONFIG_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o | ||
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c8471a2552e7..7f42d3a454d2 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -321,6 +321,9 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer, | |||
321 | struct input_event event; | 321 | struct input_event event; |
322 | int retval; | 322 | int retval; |
323 | 323 | ||
324 | if (count < input_event_size()) | ||
325 | return -EINVAL; | ||
326 | |||
324 | retval = mutex_lock_interruptible(&evdev->mutex); | 327 | retval = mutex_lock_interruptible(&evdev->mutex); |
325 | if (retval) | 328 | if (retval) |
326 | return retval; | 329 | return retval; |
@@ -330,17 +333,16 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer, | |||
330 | goto out; | 333 | goto out; |
331 | } | 334 | } |
332 | 335 | ||
333 | while (retval < count) { | 336 | do { |
334 | |||
335 | if (input_event_from_user(buffer + retval, &event)) { | 337 | if (input_event_from_user(buffer + retval, &event)) { |
336 | retval = -EFAULT; | 338 | retval = -EFAULT; |
337 | goto out; | 339 | goto out; |
338 | } | 340 | } |
341 | retval += input_event_size(); | ||
339 | 342 | ||
340 | input_inject_event(&evdev->handle, | 343 | input_inject_event(&evdev->handle, |
341 | event.type, event.code, event.value); | 344 | event.type, event.code, event.value); |
342 | retval += input_event_size(); | 345 | } while (retval + input_event_size() <= count); |
343 | } | ||
344 | 346 | ||
345 | out: | 347 | out: |
346 | mutex_unlock(&evdev->mutex); | 348 | mutex_unlock(&evdev->mutex); |
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c index 0559e309bac9..3037842a60d8 100644 --- a/drivers/input/input-polldev.c +++ b/drivers/input/input-polldev.c | |||
@@ -192,7 +192,7 @@ static struct attribute_group input_polldev_attribute_group = { | |||
192 | }; | 192 | }; |
193 | 193 | ||
194 | /** | 194 | /** |
195 | * input_allocate_polled_device - allocated memory polled device | 195 | * input_allocate_polled_device - allocate memory for polled device |
196 | * | 196 | * |
197 | * The function allocates memory for a polled device and also | 197 | * The function allocates memory for a polled device and also |
198 | * for an input device associated with this polled device. | 198 | * for an input device associated with this polled device. |
@@ -239,7 +239,7 @@ EXPORT_SYMBOL(input_free_polled_device); | |||
239 | * with input layer. The device should be allocated with call to | 239 | * with input layer. The device should be allocated with call to |
240 | * input_allocate_polled_device(). Callers should also set up poll() | 240 | * input_allocate_polled_device(). Callers should also set up poll() |
241 | * method and set up capabilities (id, name, phys, bits) of the | 241 | * method and set up capabilities (id, name, phys, bits) of the |
242 | * corresponing input_dev structure. | 242 | * corresponding input_dev structure. |
243 | */ | 243 | */ |
244 | int input_register_polled_device(struct input_polled_dev *dev) | 244 | int input_register_polled_device(struct input_polled_dev *dev) |
245 | { | 245 | { |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 11905b6a3023..d6e8bd8a851c 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -791,22 +791,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke) | |||
791 | int retval; | 791 | int retval; |
792 | 792 | ||
793 | spin_lock_irqsave(&dev->event_lock, flags); | 793 | spin_lock_irqsave(&dev->event_lock, flags); |
794 | 794 | retval = dev->getkeycode(dev, ke); | |
795 | if (dev->getkeycode) { | ||
796 | /* | ||
797 | * Support for legacy drivers, that don't implement the new | ||
798 | * ioctls | ||
799 | */ | ||
800 | u32 scancode = ke->index; | ||
801 | |||
802 | memcpy(ke->scancode, &scancode, sizeof(scancode)); | ||
803 | ke->len = sizeof(scancode); | ||
804 | retval = dev->getkeycode(dev, scancode, &ke->keycode); | ||
805 | } else { | ||
806 | retval = dev->getkeycode_new(dev, ke); | ||
807 | } | ||
808 | |||
809 | spin_unlock_irqrestore(&dev->event_lock, flags); | 795 | spin_unlock_irqrestore(&dev->event_lock, flags); |
796 | |||
810 | return retval; | 797 | return retval; |
811 | } | 798 | } |
812 | EXPORT_SYMBOL(input_get_keycode); | 799 | EXPORT_SYMBOL(input_get_keycode); |
@@ -831,35 +818,7 @@ int input_set_keycode(struct input_dev *dev, | |||
831 | 818 | ||
832 | spin_lock_irqsave(&dev->event_lock, flags); | 819 | spin_lock_irqsave(&dev->event_lock, flags); |
833 | 820 | ||
834 | if (dev->setkeycode) { | 821 | retval = dev->setkeycode(dev, ke, &old_keycode); |
835 | /* | ||
836 | * Support for legacy drivers, that don't implement the new | ||
837 | * ioctls | ||
838 | */ | ||
839 | unsigned int scancode; | ||
840 | |||
841 | retval = input_scancode_to_scalar(ke, &scancode); | ||
842 | if (retval) | ||
843 | goto out; | ||
844 | |||
845 | /* | ||
846 | * We need to know the old scancode, in order to generate a | ||
847 | * keyup effect, if the set operation happens successfully | ||
848 | */ | ||
849 | if (!dev->getkeycode) { | ||
850 | retval = -EINVAL; | ||
851 | goto out; | ||
852 | } | ||
853 | |||
854 | retval = dev->getkeycode(dev, scancode, &old_keycode); | ||
855 | if (retval) | ||
856 | goto out; | ||
857 | |||
858 | retval = dev->setkeycode(dev, scancode, ke->keycode); | ||
859 | } else { | ||
860 | retval = dev->setkeycode_new(dev, ke, &old_keycode); | ||
861 | } | ||
862 | |||
863 | if (retval) | 822 | if (retval) |
864 | goto out; | 823 | goto out; |
865 | 824 | ||
@@ -1846,11 +1805,11 @@ int input_register_device(struct input_dev *dev) | |||
1846 | dev->rep[REP_PERIOD] = 33; | 1805 | dev->rep[REP_PERIOD] = 33; |
1847 | } | 1806 | } |
1848 | 1807 | ||
1849 | if (!dev->getkeycode && !dev->getkeycode_new) | 1808 | if (!dev->getkeycode) |
1850 | dev->getkeycode_new = input_default_getkeycode; | 1809 | dev->getkeycode = input_default_getkeycode; |
1851 | 1810 | ||
1852 | if (!dev->setkeycode && !dev->setkeycode_new) | 1811 | if (!dev->setkeycode) |
1853 | dev->setkeycode_new = input_default_setkeycode; | 1812 | dev->setkeycode = input_default_setkeycode; |
1854 | 1813 | ||
1855 | dev_set_name(&dev->dev, "input%ld", | 1814 | dev_set_name(&dev->dev, "input%ld", |
1856 | (unsigned long) atomic_inc_return(&input_no) - 1); | 1815 | (unsigned long) atomic_inc_return(&input_no) - 1); |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index c7a92028f450..b16bed038f72 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -112,6 +112,16 @@ config KEYBOARD_ATKBD_RDI_KEYCODES | |||
112 | right-hand column will be interpreted as the key shown in the | 112 | right-hand column will be interpreted as the key shown in the |
113 | left-hand column. | 113 | left-hand column. |
114 | 114 | ||
115 | config KEYBOARD_QT1070 | ||
116 | tristate "Atmel AT42QT1070 Touch Sensor Chip" | ||
117 | depends on I2C | ||
118 | help | ||
119 | Say Y here if you want to use Atmel AT42QT1070 QTouch | ||
120 | Sensor chip as input device. | ||
121 | |||
122 | To compile this driver as a module, choose M here: | ||
123 | the module will be called qt1070 | ||
124 | |||
115 | config KEYBOARD_QT2160 | 125 | config KEYBOARD_QT2160 |
116 | tristate "Atmel AT42QT2160 Touch Sensor Chip" | 126 | tristate "Atmel AT42QT2160 Touch Sensor Chip" |
117 | depends on I2C && EXPERIMENTAL | 127 | depends on I2C && EXPERIMENTAL |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 468c627a2844..878e6c20deb0 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -34,6 +34,7 @@ obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o | |||
34 | obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o | 34 | obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o |
35 | obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o | 35 | obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o |
36 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o | 36 | obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o |
37 | obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o | ||
37 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o | 38 | obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o |
38 | obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o | 39 | obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o |
39 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o | 40 | obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o |
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index f7c2a166576b..b732870ecc89 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include <linux/input.h> | 31 | #include <linux/input.h> |
32 | #include <linux/leds.h> | 32 | #include <linux/leds.h> |
33 | #include <linux/pm.h> | ||
33 | #include <linux/i2c/lm8323.h> | 34 | #include <linux/i2c/lm8323.h> |
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | 36 | ||
@@ -802,8 +803,9 @@ static int __devexit lm8323_remove(struct i2c_client *client) | |||
802 | * We don't need to explicitly suspend the chip, as it already switches off | 803 | * We don't need to explicitly suspend the chip, as it already switches off |
803 | * when there's no activity. | 804 | * when there's no activity. |
804 | */ | 805 | */ |
805 | static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg) | 806 | static int lm8323_suspend(struct device *dev) |
806 | { | 807 | { |
808 | struct i2c_client *client = to_i2c_client(dev); | ||
807 | struct lm8323_chip *lm = i2c_get_clientdata(client); | 809 | struct lm8323_chip *lm = i2c_get_clientdata(client); |
808 | int i; | 810 | int i; |
809 | 811 | ||
@@ -821,8 +823,9 @@ static int lm8323_suspend(struct i2c_client *client, pm_message_t mesg) | |||
821 | return 0; | 823 | return 0; |
822 | } | 824 | } |
823 | 825 | ||
824 | static int lm8323_resume(struct i2c_client *client) | 826 | static int lm8323_resume(struct device *dev) |
825 | { | 827 | { |
828 | struct i2c_client *client = to_i2c_client(dev); | ||
826 | struct lm8323_chip *lm = i2c_get_clientdata(client); | 829 | struct lm8323_chip *lm = i2c_get_clientdata(client); |
827 | int i; | 830 | int i; |
828 | 831 | ||
@@ -839,11 +842,10 @@ static int lm8323_resume(struct i2c_client *client) | |||
839 | 842 | ||
840 | return 0; | 843 | return 0; |
841 | } | 844 | } |
842 | #else | ||
843 | #define lm8323_suspend NULL | ||
844 | #define lm8323_resume NULL | ||
845 | #endif | 845 | #endif |
846 | 846 | ||
847 | static SIMPLE_DEV_PM_OPS(lm8323_pm_ops, lm8323_suspend, lm8323_resume); | ||
848 | |||
847 | static const struct i2c_device_id lm8323_id[] = { | 849 | static const struct i2c_device_id lm8323_id[] = { |
848 | { "lm8323", 0 }, | 850 | { "lm8323", 0 }, |
849 | { } | 851 | { } |
@@ -852,11 +854,10 @@ static const struct i2c_device_id lm8323_id[] = { | |||
852 | static struct i2c_driver lm8323_i2c_driver = { | 854 | static struct i2c_driver lm8323_i2c_driver = { |
853 | .driver = { | 855 | .driver = { |
854 | .name = "lm8323", | 856 | .name = "lm8323", |
857 | .pm = &lm8323_pm_ops, | ||
855 | }, | 858 | }, |
856 | .probe = lm8323_probe, | 859 | .probe = lm8323_probe, |
857 | .remove = __devexit_p(lm8323_remove), | 860 | .remove = __devexit_p(lm8323_remove), |
858 | .suspend = lm8323_suspend, | ||
859 | .resume = lm8323_resume, | ||
860 | .id_table = lm8323_id, | 861 | .id_table = lm8323_id, |
861 | }; | 862 | }; |
862 | MODULE_DEVICE_TABLE(i2c, lm8323_id); | 863 | MODULE_DEVICE_TABLE(i2c, lm8323_id); |
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c index 9091ff5ea808..5afe35ad24d3 100644 --- a/drivers/input/keyboard/max7359_keypad.c +++ b/drivers/input/keyboard/max7359_keypad.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/pm.h> | ||
20 | #include <linux/input.h> | 21 | #include <linux/input.h> |
21 | #include <linux/input/matrix_keypad.h> | 22 | #include <linux/input/matrix_keypad.h> |
22 | 23 | ||
@@ -271,8 +272,10 @@ static int __devexit max7359_remove(struct i2c_client *client) | |||
271 | } | 272 | } |
272 | 273 | ||
273 | #ifdef CONFIG_PM | 274 | #ifdef CONFIG_PM |
274 | static int max7359_suspend(struct i2c_client *client, pm_message_t mesg) | 275 | static int max7359_suspend(struct device *dev) |
275 | { | 276 | { |
277 | struct i2c_client *client = to_i2c_client(dev); | ||
278 | |||
276 | max7359_fall_deepsleep(client); | 279 | max7359_fall_deepsleep(client); |
277 | 280 | ||
278 | if (device_may_wakeup(&client->dev)) | 281 | if (device_may_wakeup(&client->dev)) |
@@ -281,8 +284,10 @@ static int max7359_suspend(struct i2c_client *client, pm_message_t mesg) | |||
281 | return 0; | 284 | return 0; |
282 | } | 285 | } |
283 | 286 | ||
284 | static int max7359_resume(struct i2c_client *client) | 287 | static int max7359_resume(struct device *dev) |
285 | { | 288 | { |
289 | struct i2c_client *client = to_i2c_client(dev); | ||
290 | |||
286 | if (device_may_wakeup(&client->dev)) | 291 | if (device_may_wakeup(&client->dev)) |
287 | disable_irq_wake(client->irq); | 292 | disable_irq_wake(client->irq); |
288 | 293 | ||
@@ -291,11 +296,10 @@ static int max7359_resume(struct i2c_client *client) | |||
291 | 296 | ||
292 | return 0; | 297 | return 0; |
293 | } | 298 | } |
294 | #else | ||
295 | #define max7359_suspend NULL | ||
296 | #define max7359_resume NULL | ||
297 | #endif | 299 | #endif |
298 | 300 | ||
301 | static SIMPLE_DEV_PM_OPS(max7359_pm, max7359_suspend, max7359_resume); | ||
302 | |||
299 | static const struct i2c_device_id max7359_ids[] = { | 303 | static const struct i2c_device_id max7359_ids[] = { |
300 | { "max7359", 0 }, | 304 | { "max7359", 0 }, |
301 | { } | 305 | { } |
@@ -305,11 +309,10 @@ MODULE_DEVICE_TABLE(i2c, max7359_ids); | |||
305 | static struct i2c_driver max7359_i2c_driver = { | 309 | static struct i2c_driver max7359_i2c_driver = { |
306 | .driver = { | 310 | .driver = { |
307 | .name = "max7359", | 311 | .name = "max7359", |
312 | .pm = &max7359_pm, | ||
308 | }, | 313 | }, |
309 | .probe = max7359_probe, | 314 | .probe = max7359_probe, |
310 | .remove = __devexit_p(max7359_remove), | 315 | .remove = __devexit_p(max7359_remove), |
311 | .suspend = max7359_suspend, | ||
312 | .resume = max7359_resume, | ||
313 | .id_table = max7359_ids, | 316 | .id_table = max7359_ids, |
314 | }; | 317 | }; |
315 | 318 | ||
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c index 63b849d7e90b..af1aab324a4c 100644 --- a/drivers/input/keyboard/mcs_touchkey.c +++ b/drivers/input/keyboard/mcs_touchkey.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * mcs_touchkey.c - Touchkey driver for MELFAS MCS5000/5080 controller | 2 | * Touchkey driver for MELFAS MCS5000/5080 controller |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics Co.Ltd | 4 | * Copyright (C) 2010 Samsung Electronics Co.Ltd |
5 | * Author: HeungJun Kim <riverful.kim@samsung.com> | 5 | * Author: HeungJun Kim <riverful.kim@samsung.com> |
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/input.h> | 19 | #include <linux/input.h> |
20 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/pm.h> | ||
22 | 23 | ||
23 | /* MCS5000 Touchkey */ | 24 | /* MCS5000 Touchkey */ |
24 | #define MCS5000_TOUCHKEY_STATUS 0x04 | 25 | #define MCS5000_TOUCHKEY_STATUS 0x04 |
@@ -45,6 +46,8 @@ struct mcs_touchkey_chip { | |||
45 | }; | 46 | }; |
46 | 47 | ||
47 | struct mcs_touchkey_data { | 48 | struct mcs_touchkey_data { |
49 | void (*poweron)(bool); | ||
50 | |||
48 | struct i2c_client *client; | 51 | struct i2c_client *client; |
49 | struct input_dev *input_dev; | 52 | struct input_dev *input_dev; |
50 | struct mcs_touchkey_chip chip; | 53 | struct mcs_touchkey_chip chip; |
@@ -169,6 +172,11 @@ static int __devinit mcs_touchkey_probe(struct i2c_client *client, | |||
169 | if (pdata->cfg_pin) | 172 | if (pdata->cfg_pin) |
170 | pdata->cfg_pin(); | 173 | pdata->cfg_pin(); |
171 | 174 | ||
175 | if (pdata->poweron) { | ||
176 | data->poweron = pdata->poweron; | ||
177 | data->poweron(true); | ||
178 | } | ||
179 | |||
172 | error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, | 180 | error = request_threaded_irq(client->irq, NULL, mcs_touchkey_interrupt, |
173 | IRQF_TRIGGER_FALLING, client->dev.driver->name, data); | 181 | IRQF_TRIGGER_FALLING, client->dev.driver->name, data); |
174 | if (error) { | 182 | if (error) { |
@@ -196,12 +204,57 @@ static int __devexit mcs_touchkey_remove(struct i2c_client *client) | |||
196 | struct mcs_touchkey_data *data = i2c_get_clientdata(client); | 204 | struct mcs_touchkey_data *data = i2c_get_clientdata(client); |
197 | 205 | ||
198 | free_irq(client->irq, data); | 206 | free_irq(client->irq, data); |
207 | if (data->poweron) | ||
208 | data->poweron(false); | ||
199 | input_unregister_device(data->input_dev); | 209 | input_unregister_device(data->input_dev); |
200 | kfree(data); | 210 | kfree(data); |
201 | 211 | ||
202 | return 0; | 212 | return 0; |
203 | } | 213 | } |
204 | 214 | ||
215 | static void mcs_touchkey_shutdown(struct i2c_client *client) | ||
216 | { | ||
217 | struct mcs_touchkey_data *data = i2c_get_clientdata(client); | ||
218 | |||
219 | if (data->poweron) | ||
220 | data->poweron(false); | ||
221 | } | ||
222 | |||
223 | #ifdef CONFIG_PM_SLEEP | ||
224 | static int mcs_touchkey_suspend(struct device *dev) | ||
225 | { | ||
226 | struct mcs_touchkey_data *data = dev_get_drvdata(dev); | ||
227 | struct i2c_client *client = data->client; | ||
228 | |||
229 | /* Disable the work */ | ||
230 | disable_irq(client->irq); | ||
231 | |||
232 | /* Finally turn off the power */ | ||
233 | if (data->poweron) | ||
234 | data->poweron(false); | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int mcs_touchkey_resume(struct device *dev) | ||
240 | { | ||
241 | struct mcs_touchkey_data *data = dev_get_drvdata(dev); | ||
242 | struct i2c_client *client = data->client; | ||
243 | |||
244 | /* Enable the device first */ | ||
245 | if (data->poweron) | ||
246 | data->poweron(true); | ||
247 | |||
248 | /* Enable irq again */ | ||
249 | enable_irq(client->irq); | ||
250 | |||
251 | return 0; | ||
252 | } | ||
253 | #endif | ||
254 | |||
255 | static SIMPLE_DEV_PM_OPS(mcs_touchkey_pm_ops, | ||
256 | mcs_touchkey_suspend, mcs_touchkey_resume); | ||
257 | |||
205 | static const struct i2c_device_id mcs_touchkey_id[] = { | 258 | static const struct i2c_device_id mcs_touchkey_id[] = { |
206 | { "mcs5000_touchkey", MCS5000_TOUCHKEY }, | 259 | { "mcs5000_touchkey", MCS5000_TOUCHKEY }, |
207 | { "mcs5080_touchkey", MCS5080_TOUCHKEY }, | 260 | { "mcs5080_touchkey", MCS5080_TOUCHKEY }, |
@@ -213,9 +266,11 @@ static struct i2c_driver mcs_touchkey_driver = { | |||
213 | .driver = { | 266 | .driver = { |
214 | .name = "mcs_touchkey", | 267 | .name = "mcs_touchkey", |
215 | .owner = THIS_MODULE, | 268 | .owner = THIS_MODULE, |
269 | .pm = &mcs_touchkey_pm_ops, | ||
216 | }, | 270 | }, |
217 | .probe = mcs_touchkey_probe, | 271 | .probe = mcs_touchkey_probe, |
218 | .remove = __devexit_p(mcs_touchkey_remove), | 272 | .remove = __devexit_p(mcs_touchkey_remove), |
273 | .shutdown = mcs_touchkey_shutdown, | ||
219 | .id_table = mcs_touchkey_id, | 274 | .id_table = mcs_touchkey_id, |
220 | }; | 275 | }; |
221 | 276 | ||
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 45bd0977d006..c51a3c4a7feb 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
30 | #include <linux/input.h> | 30 | #include <linux/input.h> |
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/pm_runtime.h> | ||
32 | 33 | ||
33 | #include <plat/omap4-keypad.h> | 34 | #include <plat/omap4-keypad.h> |
34 | 35 | ||
@@ -80,20 +81,6 @@ struct omap4_keypad { | |||
80 | unsigned short keymap[]; | 81 | unsigned short keymap[]; |
81 | }; | 82 | }; |
82 | 83 | ||
83 | static void __devinit omap4_keypad_config(struct omap4_keypad *keypad_data) | ||
84 | { | ||
85 | __raw_writel(OMAP4_VAL_FUNCTIONALCFG, | ||
86 | keypad_data->base + OMAP4_KBD_CTRL); | ||
87 | __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, | ||
88 | keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME); | ||
89 | __raw_writel(OMAP4_VAL_IRQDISABLE, | ||
90 | keypad_data->base + OMAP4_KBD_IRQSTATUS); | ||
91 | __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, | ||
92 | keypad_data->base + OMAP4_KBD_IRQENABLE); | ||
93 | __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, | ||
94 | keypad_data->base + OMAP4_KBD_WAKEUPENABLE); | ||
95 | } | ||
96 | |||
97 | /* Interrupt handler */ | 84 | /* Interrupt handler */ |
98 | static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) | 85 | static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) |
99 | { | 86 | { |
@@ -144,6 +131,49 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) | |||
144 | return IRQ_HANDLED; | 131 | return IRQ_HANDLED; |
145 | } | 132 | } |
146 | 133 | ||
134 | static int omap4_keypad_open(struct input_dev *input) | ||
135 | { | ||
136 | struct omap4_keypad *keypad_data = input_get_drvdata(input); | ||
137 | |||
138 | pm_runtime_get_sync(input->dev.parent); | ||
139 | |||
140 | disable_irq(keypad_data->irq); | ||
141 | |||
142 | __raw_writel(OMAP4_VAL_FUNCTIONALCFG, | ||
143 | keypad_data->base + OMAP4_KBD_CTRL); | ||
144 | __raw_writel(OMAP4_VAL_DEBOUNCINGTIME, | ||
145 | keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME); | ||
146 | __raw_writel(OMAP4_VAL_IRQDISABLE, | ||
147 | keypad_data->base + OMAP4_KBD_IRQSTATUS); | ||
148 | __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY, | ||
149 | keypad_data->base + OMAP4_KBD_IRQENABLE); | ||
150 | __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA, | ||
151 | keypad_data->base + OMAP4_KBD_WAKEUPENABLE); | ||
152 | |||
153 | enable_irq(keypad_data->irq); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static void omap4_keypad_close(struct input_dev *input) | ||
159 | { | ||
160 | struct omap4_keypad *keypad_data = input_get_drvdata(input); | ||
161 | |||
162 | disable_irq(keypad_data->irq); | ||
163 | |||
164 | /* Disable interrupts */ | ||
165 | __raw_writel(OMAP4_VAL_IRQDISABLE, | ||
166 | keypad_data->base + OMAP4_KBD_IRQENABLE); | ||
167 | |||
168 | /* clear pending interrupts */ | ||
169 | __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS), | ||
170 | keypad_data->base + OMAP4_KBD_IRQSTATUS); | ||
171 | |||
172 | enable_irq(keypad_data->irq); | ||
173 | |||
174 | pm_runtime_put_sync(input->dev.parent); | ||
175 | } | ||
176 | |||
147 | static int __devinit omap4_keypad_probe(struct platform_device *pdev) | 177 | static int __devinit omap4_keypad_probe(struct platform_device *pdev) |
148 | { | 178 | { |
149 | const struct omap4_keypad_platform_data *pdata; | 179 | const struct omap4_keypad_platform_data *pdata; |
@@ -225,6 +255,9 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
225 | input_dev->id.product = 0x0001; | 255 | input_dev->id.product = 0x0001; |
226 | input_dev->id.version = 0x0001; | 256 | input_dev->id.version = 0x0001; |
227 | 257 | ||
258 | input_dev->open = omap4_keypad_open; | ||
259 | input_dev->close = omap4_keypad_close; | ||
260 | |||
228 | input_dev->keycode = keypad_data->keymap; | 261 | input_dev->keycode = keypad_data->keymap; |
229 | input_dev->keycodesize = sizeof(keypad_data->keymap[0]); | 262 | input_dev->keycodesize = sizeof(keypad_data->keymap[0]); |
230 | input_dev->keycodemax = max_keys; | 263 | input_dev->keycodemax = max_keys; |
@@ -239,8 +272,6 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
239 | matrix_keypad_build_keymap(pdata->keymap_data, row_shift, | 272 | matrix_keypad_build_keymap(pdata->keymap_data, row_shift, |
240 | input_dev->keycode, input_dev->keybit); | 273 | input_dev->keycode, input_dev->keybit); |
241 | 274 | ||
242 | omap4_keypad_config(keypad_data); | ||
243 | |||
244 | error = request_irq(keypad_data->irq, omap4_keypad_interrupt, | 275 | error = request_irq(keypad_data->irq, omap4_keypad_interrupt, |
245 | IRQF_TRIGGER_RISING, | 276 | IRQF_TRIGGER_RISING, |
246 | "omap4-keypad", keypad_data); | 277 | "omap4-keypad", keypad_data); |
@@ -249,17 +280,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
249 | goto err_free_input; | 280 | goto err_free_input; |
250 | } | 281 | } |
251 | 282 | ||
283 | pm_runtime_enable(&pdev->dev); | ||
284 | |||
252 | error = input_register_device(keypad_data->input); | 285 | error = input_register_device(keypad_data->input); |
253 | if (error < 0) { | 286 | if (error < 0) { |
254 | dev_err(&pdev->dev, "failed to register input device\n"); | 287 | dev_err(&pdev->dev, "failed to register input device\n"); |
255 | goto err_free_irq; | 288 | goto err_pm_disable; |
256 | } | 289 | } |
257 | 290 | ||
258 | |||
259 | platform_set_drvdata(pdev, keypad_data); | 291 | platform_set_drvdata(pdev, keypad_data); |
260 | return 0; | 292 | return 0; |
261 | 293 | ||
262 | err_free_irq: | 294 | err_pm_disable: |
295 | pm_runtime_disable(&pdev->dev); | ||
263 | free_irq(keypad_data->irq, keypad_data); | 296 | free_irq(keypad_data->irq, keypad_data); |
264 | err_free_input: | 297 | err_free_input: |
265 | input_free_device(input_dev); | 298 | input_free_device(input_dev); |
@@ -278,6 +311,9 @@ static int __devexit omap4_keypad_remove(struct platform_device *pdev) | |||
278 | struct resource *res; | 311 | struct resource *res; |
279 | 312 | ||
280 | free_irq(keypad_data->irq, keypad_data); | 313 | free_irq(keypad_data->irq, keypad_data); |
314 | |||
315 | pm_runtime_disable(&pdev->dev); | ||
316 | |||
281 | input_unregister_device(keypad_data->input); | 317 | input_unregister_device(keypad_data->input); |
282 | 318 | ||
283 | iounmap(keypad_data->base); | 319 | iounmap(keypad_data->base); |
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c new file mode 100644 index 000000000000..fba8404c7297 --- /dev/null +++ b/drivers/input/keyboard/qt1070.c | |||
@@ -0,0 +1,276 @@ | |||
1 | /* | ||
2 | * Atmel AT42QT1070 QTouch Sensor Controller | ||
3 | * | ||
4 | * Copyright (C) 2011 Atmel | ||
5 | * | ||
6 | * Authors: Bo Shen <voice.shen@atmel.com> | ||
7 | * | ||
8 | * Base on AT42QT2160 driver by: | ||
9 | * Raphael Derosso Pereira <raphaelpereira@gmail.com> | ||
10 | * Copyright (C) 2009 | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/i2c.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <linux/slab.h> | ||
32 | #include <linux/irq.h> | ||
33 | #include <linux/interrupt.h> | ||
34 | #include <linux/jiffies.h> | ||
35 | #include <linux/delay.h> | ||
36 | |||
37 | /* Address for each register */ | ||
38 | #define CHIP_ID 0x00 | ||
39 | #define QT1070_CHIP_ID 0x2E | ||
40 | |||
41 | #define FW_VERSION 0x01 | ||
42 | #define QT1070_FW_VERSION 0x15 | ||
43 | |||
44 | #define DET_STATUS 0x02 | ||
45 | |||
46 | #define KEY_STATUS 0x03 | ||
47 | |||
48 | /* Calibrate */ | ||
49 | #define CALIBRATE_CMD 0x38 | ||
50 | #define QT1070_CAL_TIME 200 | ||
51 | |||
52 | /* Reset */ | ||
53 | #define RESET 0x39 | ||
54 | #define QT1070_RESET_TIME 255 | ||
55 | |||
56 | /* AT42QT1070 support up to 7 keys */ | ||
57 | static const unsigned short qt1070_key2code[] = { | ||
58 | KEY_0, KEY_1, KEY_2, KEY_3, | ||
59 | KEY_4, KEY_5, KEY_6, | ||
60 | }; | ||
61 | |||
62 | struct qt1070_data { | ||
63 | struct i2c_client *client; | ||
64 | struct input_dev *input; | ||
65 | unsigned int irq; | ||
66 | unsigned short keycodes[ARRAY_SIZE(qt1070_key2code)]; | ||
67 | u8 last_keys; | ||
68 | }; | ||
69 | |||
70 | static int qt1070_read(struct i2c_client *client, u8 reg) | ||
71 | { | ||
72 | int ret; | ||
73 | |||
74 | ret = i2c_smbus_read_byte_data(client, reg); | ||
75 | if (ret < 0) | ||
76 | dev_err(&client->dev, | ||
77 | "can not read register, returned %d\n", ret); | ||
78 | |||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | static int qt1070_write(struct i2c_client *client, u8 reg, u8 data) | ||
83 | { | ||
84 | int ret; | ||
85 | |||
86 | ret = i2c_smbus_write_byte_data(client, reg, data); | ||
87 | if (ret < 0) | ||
88 | dev_err(&client->dev, | ||
89 | "can not write register, returned %d\n", ret); | ||
90 | |||
91 | return ret; | ||
92 | } | ||
93 | |||
94 | static bool __devinit qt1070_identify(struct i2c_client *client) | ||
95 | { | ||
96 | int id, ver; | ||
97 | |||
98 | /* Read Chip ID */ | ||
99 | id = qt1070_read(client, CHIP_ID); | ||
100 | if (id != QT1070_CHIP_ID) { | ||
101 | dev_err(&client->dev, "ID %d not supported\n", id); | ||
102 | return false; | ||
103 | } | ||
104 | |||
105 | /* Read firmware version */ | ||
106 | ver = qt1070_read(client, FW_VERSION); | ||
107 | if (ver < 0) { | ||
108 | dev_err(&client->dev, "could not read the firmware version\n"); | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | dev_info(&client->dev, "AT42QT1070 firmware version %x\n", ver); | ||
113 | |||
114 | return true; | ||
115 | } | ||
116 | |||
117 | static irqreturn_t qt1070_interrupt(int irq, void *dev_id) | ||
118 | { | ||
119 | struct qt1070_data *data = dev_id; | ||
120 | struct i2c_client *client = data->client; | ||
121 | struct input_dev *input = data->input; | ||
122 | int i; | ||
123 | u8 new_keys, keyval, mask = 0x01; | ||
124 | |||
125 | /* Read the detected status register, thus clearing interrupt */ | ||
126 | qt1070_read(client, DET_STATUS); | ||
127 | |||
128 | /* Read which key changed */ | ||
129 | new_keys = qt1070_read(client, KEY_STATUS); | ||
130 | |||
131 | for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) { | ||
132 | keyval = new_keys & mask; | ||
133 | if ((data->last_keys & mask) != keyval) | ||
134 | input_report_key(input, data->keycodes[i], keyval); | ||
135 | mask <<= 1; | ||
136 | } | ||
137 | input_sync(input); | ||
138 | |||
139 | data->last_keys = new_keys; | ||
140 | return IRQ_HANDLED; | ||
141 | } | ||
142 | |||
143 | static int __devinit qt1070_probe(struct i2c_client *client, | ||
144 | const struct i2c_device_id *id) | ||
145 | { | ||
146 | struct qt1070_data *data; | ||
147 | struct input_dev *input; | ||
148 | int i; | ||
149 | int err; | ||
150 | |||
151 | err = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE); | ||
152 | if (!err) { | ||
153 | dev_err(&client->dev, "%s adapter not supported\n", | ||
154 | dev_driver_string(&client->adapter->dev)); | ||
155 | return -ENODEV; | ||
156 | } | ||
157 | |||
158 | if (!client->irq) { | ||
159 | dev_err(&client->dev, "please assign the irq to this device\n"); | ||
160 | return -EINVAL; | ||
161 | } | ||
162 | |||
163 | /* Identify the qt1070 chip */ | ||
164 | if (!qt1070_identify(client)) | ||
165 | return -ENODEV; | ||
166 | |||
167 | data = kzalloc(sizeof(struct qt1070_data), GFP_KERNEL); | ||
168 | input = input_allocate_device(); | ||
169 | if (!data || !input) { | ||
170 | dev_err(&client->dev, "insufficient memory\n"); | ||
171 | err = -ENOMEM; | ||
172 | goto err_free_mem; | ||
173 | } | ||
174 | |||
175 | data->client = client; | ||
176 | data->input = input; | ||
177 | data->irq = client->irq; | ||
178 | |||
179 | input->name = "AT42QT1070 QTouch Sensor"; | ||
180 | input->dev.parent = &client->dev; | ||
181 | input->id.bustype = BUS_I2C; | ||
182 | |||
183 | /* Add the keycode */ | ||
184 | input->keycode = data->keycodes; | ||
185 | input->keycodesize = sizeof(data->keycodes[0]); | ||
186 | input->keycodemax = ARRAY_SIZE(qt1070_key2code); | ||
187 | |||
188 | __set_bit(EV_KEY, input->evbit); | ||
189 | |||
190 | for (i = 0; i < ARRAY_SIZE(qt1070_key2code); i++) { | ||
191 | data->keycodes[i] = qt1070_key2code[i]; | ||
192 | __set_bit(qt1070_key2code[i], input->keybit); | ||
193 | } | ||
194 | |||
195 | /* Calibrate device */ | ||
196 | qt1070_write(client, CALIBRATE_CMD, 1); | ||
197 | msleep(QT1070_CAL_TIME); | ||
198 | |||
199 | /* Soft reset */ | ||
200 | qt1070_write(client, RESET, 1); | ||
201 | msleep(QT1070_RESET_TIME); | ||
202 | |||
203 | err = request_threaded_irq(client->irq, NULL, qt1070_interrupt, | ||
204 | IRQF_TRIGGER_NONE, client->dev.driver->name, data); | ||
205 | if (err) { | ||
206 | dev_err(&client->dev, "fail to request irq\n"); | ||
207 | goto err_free_mem; | ||
208 | } | ||
209 | |||
210 | /* Register the input device */ | ||
211 | err = input_register_device(data->input); | ||
212 | if (err) { | ||
213 | dev_err(&client->dev, "Failed to register input device\n"); | ||
214 | goto err_free_irq; | ||
215 | } | ||
216 | |||
217 | i2c_set_clientdata(client, data); | ||
218 | |||
219 | /* Read to clear the chang line */ | ||
220 | qt1070_read(client, DET_STATUS); | ||
221 | |||
222 | return 0; | ||
223 | |||
224 | err_free_irq: | ||
225 | free_irq(client->irq, data); | ||
226 | err_free_mem: | ||
227 | input_free_device(input); | ||
228 | kfree(data); | ||
229 | return err; | ||
230 | } | ||
231 | |||
232 | static int __devexit qt1070_remove(struct i2c_client *client) | ||
233 | { | ||
234 | struct qt1070_data *data = i2c_get_clientdata(client); | ||
235 | |||
236 | /* Release IRQ */ | ||
237 | free_irq(client->irq, data); | ||
238 | |||
239 | input_unregister_device(data->input); | ||
240 | kfree(data); | ||
241 | |||
242 | i2c_set_clientdata(client, NULL); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static const struct i2c_device_id qt1070_id[] = { | ||
248 | { "qt1070", 0 }, | ||
249 | { }, | ||
250 | }; | ||
251 | |||
252 | static struct i2c_driver qt1070_driver = { | ||
253 | .driver = { | ||
254 | .name = "qt1070", | ||
255 | .owner = THIS_MODULE, | ||
256 | }, | ||
257 | .id_table = qt1070_id, | ||
258 | .probe = qt1070_probe, | ||
259 | .remove = __devexit_p(qt1070_remove), | ||
260 | }; | ||
261 | |||
262 | static int __init qt1070_init(void) | ||
263 | { | ||
264 | return i2c_add_driver(&qt1070_driver); | ||
265 | } | ||
266 | module_init(qt1070_init); | ||
267 | |||
268 | static void __exit qt1070_exit(void) | ||
269 | { | ||
270 | i2c_del_driver(&qt1070_driver); | ||
271 | } | ||
272 | module_exit(qt1070_exit); | ||
273 | |||
274 | MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>"); | ||
275 | MODULE_DESCRIPTION("Driver for AT42QT1070 QTouch sensor"); | ||
276 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c index dbbe761778d2..99122f59e988 100644 --- a/drivers/input/keyboard/tc3589x-keypad.c +++ b/drivers/input/keyboard/tc3589x-keypad.c | |||
@@ -402,7 +402,7 @@ static int __devexit tc3589x_keypad_remove(struct platform_device *pdev) | |||
402 | return 0; | 402 | return 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | #ifdef CONFIG_PM | 405 | #ifdef CONFIG_PM_SLEEP |
406 | static int tc3589x_keypad_suspend(struct device *dev) | 406 | static int tc3589x_keypad_suspend(struct device *dev) |
407 | { | 407 | { |
408 | struct platform_device *pdev = to_platform_device(dev); | 408 | struct platform_device *pdev = to_platform_device(dev); |
@@ -439,19 +439,19 @@ static int tc3589x_keypad_resume(struct device *dev) | |||
439 | 439 | ||
440 | return 0; | 440 | return 0; |
441 | } | 441 | } |
442 | |||
443 | static const SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops, | ||
444 | tc3589x_keypad_suspend, tc3589x_keypad_resume); | ||
445 | #endif | 442 | #endif |
446 | 443 | ||
444 | static SIMPLE_DEV_PM_OPS(tc3589x_keypad_dev_pm_ops, | ||
445 | tc3589x_keypad_suspend, tc3589x_keypad_resume); | ||
446 | |||
447 | static struct platform_driver tc3589x_keypad_driver = { | 447 | static struct platform_driver tc3589x_keypad_driver = { |
448 | .driver.name = "tc3589x-keypad", | 448 | .driver = { |
449 | .driver.owner = THIS_MODULE, | 449 | .name = "tc3589x-keypad", |
450 | #ifdef CONFIG_PM | 450 | .owner = THIS_MODULE, |
451 | .driver.pm = &tc3589x_keypad_dev_pm_ops, | 451 | .pm = &tc3589x_keypad_dev_pm_ops, |
452 | #endif | 452 | }, |
453 | .probe = tc3589x_keypad_probe, | 453 | .probe = tc3589x_keypad_probe, |
454 | .remove = __devexit_p(tc3589x_keypad_remove), | 454 | .remove = __devexit_p(tc3589x_keypad_remove), |
455 | }; | 455 | }; |
456 | 456 | ||
457 | static int __init tc3589x_keypad_init(void) | 457 | static int __init tc3589x_keypad_init(void) |
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c index 800fbccf1f0f..3afea3f89718 100644 --- a/drivers/input/keyboard/tca6416-keypad.c +++ b/drivers/input/keyboard/tca6416-keypad.c | |||
@@ -297,6 +297,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client, | |||
297 | } | 297 | } |
298 | 298 | ||
299 | i2c_set_clientdata(client, chip); | 299 | i2c_set_clientdata(client, chip); |
300 | device_init_wakeup(&client->dev, 1); | ||
300 | 301 | ||
301 | return 0; | 302 | return 0; |
302 | 303 | ||
@@ -326,10 +327,37 @@ static int __devexit tca6416_keypad_remove(struct i2c_client *client) | |||
326 | return 0; | 327 | return 0; |
327 | } | 328 | } |
328 | 329 | ||
330 | #ifdef CONFIG_PM_SLEEP | ||
331 | static int tca6416_keypad_suspend(struct device *dev) | ||
332 | { | ||
333 | struct i2c_client *client = to_i2c_client(dev); | ||
334 | struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); | ||
335 | |||
336 | if (device_may_wakeup(dev)) | ||
337 | enable_irq_wake(chip->irqnum); | ||
338 | |||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | static int tca6416_keypad_resume(struct device *dev) | ||
343 | { | ||
344 | struct i2c_client *client = to_i2c_client(dev); | ||
345 | struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); | ||
346 | |||
347 | if (device_may_wakeup(dev)) | ||
348 | disable_irq_wake(chip->irqnum); | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | #endif | ||
353 | |||
354 | static SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops, | ||
355 | tca6416_keypad_suspend, tca6416_keypad_resume); | ||
329 | 356 | ||
330 | static struct i2c_driver tca6416_keypad_driver = { | 357 | static struct i2c_driver tca6416_keypad_driver = { |
331 | .driver = { | 358 | .driver = { |
332 | .name = "tca6416-keypad", | 359 | .name = "tca6416-keypad", |
360 | .pm = &tca6416_keypad_dev_pm_ops, | ||
333 | }, | 361 | }, |
334 | .probe = tca6416_keypad_probe, | 362 | .probe = tca6416_keypad_probe, |
335 | .remove = __devexit_p(tca6416_keypad_remove), | 363 | .remove = __devexit_p(tca6416_keypad_remove), |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index b0c6772851a9..f9cf0881b0e3 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -454,4 +454,17 @@ config INPUT_CMA3000_I2C | |||
454 | To compile this driver as a module, choose M here: the | 454 | To compile this driver as a module, choose M here: the |
455 | module will be called cma3000_d0x_i2c. | 455 | module will be called cma3000_d0x_i2c. |
456 | 456 | ||
457 | config INPUT_XEN_KBDDEV_FRONTEND | ||
458 | tristate "Xen virtual keyboard and mouse support" | ||
459 | depends on XEN_FBDEV_FRONTEND | ||
460 | default y | ||
461 | select XEN_XENBUS_FRONTEND | ||
462 | help | ||
463 | This driver implements the front-end of the Xen virtual | ||
464 | keyboard and mouse device driver. It communicates with a back-end | ||
465 | in another domain. | ||
466 | |||
467 | To compile this driver as a module, choose M here: the | ||
468 | module will be called xen-kbdfront. | ||
469 | |||
457 | endif | 470 | endif |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 9b4797112c9a..e3f7984e6274 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -42,5 +42,6 @@ obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o | |||
42 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o | 42 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o |
43 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o | 43 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o |
44 | obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o | 44 | obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o |
45 | obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o | ||
45 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o | 46 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o |
46 | 47 | ||
diff --git a/drivers/input/misc/ad714x-i2c.c b/drivers/input/misc/ad714x-i2c.c index 2bef8fa56c94..e21deb1baa8a 100644 --- a/drivers/input/misc/ad714x-i2c.c +++ b/drivers/input/misc/ad714x-i2c.c | |||
@@ -10,23 +10,23 @@ | |||
10 | #include <linux/i2c.h> | 10 | #include <linux/i2c.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/pm.h> | ||
13 | #include "ad714x.h" | 14 | #include "ad714x.h" |
14 | 15 | ||
15 | #ifdef CONFIG_PM | 16 | #ifdef CONFIG_PM |
16 | static int ad714x_i2c_suspend(struct i2c_client *client, pm_message_t message) | 17 | static int ad714x_i2c_suspend(struct device *dev) |
17 | { | 18 | { |
18 | return ad714x_disable(i2c_get_clientdata(client)); | 19 | return ad714x_disable(i2c_get_clientdata(to_i2c_client(dev))); |
19 | } | 20 | } |
20 | 21 | ||
21 | static int ad714x_i2c_resume(struct i2c_client *client) | 22 | static int ad714x_i2c_resume(struct device *dev) |
22 | { | 23 | { |
23 | return ad714x_enable(i2c_get_clientdata(client)); | 24 | return ad714x_enable(i2c_get_clientdata(to_i2c_client(dev))); |
24 | } | 25 | } |
25 | #else | ||
26 | # define ad714x_i2c_suspend NULL | ||
27 | # define ad714x_i2c_resume NULL | ||
28 | #endif | 26 | #endif |
29 | 27 | ||
28 | static SIMPLE_DEV_PM_OPS(ad714x_i2c_pm, ad714x_i2c_suspend, ad714x_i2c_resume); | ||
29 | |||
30 | static int ad714x_i2c_write(struct device *dev, unsigned short reg, | 30 | static int ad714x_i2c_write(struct device *dev, unsigned short reg, |
31 | unsigned short data) | 31 | unsigned short data) |
32 | { | 32 | { |
@@ -114,11 +114,10 @@ MODULE_DEVICE_TABLE(i2c, ad714x_id); | |||
114 | static struct i2c_driver ad714x_i2c_driver = { | 114 | static struct i2c_driver ad714x_i2c_driver = { |
115 | .driver = { | 115 | .driver = { |
116 | .name = "ad714x_captouch", | 116 | .name = "ad714x_captouch", |
117 | .pm = &ad714x_i2c_pm, | ||
117 | }, | 118 | }, |
118 | .probe = ad714x_i2c_probe, | 119 | .probe = ad714x_i2c_probe, |
119 | .remove = __devexit_p(ad714x_i2c_remove), | 120 | .remove = __devexit_p(ad714x_i2c_remove), |
120 | .suspend = ad714x_i2c_suspend, | ||
121 | .resume = ad714x_i2c_resume, | ||
122 | .id_table = ad714x_id, | 121 | .id_table = ad714x_id, |
123 | }; | 122 | }; |
124 | 123 | ||
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c index 7f8dedfd1bfe..4120dd549305 100644 --- a/drivers/input/misc/ad714x-spi.c +++ b/drivers/input/misc/ad714x-spi.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/input.h> /* BUS_I2C */ | 9 | #include <linux/input.h> /* BUS_I2C */ |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/spi/spi.h> | 11 | #include <linux/spi/spi.h> |
12 | #include <linux/pm.h> | ||
12 | #include <linux/types.h> | 13 | #include <linux/types.h> |
13 | #include "ad714x.h" | 14 | #include "ad714x.h" |
14 | 15 | ||
@@ -16,20 +17,19 @@ | |||
16 | #define AD714x_SPI_READ BIT(10) | 17 | #define AD714x_SPI_READ BIT(10) |
17 | 18 | ||
18 | #ifdef CONFIG_PM | 19 | #ifdef CONFIG_PM |
19 | static int ad714x_spi_suspend(struct spi_device *spi, pm_message_t message) | 20 | static int ad714x_spi_suspend(struct device *dev) |
20 | { | 21 | { |
21 | return ad714x_disable(spi_get_drvdata(spi)); | 22 | return ad714x_disable(spi_get_drvdata(to_spi_device(dev))); |
22 | } | 23 | } |
23 | 24 | ||
24 | static int ad714x_spi_resume(struct spi_device *spi) | 25 | static int ad714x_spi_resume(struct device *dev) |
25 | { | 26 | { |
26 | return ad714x_enable(spi_get_drvdata(spi)); | 27 | return ad714x_enable(spi_get_drvdata(to_spi_device(dev))); |
27 | } | 28 | } |
28 | #else | ||
29 | # define ad714x_spi_suspend NULL | ||
30 | # define ad714x_spi_resume NULL | ||
31 | #endif | 29 | #endif |
32 | 30 | ||
31 | static SIMPLE_DEV_PM_OPS(ad714x_spi_pm, ad714x_spi_suspend, ad714x_spi_resume); | ||
32 | |||
33 | static int ad714x_spi_read(struct device *dev, unsigned short reg, | 33 | static int ad714x_spi_read(struct device *dev, unsigned short reg, |
34 | unsigned short *data) | 34 | unsigned short *data) |
35 | { | 35 | { |
@@ -79,11 +79,10 @@ static struct spi_driver ad714x_spi_driver = { | |||
79 | .driver = { | 79 | .driver = { |
80 | .name = "ad714x_captouch", | 80 | .name = "ad714x_captouch", |
81 | .owner = THIS_MODULE, | 81 | .owner = THIS_MODULE, |
82 | .pm = &ad714x_spi_pm, | ||
82 | }, | 83 | }, |
83 | .probe = ad714x_spi_probe, | 84 | .probe = ad714x_spi_probe, |
84 | .remove = __devexit_p(ad714x_spi_remove), | 85 | .remove = __devexit_p(ad714x_spi_remove), |
85 | .suspend = ad714x_spi_suspend, | ||
86 | .resume = ad714x_spi_resume, | ||
87 | }; | 86 | }; |
88 | 87 | ||
89 | static __init int ad714x_spi_init(void) | 88 | static __init int ad714x_spi_init(void) |
diff --git a/drivers/input/misc/adxl34x-i2c.c b/drivers/input/misc/adxl34x-i2c.c index 0779724af7e7..ccacf2bb06a4 100644 --- a/drivers/input/misc/adxl34x-i2c.c +++ b/drivers/input/misc/adxl34x-i2c.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/i2c.h> | 11 | #include <linux/i2c.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/pm.h> | ||
14 | #include "adxl34x.h" | 15 | #include "adxl34x.h" |
15 | 16 | ||
16 | static int adxl34x_smbus_read(struct device *dev, unsigned char reg) | 17 | static int adxl34x_smbus_read(struct device *dev, unsigned char reg) |
@@ -105,8 +106,9 @@ static int __devexit adxl34x_i2c_remove(struct i2c_client *client) | |||
105 | } | 106 | } |
106 | 107 | ||
107 | #ifdef CONFIG_PM | 108 | #ifdef CONFIG_PM |
108 | static int adxl34x_i2c_suspend(struct i2c_client *client, pm_message_t message) | 109 | static int adxl34x_i2c_suspend(struct device *dev) |
109 | { | 110 | { |
111 | struct i2c_client *client = to_i2c_client(dev); | ||
110 | struct adxl34x *ac = i2c_get_clientdata(client); | 112 | struct adxl34x *ac = i2c_get_clientdata(client); |
111 | 113 | ||
112 | adxl34x_suspend(ac); | 114 | adxl34x_suspend(ac); |
@@ -114,19 +116,20 @@ static int adxl34x_i2c_suspend(struct i2c_client *client, pm_message_t message) | |||
114 | return 0; | 116 | return 0; |
115 | } | 117 | } |
116 | 118 | ||
117 | static int adxl34x_i2c_resume(struct i2c_client *client) | 119 | static int adxl34x_i2c_resume(struct device *dev) |
118 | { | 120 | { |
121 | struct i2c_client *client = to_i2c_client(dev); | ||
119 | struct adxl34x *ac = i2c_get_clientdata(client); | 122 | struct adxl34x *ac = i2c_get_clientdata(client); |
120 | 123 | ||
121 | adxl34x_resume(ac); | 124 | adxl34x_resume(ac); |
122 | 125 | ||
123 | return 0; | 126 | return 0; |
124 | } | 127 | } |
125 | #else | ||
126 | # define adxl34x_i2c_suspend NULL | ||
127 | # define adxl34x_i2c_resume NULL | ||
128 | #endif | 128 | #endif |
129 | 129 | ||
130 | static SIMPLE_DEV_PM_OPS(adxl34x_i2c_pm, adxl34x_i2c_suspend, | ||
131 | adxl34x_i2c_resume); | ||
132 | |||
130 | static const struct i2c_device_id adxl34x_id[] = { | 133 | static const struct i2c_device_id adxl34x_id[] = { |
131 | { "adxl34x", 0 }, | 134 | { "adxl34x", 0 }, |
132 | { } | 135 | { } |
@@ -138,11 +141,10 @@ static struct i2c_driver adxl34x_driver = { | |||
138 | .driver = { | 141 | .driver = { |
139 | .name = "adxl34x", | 142 | .name = "adxl34x", |
140 | .owner = THIS_MODULE, | 143 | .owner = THIS_MODULE, |
144 | .pm = &adxl34x_i2c_pm, | ||
141 | }, | 145 | }, |
142 | .probe = adxl34x_i2c_probe, | 146 | .probe = adxl34x_i2c_probe, |
143 | .remove = __devexit_p(adxl34x_i2c_remove), | 147 | .remove = __devexit_p(adxl34x_i2c_remove), |
144 | .suspend = adxl34x_i2c_suspend, | ||
145 | .resume = adxl34x_i2c_resume, | ||
146 | .id_table = adxl34x_id, | 148 | .id_table = adxl34x_id, |
147 | }; | 149 | }; |
148 | 150 | ||
diff --git a/drivers/input/misc/adxl34x-spi.c b/drivers/input/misc/adxl34x-spi.c index 782de9e89828..f29de22fdda0 100644 --- a/drivers/input/misc/adxl34x-spi.c +++ b/drivers/input/misc/adxl34x-spi.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/input.h> /* BUS_SPI */ | 10 | #include <linux/input.h> /* BUS_SPI */ |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/spi/spi.h> | 12 | #include <linux/spi/spi.h> |
13 | #include <linux/pm.h> | ||
13 | #include <linux/types.h> | 14 | #include <linux/types.h> |
14 | #include "adxl34x.h" | 15 | #include "adxl34x.h" |
15 | 16 | ||
@@ -57,7 +58,7 @@ static int adxl34x_spi_read_block(struct device *dev, | |||
57 | return (status < 0) ? status : 0; | 58 | return (status < 0) ? status : 0; |
58 | } | 59 | } |
59 | 60 | ||
60 | static const struct adxl34x_bus_ops adx134x_spi_bops = { | 61 | static const struct adxl34x_bus_ops adxl34x_spi_bops = { |
61 | .bustype = BUS_SPI, | 62 | .bustype = BUS_SPI, |
62 | .write = adxl34x_spi_write, | 63 | .write = adxl34x_spi_write, |
63 | .read = adxl34x_spi_read, | 64 | .read = adxl34x_spi_read, |
@@ -76,7 +77,7 @@ static int __devinit adxl34x_spi_probe(struct spi_device *spi) | |||
76 | 77 | ||
77 | ac = adxl34x_probe(&spi->dev, spi->irq, | 78 | ac = adxl34x_probe(&spi->dev, spi->irq, |
78 | spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, | 79 | spi->max_speed_hz > MAX_FREQ_NO_FIFODELAY, |
79 | &adx134x_spi_bops); | 80 | &adxl34x_spi_bops); |
80 | 81 | ||
81 | if (IS_ERR(ac)) | 82 | if (IS_ERR(ac)) |
82 | return PTR_ERR(ac); | 83 | return PTR_ERR(ac); |
@@ -94,8 +95,9 @@ static int __devexit adxl34x_spi_remove(struct spi_device *spi) | |||
94 | } | 95 | } |
95 | 96 | ||
96 | #ifdef CONFIG_PM | 97 | #ifdef CONFIG_PM |
97 | static int adxl34x_spi_suspend(struct spi_device *spi, pm_message_t message) | 98 | static int adxl34x_spi_suspend(struct device *dev) |
98 | { | 99 | { |
100 | struct spi_device *spi = to_spi_device(dev); | ||
99 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); | 101 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); |
100 | 102 | ||
101 | adxl34x_suspend(ac); | 103 | adxl34x_suspend(ac); |
@@ -103,29 +105,29 @@ static int adxl34x_spi_suspend(struct spi_device *spi, pm_message_t message) | |||
103 | return 0; | 105 | return 0; |
104 | } | 106 | } |
105 | 107 | ||
106 | static int adxl34x_spi_resume(struct spi_device *spi) | 108 | static int adxl34x_spi_resume(struct device *dev) |
107 | { | 109 | { |
110 | struct spi_device *spi = to_spi_device(dev); | ||
108 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); | 111 | struct adxl34x *ac = dev_get_drvdata(&spi->dev); |
109 | 112 | ||
110 | adxl34x_resume(ac); | 113 | adxl34x_resume(ac); |
111 | 114 | ||
112 | return 0; | 115 | return 0; |
113 | } | 116 | } |
114 | #else | ||
115 | # define adxl34x_spi_suspend NULL | ||
116 | # define adxl34x_spi_resume NULL | ||
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | static SIMPLE_DEV_PM_OPS(adxl34x_spi_pm, adxl34x_spi_suspend, | ||
120 | adxl34x_spi_resume); | ||
121 | |||
119 | static struct spi_driver adxl34x_driver = { | 122 | static struct spi_driver adxl34x_driver = { |
120 | .driver = { | 123 | .driver = { |
121 | .name = "adxl34x", | 124 | .name = "adxl34x", |
122 | .bus = &spi_bus_type, | 125 | .bus = &spi_bus_type, |
123 | .owner = THIS_MODULE, | 126 | .owner = THIS_MODULE, |
127 | .pm = &adxl34x_spi_pm, | ||
124 | }, | 128 | }, |
125 | .probe = adxl34x_spi_probe, | 129 | .probe = adxl34x_spi_probe, |
126 | .remove = __devexit_p(adxl34x_spi_remove), | 130 | .remove = __devexit_p(adxl34x_spi_remove), |
127 | .suspend = adxl34x_spi_suspend, | ||
128 | .resume = adxl34x_spi_resume, | ||
129 | }; | 131 | }; |
130 | 132 | ||
131 | static int __init adxl34x_spi_init(void) | 133 | static int __init adxl34x_spi_init(void) |
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 0b0e9be63542..9ccdb82d869a 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c | |||
@@ -612,8 +612,8 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2) | |||
612 | idev->open = ati_remote2_open; | 612 | idev->open = ati_remote2_open; |
613 | idev->close = ati_remote2_close; | 613 | idev->close = ati_remote2_close; |
614 | 614 | ||
615 | idev->getkeycode_new = ati_remote2_getkeycode; | 615 | idev->getkeycode = ati_remote2_getkeycode; |
616 | idev->setkeycode_new = ati_remote2_setkeycode; | 616 | idev->setkeycode = ati_remote2_setkeycode; |
617 | 617 | ||
618 | idev->name = ar2->name; | 618 | idev->name = ar2->name; |
619 | idev->phys = ar2->phys; | 619 | idev->phys = ar2->phys; |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 82542a1c1098..364bdf43a381 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -347,8 +347,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu | |||
347 | { | 347 | { |
348 | struct uinput_user_dev *user_dev; | 348 | struct uinput_user_dev *user_dev; |
349 | struct input_dev *dev; | 349 | struct input_dev *dev; |
350 | char *name; | 350 | int i; |
351 | int i, size; | ||
352 | int retval; | 351 | int retval; |
353 | 352 | ||
354 | if (count != sizeof(struct uinput_user_dev)) | 353 | if (count != sizeof(struct uinput_user_dev)) |
@@ -362,30 +361,25 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu | |||
362 | 361 | ||
363 | dev = udev->dev; | 362 | dev = udev->dev; |
364 | 363 | ||
365 | user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); | 364 | user_dev = memdup_user(buffer, sizeof(struct uinput_user_dev)); |
366 | if (!user_dev) | 365 | if (IS_ERR(user_dev)) |
367 | return -ENOMEM; | 366 | return PTR_ERR(user_dev); |
368 | |||
369 | if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) { | ||
370 | retval = -EFAULT; | ||
371 | goto exit; | ||
372 | } | ||
373 | 367 | ||
374 | udev->ff_effects_max = user_dev->ff_effects_max; | 368 | udev->ff_effects_max = user_dev->ff_effects_max; |
375 | 369 | ||
376 | size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; | 370 | /* Ensure name is filled in */ |
377 | if (!size) { | 371 | if (!user_dev->name[0]) { |
378 | retval = -EINVAL; | 372 | retval = -EINVAL; |
379 | goto exit; | 373 | goto exit; |
380 | } | 374 | } |
381 | 375 | ||
382 | kfree(dev->name); | 376 | kfree(dev->name); |
383 | dev->name = name = kmalloc(size, GFP_KERNEL); | 377 | dev->name = kstrndup(user_dev->name, UINPUT_MAX_NAME_SIZE, |
384 | if (!name) { | 378 | GFP_KERNEL); |
379 | if (!dev->name) { | ||
385 | retval = -ENOMEM; | 380 | retval = -ENOMEM; |
386 | goto exit; | 381 | goto exit; |
387 | } | 382 | } |
388 | strlcpy(name, user_dev->name, size); | ||
389 | 383 | ||
390 | dev->id.bustype = user_dev->id.bustype; | 384 | dev->id.bustype = user_dev->id.bustype; |
391 | dev->id.vendor = user_dev->id.vendor; | 385 | dev->id.vendor = user_dev->id.vendor; |
@@ -622,7 +616,6 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, | |||
622 | struct uinput_ff_upload ff_up; | 616 | struct uinput_ff_upload ff_up; |
623 | struct uinput_ff_erase ff_erase; | 617 | struct uinput_ff_erase ff_erase; |
624 | struct uinput_request *req; | 618 | struct uinput_request *req; |
625 | int length; | ||
626 | char *phys; | 619 | char *phys; |
627 | 620 | ||
628 | retval = mutex_lock_interruptible(&udev->mutex); | 621 | retval = mutex_lock_interruptible(&udev->mutex); |
@@ -689,24 +682,15 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, | |||
689 | retval = -EINVAL; | 682 | retval = -EINVAL; |
690 | goto out; | 683 | goto out; |
691 | } | 684 | } |
692 | length = strnlen_user(p, 1024); | 685 | |
693 | if (length <= 0) { | 686 | phys = strndup_user(p, 1024); |
694 | retval = -EFAULT; | 687 | if (IS_ERR(phys)) { |
695 | break; | 688 | retval = PTR_ERR(phys); |
689 | goto out; | ||
696 | } | 690 | } |
691 | |||
697 | kfree(udev->dev->phys); | 692 | kfree(udev->dev->phys); |
698 | udev->dev->phys = phys = kmalloc(length, GFP_KERNEL); | 693 | udev->dev->phys = phys; |
699 | if (!phys) { | ||
700 | retval = -ENOMEM; | ||
701 | break; | ||
702 | } | ||
703 | if (copy_from_user(phys, p, length)) { | ||
704 | udev->dev->phys = NULL; | ||
705 | kfree(phys); | ||
706 | retval = -EFAULT; | ||
707 | break; | ||
708 | } | ||
709 | phys[length - 1] = '\0'; | ||
710 | break; | 694 | break; |
711 | 695 | ||
712 | case UI_BEGIN_FF_UPLOAD: | 696 | case UI_BEGIN_FF_UPLOAD: |
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index 7f85a862ad11..7077f9bf5ead 100644 --- a/drivers/input/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c | |||
@@ -11,12 +11,6 @@ | |||
11 | * more details. | 11 | * more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | /* | ||
15 | * TODO: | ||
16 | * | ||
17 | * Switch to grant tables together with xen-fbfront.c. | ||
18 | */ | ||
19 | |||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
21 | 15 | ||
22 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
@@ -30,6 +24,8 @@ | |||
30 | #include <xen/xen.h> | 24 | #include <xen/xen.h> |
31 | #include <xen/events.h> | 25 | #include <xen/events.h> |
32 | #include <xen/page.h> | 26 | #include <xen/page.h> |
27 | #include <xen/grant_table.h> | ||
28 | #include <xen/interface/grant_table.h> | ||
33 | #include <xen/interface/io/fbif.h> | 29 | #include <xen/interface/io/fbif.h> |
34 | #include <xen/interface/io/kbdif.h> | 30 | #include <xen/interface/io/kbdif.h> |
35 | #include <xen/xenbus.h> | 31 | #include <xen/xenbus.h> |
@@ -38,6 +34,7 @@ struct xenkbd_info { | |||
38 | struct input_dev *kbd; | 34 | struct input_dev *kbd; |
39 | struct input_dev *ptr; | 35 | struct input_dev *ptr; |
40 | struct xenkbd_page *page; | 36 | struct xenkbd_page *page; |
37 | int gref; | ||
41 | int irq; | 38 | int irq; |
42 | struct xenbus_device *xbdev; | 39 | struct xenbus_device *xbdev; |
43 | char phys[32]; | 40 | char phys[32]; |
@@ -110,7 +107,7 @@ static irqreturn_t input_handler(int rq, void *dev_id) | |||
110 | static int __devinit xenkbd_probe(struct xenbus_device *dev, | 107 | static int __devinit xenkbd_probe(struct xenbus_device *dev, |
111 | const struct xenbus_device_id *id) | 108 | const struct xenbus_device_id *id) |
112 | { | 109 | { |
113 | int ret, i; | 110 | int ret, i, abs; |
114 | struct xenkbd_info *info; | 111 | struct xenkbd_info *info; |
115 | struct input_dev *kbd, *ptr; | 112 | struct input_dev *kbd, *ptr; |
116 | 113 | ||
@@ -122,12 +119,18 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, | |||
122 | dev_set_drvdata(&dev->dev, info); | 119 | dev_set_drvdata(&dev->dev, info); |
123 | info->xbdev = dev; | 120 | info->xbdev = dev; |
124 | info->irq = -1; | 121 | info->irq = -1; |
122 | info->gref = -1; | ||
125 | snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename); | 123 | snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename); |
126 | 124 | ||
127 | info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); | 125 | info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
128 | if (!info->page) | 126 | if (!info->page) |
129 | goto error_nomem; | 127 | goto error_nomem; |
130 | 128 | ||
129 | if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-abs-pointer", "%d", &abs) < 0) | ||
130 | abs = 0; | ||
131 | if (abs) | ||
132 | xenbus_printf(XBT_NIL, dev->nodename, "request-abs-pointer", "1"); | ||
133 | |||
131 | /* keyboard */ | 134 | /* keyboard */ |
132 | kbd = input_allocate_device(); | 135 | kbd = input_allocate_device(); |
133 | if (!kbd) | 136 | if (!kbd) |
@@ -137,11 +140,12 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, | |||
137 | kbd->id.bustype = BUS_PCI; | 140 | kbd->id.bustype = BUS_PCI; |
138 | kbd->id.vendor = 0x5853; | 141 | kbd->id.vendor = 0x5853; |
139 | kbd->id.product = 0xffff; | 142 | kbd->id.product = 0xffff; |
140 | kbd->evbit[0] = BIT(EV_KEY); | 143 | |
144 | __set_bit(EV_KEY, kbd->evbit); | ||
141 | for (i = KEY_ESC; i < KEY_UNKNOWN; i++) | 145 | for (i = KEY_ESC; i < KEY_UNKNOWN; i++) |
142 | set_bit(i, kbd->keybit); | 146 | __set_bit(i, kbd->keybit); |
143 | for (i = KEY_OK; i < KEY_MAX; i++) | 147 | for (i = KEY_OK; i < KEY_MAX; i++) |
144 | set_bit(i, kbd->keybit); | 148 | __set_bit(i, kbd->keybit); |
145 | 149 | ||
146 | ret = input_register_device(kbd); | 150 | ret = input_register_device(kbd); |
147 | if (ret) { | 151 | if (ret) { |
@@ -160,12 +164,20 @@ static int __devinit xenkbd_probe(struct xenbus_device *dev, | |||
160 | ptr->id.bustype = BUS_PCI; | 164 | ptr->id.bustype = BUS_PCI; |
161 | ptr->id.vendor = 0x5853; | 165 | ptr->id.vendor = 0x5853; |
162 | ptr->id.product = 0xfffe; | 166 | ptr->id.product = 0xfffe; |
163 | ptr->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS); | 167 | |
168 | if (abs) { | ||
169 | __set_bit(EV_ABS, ptr->evbit); | ||
170 | input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0); | ||
171 | input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0); | ||
172 | } else { | ||
173 | input_set_capability(ptr, EV_REL, REL_X); | ||
174 | input_set_capability(ptr, EV_REL, REL_Y); | ||
175 | } | ||
176 | input_set_capability(ptr, EV_REL, REL_WHEEL); | ||
177 | |||
178 | __set_bit(EV_KEY, ptr->evbit); | ||
164 | for (i = BTN_LEFT; i <= BTN_TASK; i++) | 179 | for (i = BTN_LEFT; i <= BTN_TASK; i++) |
165 | set_bit(i, ptr->keybit); | 180 | __set_bit(i, ptr->keybit); |
166 | ptr->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); | ||
167 | input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0); | ||
168 | input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0); | ||
169 | 181 | ||
170 | ret = input_register_device(ptr); | 182 | ret = input_register_device(ptr); |
171 | if (ret) { | 183 | if (ret) { |
@@ -218,15 +230,20 @@ static int xenkbd_connect_backend(struct xenbus_device *dev, | |||
218 | int ret, evtchn; | 230 | int ret, evtchn; |
219 | struct xenbus_transaction xbt; | 231 | struct xenbus_transaction xbt; |
220 | 232 | ||
233 | ret = gnttab_grant_foreign_access(dev->otherend_id, | ||
234 | virt_to_mfn(info->page), 0); | ||
235 | if (ret < 0) | ||
236 | return ret; | ||
237 | info->gref = ret; | ||
238 | |||
221 | ret = xenbus_alloc_evtchn(dev, &evtchn); | 239 | ret = xenbus_alloc_evtchn(dev, &evtchn); |
222 | if (ret) | 240 | if (ret) |
223 | return ret; | 241 | goto error_grant; |
224 | ret = bind_evtchn_to_irqhandler(evtchn, input_handler, | 242 | ret = bind_evtchn_to_irqhandler(evtchn, input_handler, |
225 | 0, dev->devicetype, info); | 243 | 0, dev->devicetype, info); |
226 | if (ret < 0) { | 244 | if (ret < 0) { |
227 | xenbus_free_evtchn(dev, evtchn); | ||
228 | xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler"); | 245 | xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler"); |
229 | return ret; | 246 | goto error_evtchan; |
230 | } | 247 | } |
231 | info->irq = ret; | 248 | info->irq = ret; |
232 | 249 | ||
@@ -234,12 +251,15 @@ static int xenkbd_connect_backend(struct xenbus_device *dev, | |||
234 | ret = xenbus_transaction_start(&xbt); | 251 | ret = xenbus_transaction_start(&xbt); |
235 | if (ret) { | 252 | if (ret) { |
236 | xenbus_dev_fatal(dev, ret, "starting transaction"); | 253 | xenbus_dev_fatal(dev, ret, "starting transaction"); |
237 | return ret; | 254 | goto error_irqh; |
238 | } | 255 | } |
239 | ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", | 256 | ret = xenbus_printf(xbt, dev->nodename, "page-ref", "%lu", |
240 | virt_to_mfn(info->page)); | 257 | virt_to_mfn(info->page)); |
241 | if (ret) | 258 | if (ret) |
242 | goto error_xenbus; | 259 | goto error_xenbus; |
260 | ret = xenbus_printf(xbt, dev->nodename, "page-gref", "%u", info->gref); | ||
261 | if (ret) | ||
262 | goto error_xenbus; | ||
243 | ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u", | 263 | ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u", |
244 | evtchn); | 264 | evtchn); |
245 | if (ret) | 265 | if (ret) |
@@ -249,7 +269,7 @@ static int xenkbd_connect_backend(struct xenbus_device *dev, | |||
249 | if (ret == -EAGAIN) | 269 | if (ret == -EAGAIN) |
250 | goto again; | 270 | goto again; |
251 | xenbus_dev_fatal(dev, ret, "completing transaction"); | 271 | xenbus_dev_fatal(dev, ret, "completing transaction"); |
252 | return ret; | 272 | goto error_irqh; |
253 | } | 273 | } |
254 | 274 | ||
255 | xenbus_switch_state(dev, XenbusStateInitialised); | 275 | xenbus_switch_state(dev, XenbusStateInitialised); |
@@ -258,6 +278,14 @@ static int xenkbd_connect_backend(struct xenbus_device *dev, | |||
258 | error_xenbus: | 278 | error_xenbus: |
259 | xenbus_transaction_end(xbt, 1); | 279 | xenbus_transaction_end(xbt, 1); |
260 | xenbus_dev_fatal(dev, ret, "writing xenstore"); | 280 | xenbus_dev_fatal(dev, ret, "writing xenstore"); |
281 | error_irqh: | ||
282 | unbind_from_irqhandler(info->irq, info); | ||
283 | info->irq = -1; | ||
284 | error_evtchan: | ||
285 | xenbus_free_evtchn(dev, evtchn); | ||
286 | error_grant: | ||
287 | gnttab_end_foreign_access_ref(info->gref, 0); | ||
288 | info->gref = -1; | ||
261 | return ret; | 289 | return ret; |
262 | } | 290 | } |
263 | 291 | ||
@@ -266,13 +294,16 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *info) | |||
266 | if (info->irq >= 0) | 294 | if (info->irq >= 0) |
267 | unbind_from_irqhandler(info->irq, info); | 295 | unbind_from_irqhandler(info->irq, info); |
268 | info->irq = -1; | 296 | info->irq = -1; |
297 | if (info->gref >= 0) | ||
298 | gnttab_end_foreign_access_ref(info->gref, 0); | ||
299 | info->gref = -1; | ||
269 | } | 300 | } |
270 | 301 | ||
271 | static void xenkbd_backend_changed(struct xenbus_device *dev, | 302 | static void xenkbd_backend_changed(struct xenbus_device *dev, |
272 | enum xenbus_state backend_state) | 303 | enum xenbus_state backend_state) |
273 | { | 304 | { |
274 | struct xenkbd_info *info = dev_get_drvdata(&dev->dev); | 305 | struct xenkbd_info *info = dev_get_drvdata(&dev->dev); |
275 | int ret, val; | 306 | int val; |
276 | 307 | ||
277 | switch (backend_state) { | 308 | switch (backend_state) { |
278 | case XenbusStateInitialising: | 309 | case XenbusStateInitialising: |
@@ -285,16 +316,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev, | |||
285 | 316 | ||
286 | case XenbusStateInitWait: | 317 | case XenbusStateInitWait: |
287 | InitWait: | 318 | InitWait: |
288 | ret = xenbus_scanf(XBT_NIL, info->xbdev->otherend, | ||
289 | "feature-abs-pointer", "%d", &val); | ||
290 | if (ret < 0) | ||
291 | val = 0; | ||
292 | if (val) { | ||
293 | ret = xenbus_printf(XBT_NIL, info->xbdev->nodename, | ||
294 | "request-abs-pointer", "1"); | ||
295 | if (ret) | ||
296 | pr_warning("can't request abs-pointer\n"); | ||
297 | } | ||
298 | xenbus_switch_state(dev, XenbusStateConnected); | 319 | xenbus_switch_state(dev, XenbusStateConnected); |
299 | break; | 320 | break; |
300 | 321 | ||
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index ee82851afe3e..3aead91bacc8 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c | |||
@@ -63,6 +63,10 @@ | |||
63 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 | 63 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 |
64 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 | 64 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 |
65 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 | 65 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 |
66 | /* Macbook8 (unibody, March 2011) */ | ||
67 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245 | ||
68 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246 | ||
69 | #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247 | ||
66 | 70 | ||
67 | #define BCM5974_DEVICE(prod) { \ | 71 | #define BCM5974_DEVICE(prod) { \ |
68 | .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ | 72 | .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ |
@@ -96,6 +100,10 @@ static const struct usb_device_id bcm5974_table[] = { | |||
96 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), | 100 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), |
97 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), | 101 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), |
98 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), | 102 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), |
103 | /* MacbookPro8 */ | ||
104 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI), | ||
105 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO), | ||
106 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS), | ||
99 | /* Terminating entry */ | 107 | /* Terminating entry */ |
100 | {} | 108 | {} |
101 | }; | 109 | }; |
@@ -274,6 +282,18 @@ static const struct bcm5974_config bcm5974_config_table[] = { | |||
274 | { DIM_X, DIM_X / SN_COORD, -4616, 5112 }, | 282 | { DIM_X, DIM_X / SN_COORD, -4616, 5112 }, |
275 | { DIM_Y, DIM_Y / SN_COORD, -142, 5234 } | 283 | { DIM_Y, DIM_Y / SN_COORD, -142, 5234 } |
276 | }, | 284 | }, |
285 | { | ||
286 | USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI, | ||
287 | USB_DEVICE_ID_APPLE_WELLSPRING5_ISO, | ||
288 | USB_DEVICE_ID_APPLE_WELLSPRING5_JIS, | ||
289 | HAS_INTEGRATED_BUTTON, | ||
290 | 0x84, sizeof(struct bt_data), | ||
291 | 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, | ||
292 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, | ||
293 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
294 | { DIM_X, DIM_X / SN_COORD, -4415, 5050 }, | ||
295 | { DIM_Y, DIM_Y / SN_COORD, -55, 6680 } | ||
296 | }, | ||
277 | {} | 297 | {} |
278 | }; | 298 | }; |
279 | 299 | ||
@@ -430,10 +450,6 @@ static int report_tp_state(struct bcm5974 *dev, int size) | |||
430 | ptest = int2bound(&c->p, raw_p); | 450 | ptest = int2bound(&c->p, raw_p); |
431 | origin = raw2int(f->origin); | 451 | origin = raw2int(f->origin); |
432 | 452 | ||
433 | /* set the integrated button if applicable */ | ||
434 | if (c->tp_type == TYPE2) | ||
435 | ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); | ||
436 | |||
437 | /* while tracking finger still valid, count all fingers */ | 453 | /* while tracking finger still valid, count all fingers */ |
438 | if (ptest > PRESSURE_LOW && origin) { | 454 | if (ptest > PRESSURE_LOW && origin) { |
439 | abs_p = ptest; | 455 | abs_p = ptest; |
@@ -452,6 +468,10 @@ static int report_tp_state(struct bcm5974 *dev, int size) | |||
452 | } | 468 | } |
453 | } | 469 | } |
454 | 470 | ||
471 | /* set the integrated button if applicable */ | ||
472 | if (c->tp_type == TYPE2) | ||
473 | ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); | ||
474 | |||
455 | if (dev->fingers < nmin) | 475 | if (dev->fingers < nmin) |
456 | dev->fingers = nmin; | 476 | dev->fingers = nmin; |
457 | if (dev->fingers > nmax) | 477 | if (dev->fingers > nmax) |
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c index 0ae62f0bcb32..f6aa26d305ed 100644 --- a/drivers/input/mouse/synaptics_i2c.c +++ b/drivers/input/mouse/synaptics_i2c.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/workqueue.h> | 19 | #include <linux/workqueue.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/pm.h> | ||
21 | 22 | ||
22 | #define DRIVER_NAME "synaptics_i2c" | 23 | #define DRIVER_NAME "synaptics_i2c" |
23 | /* maximum product id is 15 characters */ | 24 | /* maximum product id is 15 characters */ |
@@ -619,8 +620,9 @@ static int __devexit synaptics_i2c_remove(struct i2c_client *client) | |||
619 | } | 620 | } |
620 | 621 | ||
621 | #ifdef CONFIG_PM | 622 | #ifdef CONFIG_PM |
622 | static int synaptics_i2c_suspend(struct i2c_client *client, pm_message_t mesg) | 623 | static int synaptics_i2c_suspend(struct device *dev) |
623 | { | 624 | { |
625 | struct i2c_client *client = to_i2c_client(dev); | ||
624 | struct synaptics_i2c *touch = i2c_get_clientdata(client); | 626 | struct synaptics_i2c *touch = i2c_get_clientdata(client); |
625 | 627 | ||
626 | cancel_delayed_work_sync(&touch->dwork); | 628 | cancel_delayed_work_sync(&touch->dwork); |
@@ -631,9 +633,10 @@ static int synaptics_i2c_suspend(struct i2c_client *client, pm_message_t mesg) | |||
631 | return 0; | 633 | return 0; |
632 | } | 634 | } |
633 | 635 | ||
634 | static int synaptics_i2c_resume(struct i2c_client *client) | 636 | static int synaptics_i2c_resume(struct device *dev) |
635 | { | 637 | { |
636 | int ret; | 638 | int ret; |
639 | struct i2c_client *client = to_i2c_client(dev); | ||
637 | struct synaptics_i2c *touch = i2c_get_clientdata(client); | 640 | struct synaptics_i2c *touch = i2c_get_clientdata(client); |
638 | 641 | ||
639 | ret = synaptics_i2c_reset_config(client); | 642 | ret = synaptics_i2c_reset_config(client); |
@@ -645,11 +648,11 @@ static int synaptics_i2c_resume(struct i2c_client *client) | |||
645 | 648 | ||
646 | return 0; | 649 | return 0; |
647 | } | 650 | } |
648 | #else | ||
649 | #define synaptics_i2c_suspend NULL | ||
650 | #define synaptics_i2c_resume NULL | ||
651 | #endif | 651 | #endif |
652 | 652 | ||
653 | static SIMPLE_DEV_PM_OPS(synaptics_i2c_pm, synaptics_i2c_suspend, | ||
654 | synaptics_i2c_resume); | ||
655 | |||
653 | static const struct i2c_device_id synaptics_i2c_id_table[] = { | 656 | static const struct i2c_device_id synaptics_i2c_id_table[] = { |
654 | { "synaptics_i2c", 0 }, | 657 | { "synaptics_i2c", 0 }, |
655 | { }, | 658 | { }, |
@@ -660,13 +663,12 @@ static struct i2c_driver synaptics_i2c_driver = { | |||
660 | .driver = { | 663 | .driver = { |
661 | .name = DRIVER_NAME, | 664 | .name = DRIVER_NAME, |
662 | .owner = THIS_MODULE, | 665 | .owner = THIS_MODULE, |
666 | .pm = &synaptics_i2c_pm, | ||
663 | }, | 667 | }, |
664 | 668 | ||
665 | .probe = synaptics_i2c_probe, | 669 | .probe = synaptics_i2c_probe, |
666 | .remove = __devexit_p(synaptics_i2c_remove), | 670 | .remove = __devexit_p(synaptics_i2c_remove), |
667 | 671 | ||
668 | .suspend = synaptics_i2c_suspend, | ||
669 | .resume = synaptics_i2c_resume, | ||
670 | .id_table = synaptics_i2c_id_table, | 672 | .id_table = synaptics_i2c_id_table, |
671 | }; | 673 | }; |
672 | 674 | ||
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c index 7729e547ba65..337bf51bc984 100644 --- a/drivers/input/sparse-keymap.c +++ b/drivers/input/sparse-keymap.c | |||
@@ -210,8 +210,8 @@ int sparse_keymap_setup(struct input_dev *dev, | |||
210 | 210 | ||
211 | dev->keycode = map; | 211 | dev->keycode = map; |
212 | dev->keycodemax = map_size; | 212 | dev->keycodemax = map_size; |
213 | dev->getkeycode_new = sparse_keymap_getkeycode; | 213 | dev->getkeycode = sparse_keymap_getkeycode; |
214 | dev->setkeycode_new = sparse_keymap_setkeycode; | 214 | dev->setkeycode = sparse_keymap_setkeycode; |
215 | 215 | ||
216 | return 0; | 216 | return 0; |
217 | 217 | ||
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index cf8fb9f5d4a8..449c0a46dbac 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -193,16 +193,16 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
193 | case HID_USAGE_X: | 193 | case HID_USAGE_X: |
194 | if (usage == WCM_DESKTOP) { | 194 | if (usage == WCM_DESKTOP) { |
195 | if (finger) { | 195 | if (finger) { |
196 | features->device_type = BTN_TOOL_DOUBLETAP; | 196 | features->device_type = BTN_TOOL_FINGER; |
197 | if (features->type == TABLETPC2FG) { | 197 | if (features->type == TABLETPC2FG) { |
198 | /* need to reset back */ | 198 | /* need to reset back */ |
199 | features->pktlen = WACOM_PKGLEN_TPC2FG; | 199 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
200 | features->device_type = BTN_TOOL_TRIPLETAP; | 200 | features->device_type = BTN_TOOL_DOUBLETAP; |
201 | } | 201 | } |
202 | if (features->type == BAMBOO_PT) { | 202 | if (features->type == BAMBOO_PT) { |
203 | /* need to reset back */ | 203 | /* need to reset back */ |
204 | features->pktlen = WACOM_PKGLEN_BBTOUCH; | 204 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
205 | features->device_type = BTN_TOOL_TRIPLETAP; | 205 | features->device_type = BTN_TOOL_DOUBLETAP; |
206 | features->x_phy = | 206 | features->x_phy = |
207 | get_unaligned_le16(&report[i + 5]); | 207 | get_unaligned_le16(&report[i + 5]); |
208 | features->x_max = | 208 | features->x_max = |
@@ -241,11 +241,11 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
241 | case HID_USAGE_Y: | 241 | case HID_USAGE_Y: |
242 | if (usage == WCM_DESKTOP) { | 242 | if (usage == WCM_DESKTOP) { |
243 | if (finger) { | 243 | if (finger) { |
244 | features->device_type = BTN_TOOL_DOUBLETAP; | 244 | features->device_type = BTN_TOOL_FINGER; |
245 | if (features->type == TABLETPC2FG) { | 245 | if (features->type == TABLETPC2FG) { |
246 | /* need to reset back */ | 246 | /* need to reset back */ |
247 | features->pktlen = WACOM_PKGLEN_TPC2FG; | 247 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
248 | features->device_type = BTN_TOOL_TRIPLETAP; | 248 | features->device_type = BTN_TOOL_DOUBLETAP; |
249 | features->y_max = | 249 | features->y_max = |
250 | get_unaligned_le16(&report[i + 3]); | 250 | get_unaligned_le16(&report[i + 3]); |
251 | features->y_phy = | 251 | features->y_phy = |
@@ -254,7 +254,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi | |||
254 | } else if (features->type == BAMBOO_PT) { | 254 | } else if (features->type == BAMBOO_PT) { |
255 | /* need to reset back */ | 255 | /* need to reset back */ |
256 | features->pktlen = WACOM_PKGLEN_BBTOUCH; | 256 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
257 | features->device_type = BTN_TOOL_TRIPLETAP; | 257 | features->device_type = BTN_TOOL_DOUBLETAP; |
258 | features->y_phy = | 258 | features->y_phy = |
259 | get_unaligned_le16(&report[i + 3]); | 259 | get_unaligned_le16(&report[i + 3]); |
260 | features->y_max = | 260 | features->y_max = |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 367fa82a607e..5597637cfd41 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -675,169 +675,87 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) | |||
675 | return 1; | 675 | return 1; |
676 | } | 676 | } |
677 | 677 | ||
678 | 678 | static int wacom_tpc_mt_touch(struct wacom_wac *wacom) | |
679 | static void wacom_tpc_finger_in(struct wacom_wac *wacom, char *data, int idx) | ||
680 | { | 679 | { |
681 | struct input_dev *input = wacom->input; | 680 | struct input_dev *input = wacom->input; |
682 | int finger = idx + 1; | 681 | unsigned char *data = wacom->data; |
683 | int x = le16_to_cpup((__le16 *)&data[finger * 2]) & 0x7fff; | 682 | int contact_with_no_pen_down_count = 0; |
684 | int y = le16_to_cpup((__le16 *)&data[4 + finger * 2]) & 0x7fff; | 683 | int i; |
685 | 684 | ||
686 | /* | 685 | for (i = 0; i < 2; i++) { |
687 | * Work around input core suppressing "duplicate" events since | 686 | int p = data[1] & (1 << i); |
688 | * we are abusing ABS_X/ABS_Y to transmit multi-finger data. | 687 | bool touch = p && !wacom->shared->stylus_in_proximity; |
689 | * This should go away once we switch to true multitouch | 688 | |
690 | * protocol. | 689 | input_mt_slot(input, i); |
691 | */ | 690 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
692 | if (wacom->last_finger != finger) { | 691 | if (touch) { |
693 | if (x == input_abs_get_val(input, ABS_X)) | 692 | int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff; |
694 | x++; | 693 | int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff; |
695 | 694 | ||
696 | if (y == input_abs_get_val(input, ABS_Y)) | 695 | input_report_abs(input, ABS_MT_POSITION_X, x); |
697 | y++; | 696 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
697 | contact_with_no_pen_down_count++; | ||
698 | } | ||
698 | } | 699 | } |
699 | 700 | ||
700 | input_report_abs(input, ABS_X, x); | 701 | /* keep touch state for pen event */ |
701 | input_report_abs(input, ABS_Y, y); | 702 | wacom->shared->touch_down = (contact_with_no_pen_down_count > 0); |
702 | input_report_abs(input, ABS_MISC, wacom->id[0]); | ||
703 | input_report_key(input, wacom->tool[finger], 1); | ||
704 | if (!idx) | ||
705 | input_report_key(input, BTN_TOUCH, 1); | ||
706 | input_event(input, EV_MSC, MSC_SERIAL, finger); | ||
707 | input_sync(input); | ||
708 | 703 | ||
709 | wacom->last_finger = finger; | 704 | input_mt_report_pointer_emulation(input, true); |
710 | } | ||
711 | 705 | ||
712 | static void wacom_tpc_touch_out(struct wacom_wac *wacom, int idx) | 706 | return 1; |
713 | { | ||
714 | struct input_dev *input = wacom->input; | ||
715 | int finger = idx + 1; | ||
716 | |||
717 | input_report_abs(input, ABS_X, 0); | ||
718 | input_report_abs(input, ABS_Y, 0); | ||
719 | input_report_abs(input, ABS_MISC, 0); | ||
720 | input_report_key(input, wacom->tool[finger], 0); | ||
721 | if (!idx) | ||
722 | input_report_key(input, BTN_TOUCH, 0); | ||
723 | input_event(input, EV_MSC, MSC_SERIAL, finger); | ||
724 | input_sync(input); | ||
725 | } | 707 | } |
726 | 708 | ||
727 | static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len) | 709 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
728 | { | 710 | { |
729 | char *data = wacom->data; | 711 | char *data = wacom->data; |
730 | struct input_dev *input = wacom->input; | 712 | struct input_dev *input = wacom->input; |
713 | bool prox; | ||
714 | int x = 0, y = 0; | ||
731 | 715 | ||
732 | wacom->tool[1] = BTN_TOOL_DOUBLETAP; | 716 | if (!wacom->shared->stylus_in_proximity) { |
733 | wacom->id[0] = TOUCH_DEVICE_ID; | 717 | if (len == WACOM_PKGLEN_TPC1FG) { |
734 | wacom->tool[2] = BTN_TOOL_TRIPLETAP; | 718 | prox = data[0] & 0x01; |
735 | 719 | x = get_unaligned_le16(&data[1]); | |
736 | if (len != WACOM_PKGLEN_TPC1FG) { | 720 | y = get_unaligned_le16(&data[3]); |
737 | 721 | } else { /* with capacity */ | |
738 | switch (data[0]) { | 722 | prox = data[1] & 0x01; |
723 | x = le16_to_cpup((__le16 *)&data[2]); | ||
724 | y = le16_to_cpup((__le16 *)&data[4]); | ||
725 | } | ||
726 | } else | ||
727 | /* force touch out when pen is in prox */ | ||
728 | prox = 0; | ||
739 | 729 | ||
740 | case WACOM_REPORT_TPC1FG: | 730 | if (prox) { |
741 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 731 | input_report_abs(input, ABS_X, x); |
742 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | 732 | input_report_abs(input, ABS_Y, y); |
743 | input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); | 733 | } |
744 | input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6])); | 734 | input_report_key(input, BTN_TOUCH, prox); |
745 | input_report_abs(input, ABS_MISC, wacom->id[0]); | ||
746 | input_report_key(input, wacom->tool[1], 1); | ||
747 | input_sync(input); | ||
748 | break; | ||
749 | 735 | ||
750 | case WACOM_REPORT_TPC2FG: | 736 | /* keep touch state for pen events */ |
751 | if (data[1] & 0x01) | 737 | wacom->shared->touch_down = prox; |
752 | wacom_tpc_finger_in(wacom, data, 0); | ||
753 | else if (wacom->id[1] & 0x01) | ||
754 | wacom_tpc_touch_out(wacom, 0); | ||
755 | 738 | ||
756 | if (data[1] & 0x02) | 739 | return 1; |
757 | wacom_tpc_finger_in(wacom, data, 1); | ||
758 | else if (wacom->id[1] & 0x02) | ||
759 | wacom_tpc_touch_out(wacom, 1); | ||
760 | break; | ||
761 | } | ||
762 | } else { | ||
763 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); | ||
764 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); | ||
765 | input_report_key(input, BTN_TOUCH, 1); | ||
766 | input_report_abs(input, ABS_MISC, wacom->id[1]); | ||
767 | input_report_key(input, wacom->tool[1], 1); | ||
768 | input_sync(input); | ||
769 | } | ||
770 | } | 740 | } |
771 | 741 | ||
772 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | 742 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
773 | { | 743 | { |
774 | struct wacom_features *features = &wacom->features; | 744 | struct wacom_features *features = &wacom->features; |
775 | char *data = wacom->data; | 745 | char *data = wacom->data; |
776 | struct input_dev *input = wacom->input; | 746 | struct input_dev *input = wacom->input; |
777 | int prox = 0, pressure; | 747 | int pressure; |
778 | int retval = 0; | 748 | bool prox = data[1] & 0x20; |
779 | 749 | ||
780 | dbg("wacom_tpc_irq: received report #%d", data[0]); | 750 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
781 | 751 | /* Going into proximity select tool */ | |
782 | if (len == WACOM_PKGLEN_TPC1FG || /* single touch */ | 752 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
783 | data[0] == WACOM_REPORT_TPC1FG || /* single touch */ | ||
784 | data[0] == WACOM_REPORT_TPC2FG) { /* 2FG touch */ | ||
785 | |||
786 | if (wacom->shared->stylus_in_proximity) { | ||
787 | if (wacom->id[1] & 0x01) | ||
788 | wacom_tpc_touch_out(wacom, 0); | ||
789 | |||
790 | if (wacom->id[1] & 0x02) | ||
791 | wacom_tpc_touch_out(wacom, 1); | ||
792 | |||
793 | wacom->id[1] = 0; | ||
794 | return 0; | ||
795 | } | ||
796 | |||
797 | if (len == WACOM_PKGLEN_TPC1FG) { /* with touch */ | ||
798 | prox = data[0] & 0x01; | ||
799 | } else { /* with capacity */ | ||
800 | if (data[0] == WACOM_REPORT_TPC1FG) | ||
801 | /* single touch */ | ||
802 | prox = data[1] & 0x01; | ||
803 | else | ||
804 | /* 2FG touch data */ | ||
805 | prox = data[1] & 0x03; | ||
806 | } | ||
807 | |||
808 | if (prox) { | ||
809 | if (!wacom->id[1]) | ||
810 | wacom->last_finger = 1; | ||
811 | wacom_tpc_touch_in(wacom, len); | ||
812 | } else { | ||
813 | if (data[0] == WACOM_REPORT_TPC2FG) { | ||
814 | /* 2FGT out-prox */ | ||
815 | if (wacom->id[1] & 0x01) | ||
816 | wacom_tpc_touch_out(wacom, 0); | ||
817 | 753 | ||
818 | if (wacom->id[1] & 0x02) | 754 | /* keep pen state for touch events */ |
819 | wacom_tpc_touch_out(wacom, 1); | 755 | wacom->shared->stylus_in_proximity = prox; |
820 | } else | ||
821 | /* one finger touch */ | ||
822 | wacom_tpc_touch_out(wacom, 0); | ||
823 | 756 | ||
824 | wacom->id[0] = 0; | 757 | /* send pen events only when touch is up or forced out */ |
825 | } | 758 | if (!wacom->shared->touch_down) { |
826 | /* keep prox bit to send proper out-prox event */ | ||
827 | wacom->id[1] = prox; | ||
828 | } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */ | ||
829 | prox = data[1] & 0x20; | ||
830 | |||
831 | if (!wacom->shared->stylus_in_proximity) { /* first in prox */ | ||
832 | /* Going into proximity select tool */ | ||
833 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | ||
834 | if (wacom->tool[0] == BTN_TOOL_PEN) | ||
835 | wacom->id[0] = STYLUS_DEVICE_ID; | ||
836 | else | ||
837 | wacom->id[0] = ERASER_DEVICE_ID; | ||
838 | |||
839 | wacom->shared->stylus_in_proximity = true; | ||
840 | } | ||
841 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); | 759 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
842 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | 760 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
843 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | 761 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
@@ -847,15 +765,27 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | |||
847 | pressure = features->pressure_max + pressure + 1; | 765 | pressure = features->pressure_max + pressure + 1; |
848 | input_report_abs(input, ABS_PRESSURE, pressure); | 766 | input_report_abs(input, ABS_PRESSURE, pressure); |
849 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); | 767 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
850 | if (!prox) { /* out-prox */ | ||
851 | wacom->id[0] = 0; | ||
852 | wacom->shared->stylus_in_proximity = false; | ||
853 | } | ||
854 | input_report_key(input, wacom->tool[0], prox); | 768 | input_report_key(input, wacom->tool[0], prox); |
855 | input_report_abs(input, ABS_MISC, wacom->id[0]); | 769 | return 1; |
856 | retval = 1; | ||
857 | } | 770 | } |
858 | return retval; | 771 | |
772 | return 0; | ||
773 | } | ||
774 | |||
775 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | ||
776 | { | ||
777 | char *data = wacom->data; | ||
778 | |||
779 | dbg("wacom_tpc_irq: received report #%d", data[0]); | ||
780 | |||
781 | if (len == WACOM_PKGLEN_TPC1FG || data[0] == WACOM_REPORT_TPC1FG) | ||
782 | return wacom_tpc_single_touch(wacom, len); | ||
783 | else if (data[0] == WACOM_REPORT_TPC2FG) | ||
784 | return wacom_tpc_mt_touch(wacom); | ||
785 | else if (data[0] == WACOM_REPORT_PENABLED) | ||
786 | return wacom_tpc_pen(wacom); | ||
787 | |||
788 | return 0; | ||
859 | } | 789 | } |
860 | 790 | ||
861 | static int wacom_bpt_touch(struct wacom_wac *wacom) | 791 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
@@ -1078,7 +1008,7 @@ void wacom_setup_device_quirks(struct wacom_features *features) | |||
1078 | { | 1008 | { |
1079 | 1009 | ||
1080 | /* touch device found but size is not defined. use default */ | 1010 | /* touch device found but size is not defined. use default */ |
1081 | if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { | 1011 | if (features->device_type == BTN_TOOL_FINGER && !features->x_max) { |
1082 | features->x_max = 1023; | 1012 | features->x_max = 1023; |
1083 | features->y_max = 1023; | 1013 | features->y_max = 1023; |
1084 | } | 1014 | } |
@@ -1090,7 +1020,7 @@ void wacom_setup_device_quirks(struct wacom_features *features) | |||
1090 | 1020 | ||
1091 | /* quirks for bamboo touch */ | 1021 | /* quirks for bamboo touch */ |
1092 | if (features->type == BAMBOO_PT && | 1022 | if (features->type == BAMBOO_PT && |
1093 | features->device_type == BTN_TOOL_TRIPLETAP) { | 1023 | features->device_type == BTN_TOOL_DOUBLETAP) { |
1094 | features->x_max <<= 5; | 1024 | features->x_max <<= 5; |
1095 | features->y_max <<= 5; | 1025 | features->y_max <<= 5; |
1096 | features->x_fuzz <<= 5; | 1026 | features->x_fuzz <<= 5; |
@@ -1226,27 +1156,30 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1226 | break; | 1156 | break; |
1227 | 1157 | ||
1228 | case TABLETPC2FG: | 1158 | case TABLETPC2FG: |
1229 | if (features->device_type == BTN_TOOL_TRIPLETAP) { | 1159 | if (features->device_type == BTN_TOOL_DOUBLETAP) { |
1230 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | 1160 | |
1231 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); | 1161 | input_mt_init_slots(input_dev, 2); |
1162 | input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, | ||
1163 | 0, MT_TOOL_MAX, 0, 0); | ||
1164 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | ||
1165 | 0, features->x_max, 0, 0); | ||
1166 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | ||
1167 | 0, features->y_max, 0, 0); | ||
1232 | } | 1168 | } |
1233 | /* fall through */ | 1169 | /* fall through */ |
1234 | 1170 | ||
1235 | case TABLETPC: | 1171 | case TABLETPC: |
1236 | if (features->device_type == BTN_TOOL_DOUBLETAP || | 1172 | __clear_bit(ABS_MISC, input_dev->absbit); |
1237 | features->device_type == BTN_TOOL_TRIPLETAP) { | 1173 | |
1174 | if (features->device_type != BTN_TOOL_PEN) { | ||
1238 | input_abs_set_res(input_dev, ABS_X, | 1175 | input_abs_set_res(input_dev, ABS_X, |
1239 | wacom_calculate_touch_res(features->x_max, | 1176 | wacom_calculate_touch_res(features->x_max, |
1240 | features->x_phy)); | 1177 | features->x_phy)); |
1241 | input_abs_set_res(input_dev, ABS_Y, | 1178 | input_abs_set_res(input_dev, ABS_Y, |
1242 | wacom_calculate_touch_res(features->y_max, | 1179 | wacom_calculate_touch_res(features->y_max, |
1243 | features->y_phy)); | 1180 | features->y_phy)); |
1244 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
1245 | } | ||
1246 | |||
1247 | if (features->device_type != BTN_TOOL_PEN) | ||
1248 | break; /* no need to process stylus stuff */ | 1181 | break; /* no need to process stylus stuff */ |
1249 | 1182 | } | |
1250 | /* fall through */ | 1183 | /* fall through */ |
1251 | 1184 | ||
1252 | case PL: | 1185 | case PL: |
@@ -1264,7 +1197,7 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1264 | case BAMBOO_PT: | 1197 | case BAMBOO_PT: |
1265 | __clear_bit(ABS_MISC, input_dev->absbit); | 1198 | __clear_bit(ABS_MISC, input_dev->absbit); |
1266 | 1199 | ||
1267 | if (features->device_type == BTN_TOOL_TRIPLETAP) { | 1200 | if (features->device_type == BTN_TOOL_DOUBLETAP) { |
1268 | __set_bit(BTN_LEFT, input_dev->keybit); | 1201 | __set_bit(BTN_LEFT, input_dev->keybit); |
1269 | __set_bit(BTN_FORWARD, input_dev->keybit); | 1202 | __set_bit(BTN_FORWARD, input_dev->keybit); |
1270 | __set_bit(BTN_BACK, input_dev->keybit); | 1203 | __set_bit(BTN_BACK, input_dev->keybit); |
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index b1310ec9720c..835f756b150c 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h | |||
@@ -88,15 +88,15 @@ struct wacom_features { | |||
88 | 88 | ||
89 | struct wacom_shared { | 89 | struct wacom_shared { |
90 | bool stylus_in_proximity; | 90 | bool stylus_in_proximity; |
91 | bool touch_down; | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | struct wacom_wac { | 94 | struct wacom_wac { |
94 | char name[64]; | 95 | char name[64]; |
95 | unsigned char *data; | 96 | unsigned char *data; |
96 | int tool[3]; | 97 | int tool[2]; |
97 | int id[3]; | 98 | int id[2]; |
98 | __u32 serial[2]; | 99 | __u32 serial[2]; |
99 | int last_finger; | ||
100 | struct wacom_features features; | 100 | struct wacom_features features; |
101 | struct wacom_shared *shared; | 101 | struct wacom_shared *shared; |
102 | struct input_dev *input; | 102 | struct input_dev *input; |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 61834ae282e1..112ec55f2939 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -86,6 +86,18 @@ config TOUCHSCREEN_AD7879_SPI | |||
86 | To compile this driver as a module, choose M here: the | 86 | To compile this driver as a module, choose M here: the |
87 | module will be called ad7879-spi. | 87 | module will be called ad7879-spi. |
88 | 88 | ||
89 | config TOUCHSCREEN_ATMEL_MXT | ||
90 | tristate "Atmel mXT I2C Touchscreen" | ||
91 | depends on I2C | ||
92 | help | ||
93 | Say Y here if you have Atmel mXT series I2C touchscreen, | ||
94 | such as AT42QT602240/ATMXT224, connected to your system. | ||
95 | |||
96 | If unsure, say N. | ||
97 | |||
98 | To compile this driver as a module, choose M here: the | ||
99 | module will be called atmel_mxt_ts. | ||
100 | |||
89 | config TOUCHSCREEN_BITSY | 101 | config TOUCHSCREEN_BITSY |
90 | tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" | 102 | tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" |
91 | depends on SA1100_BITSY | 103 | depends on SA1100_BITSY |
@@ -339,18 +351,6 @@ config TOUCHSCREEN_PENMOUNT | |||
339 | To compile this driver as a module, choose M here: the | 351 | To compile this driver as a module, choose M here: the |
340 | module will be called penmount. | 352 | module will be called penmount. |
341 | 353 | ||
342 | config TOUCHSCREEN_QT602240 | ||
343 | tristate "QT602240 I2C Touchscreen" | ||
344 | depends on I2C | ||
345 | help | ||
346 | Say Y here if you have the AT42QT602240/ATMXT224 I2C touchscreen | ||
347 | connected to your system. | ||
348 | |||
349 | If unsure, say N. | ||
350 | |||
351 | To compile this driver as a module, choose M here: the | ||
352 | module will be called qt602240_ts. | ||
353 | |||
354 | config TOUCHSCREEN_MIGOR | 354 | config TOUCHSCREEN_MIGOR |
355 | tristate "Renesas MIGO-R touchscreen" | 355 | tristate "Renesas MIGO-R touchscreen" |
356 | depends on SH_MIGOR && I2C | 356 | depends on SH_MIGOR && I2C |
@@ -423,6 +423,16 @@ config TOUCHSCREEN_UCB1400 | |||
423 | To compile this driver as a module, choose M here: the | 423 | To compile this driver as a module, choose M here: the |
424 | module will be called ucb1400_ts. | 424 | module will be called ucb1400_ts. |
425 | 425 | ||
426 | config TOUCHSCREEN_WM831X | ||
427 | tristate "Support for WM831x touchscreen controllers" | ||
428 | depends on MFD_WM831X | ||
429 | help | ||
430 | This enables support for the touchscreen controller on the WM831x | ||
431 | series of PMICs. | ||
432 | |||
433 | To compile this driver as a module, choose M here: the | ||
434 | module will be called wm831x-ts. | ||
435 | |||
426 | config TOUCHSCREEN_WM97XX | 436 | config TOUCHSCREEN_WM97XX |
427 | tristate "Support for WM97xx AC97 touchscreen controllers" | 437 | tristate "Support for WM97xx AC97 touchscreen controllers" |
428 | depends on AC97_BUS | 438 | depends on AC97_BUS |
@@ -629,6 +639,17 @@ config TOUCHSCREEN_TOUCHIT213 | |||
629 | To compile this driver as a module, choose M here: the | 639 | To compile this driver as a module, choose M here: the |
630 | module will be called touchit213. | 640 | module will be called touchit213. |
631 | 641 | ||
642 | config TOUCHSCREEN_TSC2005 | ||
643 | tristate "TSC2005 based touchscreens" | ||
644 | depends on SPI_MASTER | ||
645 | help | ||
646 | Say Y here if you have a TSC2005 based touchscreen. | ||
647 | |||
648 | If unsure, say N. | ||
649 | |||
650 | To compile this driver as a module, choose M here: the | ||
651 | module will be called tsc2005. | ||
652 | |||
632 | config TOUCHSCREEN_TSC2007 | 653 | config TOUCHSCREEN_TSC2007 |
633 | tristate "TSC2007 based touchscreens" | 654 | tristate "TSC2007 based touchscreens" |
634 | depends on I2C | 655 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 718bcc814952..ca94098d4c92 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,6 +12,7 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o | |||
12 | obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o | 12 | obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o |
13 | obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o | 13 | obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o |
14 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o | 14 | obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o |
15 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o | ||
15 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o | 16 | obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o |
16 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o | 17 | obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o |
17 | obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o | 18 | obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o |
@@ -37,7 +38,6 @@ obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o | |||
37 | obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o | 38 | obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o |
38 | obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o | 39 | obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o |
39 | obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o | 40 | obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o |
40 | obj-$(CONFIG_TOUCHSCREEN_QT602240) += qt602240_ts.o | ||
41 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o | 41 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o |
42 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o | 42 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o |
43 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o | 43 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o |
@@ -45,9 +45,11 @@ obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o | |||
45 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | 45 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o |
46 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o | 46 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o |
47 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o | 47 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o |
48 | obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o | ||
48 | obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o | 49 | obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o |
49 | obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o | 50 | obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o |
50 | obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o | 51 | obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o |
52 | obj-$(CONFIG_TOUCHSCREEN_WM831X) += wm831x-ts.o | ||
51 | obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o | 53 | obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o |
52 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o | 54 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o |
53 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o | 55 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o |
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index a1952fcc083e..714d4e0f9f95 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/input.h> | 42 | #include <linux/input.h> |
43 | #include <linux/interrupt.h> | 43 | #include <linux/interrupt.h> |
44 | #include <linux/pm.h> | ||
44 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
45 | #include <linux/spi/spi.h> | 46 | #include <linux/spi/spi.h> |
46 | #include <linux/spi/ad7877.h> | 47 | #include <linux/spi/ad7877.h> |
@@ -826,39 +827,37 @@ static int __devexit ad7877_remove(struct spi_device *spi) | |||
826 | return 0; | 827 | return 0; |
827 | } | 828 | } |
828 | 829 | ||
829 | #ifdef CONFIG_PM | 830 | #ifdef CONFIG_PM_SLEEP |
830 | static int ad7877_suspend(struct spi_device *spi, pm_message_t message) | 831 | static int ad7877_suspend(struct device *dev) |
831 | { | 832 | { |
832 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 833 | struct ad7877 *ts = dev_get_drvdata(dev); |
833 | 834 | ||
834 | ad7877_disable(ts); | 835 | ad7877_disable(ts); |
835 | 836 | ||
836 | return 0; | 837 | return 0; |
837 | } | 838 | } |
838 | 839 | ||
839 | static int ad7877_resume(struct spi_device *spi) | 840 | static int ad7877_resume(struct device *dev) |
840 | { | 841 | { |
841 | struct ad7877 *ts = dev_get_drvdata(&spi->dev); | 842 | struct ad7877 *ts = dev_get_drvdata(dev); |
842 | 843 | ||
843 | ad7877_enable(ts); | 844 | ad7877_enable(ts); |
844 | 845 | ||
845 | return 0; | 846 | return 0; |
846 | } | 847 | } |
847 | #else | ||
848 | #define ad7877_suspend NULL | ||
849 | #define ad7877_resume NULL | ||
850 | #endif | 848 | #endif |
851 | 849 | ||
850 | static SIMPLE_DEV_PM_OPS(ad7877_pm, ad7877_suspend, ad7877_resume); | ||
851 | |||
852 | static struct spi_driver ad7877_driver = { | 852 | static struct spi_driver ad7877_driver = { |
853 | .driver = { | 853 | .driver = { |
854 | .name = "ad7877", | 854 | .name = "ad7877", |
855 | .bus = &spi_bus_type, | 855 | .bus = &spi_bus_type, |
856 | .owner = THIS_MODULE, | 856 | .owner = THIS_MODULE, |
857 | .pm = &ad7877_pm, | ||
857 | }, | 858 | }, |
858 | .probe = ad7877_probe, | 859 | .probe = ad7877_probe, |
859 | .remove = __devexit_p(ad7877_remove), | 860 | .remove = __devexit_p(ad7877_remove), |
860 | .suspend = ad7877_suspend, | ||
861 | .resume = ad7877_resume, | ||
862 | }; | 861 | }; |
863 | 862 | ||
864 | static int __init ad7877_init(void) | 863 | static int __init ad7877_init(void) |
diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c index 59c6e68c4325..ddf732f3cafc 100644 --- a/drivers/input/touchscreen/ad7879-spi.c +++ b/drivers/input/touchscreen/ad7879-spi.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/input.h> /* BUS_SPI */ | 9 | #include <linux/input.h> /* BUS_SPI */ |
10 | #include <linux/pm.h> | ||
10 | #include <linux/spi/spi.h> | 11 | #include <linux/spi/spi.h> |
11 | 12 | ||
12 | #include "ad7879.h" | 13 | #include "ad7879.h" |
@@ -20,9 +21,10 @@ | |||
20 | #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) | 21 | #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) |
21 | #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) | 22 | #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) |
22 | 23 | ||
23 | #ifdef CONFIG_PM | 24 | #ifdef CONFIG_PM_SLEEP |
24 | static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message) | 25 | static int ad7879_spi_suspend(struct device *dev) |
25 | { | 26 | { |
27 | struct spi_device *spi = to_spi_device(dev); | ||
26 | struct ad7879 *ts = spi_get_drvdata(spi); | 28 | struct ad7879 *ts = spi_get_drvdata(spi); |
27 | 29 | ||
28 | ad7879_suspend(ts); | 30 | ad7879_suspend(ts); |
@@ -30,19 +32,19 @@ static int ad7879_spi_suspend(struct spi_device *spi, pm_message_t message) | |||
30 | return 0; | 32 | return 0; |
31 | } | 33 | } |
32 | 34 | ||
33 | static int ad7879_spi_resume(struct spi_device *spi) | 35 | static int ad7879_spi_resume(struct device *dev) |
34 | { | 36 | { |
37 | struct spi_device *spi = to_spi_device(dev); | ||
35 | struct ad7879 *ts = spi_get_drvdata(spi); | 38 | struct ad7879 *ts = spi_get_drvdata(spi); |
36 | 39 | ||
37 | ad7879_resume(ts); | 40 | ad7879_resume(ts); |
38 | 41 | ||
39 | return 0; | 42 | return 0; |
40 | } | 43 | } |
41 | #else | ||
42 | # define ad7879_spi_suspend NULL | ||
43 | # define ad7879_spi_resume NULL | ||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend, ad7879_spi_resume); | ||
47 | |||
46 | /* | 48 | /* |
47 | * ad7879_read/write are only used for initial setup and for sysfs controls. | 49 | * ad7879_read/write are only used for initial setup and for sysfs controls. |
48 | * The main traffic is done in ad7879_collect(). | 50 | * The main traffic is done in ad7879_collect(). |
@@ -173,11 +175,10 @@ static struct spi_driver ad7879_spi_driver = { | |||
173 | .name = "ad7879", | 175 | .name = "ad7879", |
174 | .bus = &spi_bus_type, | 176 | .bus = &spi_bus_type, |
175 | .owner = THIS_MODULE, | 177 | .owner = THIS_MODULE, |
178 | .pm = &ad7879_spi_pm, | ||
176 | }, | 179 | }, |
177 | .probe = ad7879_spi_probe, | 180 | .probe = ad7879_spi_probe, |
178 | .remove = __devexit_p(ad7879_spi_remove), | 181 | .remove = __devexit_p(ad7879_spi_remove), |
179 | .suspend = ad7879_spi_suspend, | ||
180 | .resume = ad7879_spi_resume, | ||
181 | }; | 182 | }; |
182 | 183 | ||
183 | static int __init ad7879_spi_init(void) | 184 | static int __init ad7879_spi_init(void) |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 4bf2316e3284..c24946f51256 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/pm.h> | ||
29 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
30 | #include <linux/spi/spi.h> | 31 | #include <linux/spi/spi.h> |
31 | #include <linux/spi/ads7846.h> | 32 | #include <linux/spi/ads7846.h> |
@@ -892,9 +893,10 @@ static irqreturn_t ads7846_irq(int irq, void *handle) | |||
892 | return IRQ_HANDLED; | 893 | return IRQ_HANDLED; |
893 | } | 894 | } |
894 | 895 | ||
895 | static int ads7846_suspend(struct spi_device *spi, pm_message_t message) | 896 | #ifdef CONFIG_PM_SLEEP |
897 | static int ads7846_suspend(struct device *dev) | ||
896 | { | 898 | { |
897 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 899 | struct ads7846 *ts = dev_get_drvdata(dev); |
898 | 900 | ||
899 | mutex_lock(&ts->lock); | 901 | mutex_lock(&ts->lock); |
900 | 902 | ||
@@ -914,9 +916,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message) | |||
914 | return 0; | 916 | return 0; |
915 | } | 917 | } |
916 | 918 | ||
917 | static int ads7846_resume(struct spi_device *spi) | 919 | static int ads7846_resume(struct device *dev) |
918 | { | 920 | { |
919 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 921 | struct ads7846 *ts = dev_get_drvdata(dev); |
920 | 922 | ||
921 | mutex_lock(&ts->lock); | 923 | mutex_lock(&ts->lock); |
922 | 924 | ||
@@ -935,6 +937,9 @@ static int ads7846_resume(struct spi_device *spi) | |||
935 | 937 | ||
936 | return 0; | 938 | return 0; |
937 | } | 939 | } |
940 | #endif | ||
941 | |||
942 | static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); | ||
938 | 943 | ||
939 | static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) | 944 | static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) |
940 | { | 945 | { |
@@ -1408,11 +1413,10 @@ static struct spi_driver ads7846_driver = { | |||
1408 | .name = "ads7846", | 1413 | .name = "ads7846", |
1409 | .bus = &spi_bus_type, | 1414 | .bus = &spi_bus_type, |
1410 | .owner = THIS_MODULE, | 1415 | .owner = THIS_MODULE, |
1416 | .pm = &ads7846_pm, | ||
1411 | }, | 1417 | }, |
1412 | .probe = ads7846_probe, | 1418 | .probe = ads7846_probe, |
1413 | .remove = __devexit_p(ads7846_remove), | 1419 | .remove = __devexit_p(ads7846_remove), |
1414 | .suspend = ads7846_suspend, | ||
1415 | .resume = ads7846_resume, | ||
1416 | }; | 1420 | }; |
1417 | 1421 | ||
1418 | static int __init ads7846_init(void) | 1422 | static int __init ads7846_init(void) |
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c new file mode 100644 index 000000000000..4012436633b1 --- /dev/null +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -0,0 +1,1211 @@ | |||
1 | /* | ||
2 | * Atmel maXTouch Touchscreen driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Samsung Electronics Co.Ltd | ||
5 | * Author: Joonyoung Shim <jy0922.shim@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/firmware.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/i2c/atmel_mxt_ts.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/slab.h> | ||
23 | |||
24 | /* Version */ | ||
25 | #define MXT_VER_20 20 | ||
26 | #define MXT_VER_21 21 | ||
27 | #define MXT_VER_22 22 | ||
28 | |||
29 | /* Slave addresses */ | ||
30 | #define MXT_APP_LOW 0x4a | ||
31 | #define MXT_APP_HIGH 0x4b | ||
32 | #define MXT_BOOT_LOW 0x24 | ||
33 | #define MXT_BOOT_HIGH 0x25 | ||
34 | |||
35 | /* Firmware */ | ||
36 | #define MXT_FW_NAME "maxtouch.fw" | ||
37 | |||
38 | /* Registers */ | ||
39 | #define MXT_FAMILY_ID 0x00 | ||
40 | #define MXT_VARIANT_ID 0x01 | ||
41 | #define MXT_VERSION 0x02 | ||
42 | #define MXT_BUILD 0x03 | ||
43 | #define MXT_MATRIX_X_SIZE 0x04 | ||
44 | #define MXT_MATRIX_Y_SIZE 0x05 | ||
45 | #define MXT_OBJECT_NUM 0x06 | ||
46 | #define MXT_OBJECT_START 0x07 | ||
47 | |||
48 | #define MXT_OBJECT_SIZE 6 | ||
49 | |||
50 | /* Object types */ | ||
51 | #define MXT_DEBUG_DIAGNOSTIC 37 | ||
52 | #define MXT_GEN_MESSAGE 5 | ||
53 | #define MXT_GEN_COMMAND 6 | ||
54 | #define MXT_GEN_POWER 7 | ||
55 | #define MXT_GEN_ACQUIRE 8 | ||
56 | #define MXT_TOUCH_MULTI 9 | ||
57 | #define MXT_TOUCH_KEYARRAY 15 | ||
58 | #define MXT_TOUCH_PROXIMITY 23 | ||
59 | #define MXT_PROCI_GRIPFACE 20 | ||
60 | #define MXT_PROCG_NOISE 22 | ||
61 | #define MXT_PROCI_ONETOUCH 24 | ||
62 | #define MXT_PROCI_TWOTOUCH 27 | ||
63 | #define MXT_PROCI_GRIP 40 | ||
64 | #define MXT_PROCI_PALM 41 | ||
65 | #define MXT_SPT_COMMSCONFIG 18 | ||
66 | #define MXT_SPT_GPIOPWM 19 | ||
67 | #define MXT_SPT_SELFTEST 25 | ||
68 | #define MXT_SPT_CTECONFIG 28 | ||
69 | #define MXT_SPT_USERDATA 38 | ||
70 | #define MXT_SPT_DIGITIZER 43 | ||
71 | #define MXT_SPT_MESSAGECOUNT 44 | ||
72 | |||
73 | /* MXT_GEN_COMMAND field */ | ||
74 | #define MXT_COMMAND_RESET 0 | ||
75 | #define MXT_COMMAND_BACKUPNV 1 | ||
76 | #define MXT_COMMAND_CALIBRATE 2 | ||
77 | #define MXT_COMMAND_REPORTALL 3 | ||
78 | #define MXT_COMMAND_DIAGNOSTIC 5 | ||
79 | |||
80 | /* MXT_GEN_POWER field */ | ||
81 | #define MXT_POWER_IDLEACQINT 0 | ||
82 | #define MXT_POWER_ACTVACQINT 1 | ||
83 | #define MXT_POWER_ACTV2IDLETO 2 | ||
84 | |||
85 | /* MXT_GEN_ACQUIRE field */ | ||
86 | #define MXT_ACQUIRE_CHRGTIME 0 | ||
87 | #define MXT_ACQUIRE_TCHDRIFT 2 | ||
88 | #define MXT_ACQUIRE_DRIFTST 3 | ||
89 | #define MXT_ACQUIRE_TCHAUTOCAL 4 | ||
90 | #define MXT_ACQUIRE_SYNC 5 | ||
91 | #define MXT_ACQUIRE_ATCHCALST 6 | ||
92 | #define MXT_ACQUIRE_ATCHCALSTHR 7 | ||
93 | |||
94 | /* MXT_TOUCH_MULTI field */ | ||
95 | #define MXT_TOUCH_CTRL 0 | ||
96 | #define MXT_TOUCH_XORIGIN 1 | ||
97 | #define MXT_TOUCH_YORIGIN 2 | ||
98 | #define MXT_TOUCH_XSIZE 3 | ||
99 | #define MXT_TOUCH_YSIZE 4 | ||
100 | #define MXT_TOUCH_BLEN 6 | ||
101 | #define MXT_TOUCH_TCHTHR 7 | ||
102 | #define MXT_TOUCH_TCHDI 8 | ||
103 | #define MXT_TOUCH_ORIENT 9 | ||
104 | #define MXT_TOUCH_MOVHYSTI 11 | ||
105 | #define MXT_TOUCH_MOVHYSTN 12 | ||
106 | #define MXT_TOUCH_NUMTOUCH 14 | ||
107 | #define MXT_TOUCH_MRGHYST 15 | ||
108 | #define MXT_TOUCH_MRGTHR 16 | ||
109 | #define MXT_TOUCH_AMPHYST 17 | ||
110 | #define MXT_TOUCH_XRANGE_LSB 18 | ||
111 | #define MXT_TOUCH_XRANGE_MSB 19 | ||
112 | #define MXT_TOUCH_YRANGE_LSB 20 | ||
113 | #define MXT_TOUCH_YRANGE_MSB 21 | ||
114 | #define MXT_TOUCH_XLOCLIP 22 | ||
115 | #define MXT_TOUCH_XHICLIP 23 | ||
116 | #define MXT_TOUCH_YLOCLIP 24 | ||
117 | #define MXT_TOUCH_YHICLIP 25 | ||
118 | #define MXT_TOUCH_XEDGECTRL 26 | ||
119 | #define MXT_TOUCH_XEDGEDIST 27 | ||
120 | #define MXT_TOUCH_YEDGECTRL 28 | ||
121 | #define MXT_TOUCH_YEDGEDIST 29 | ||
122 | #define MXT_TOUCH_JUMPLIMIT 30 | ||
123 | |||
124 | /* MXT_PROCI_GRIPFACE field */ | ||
125 | #define MXT_GRIPFACE_CTRL 0 | ||
126 | #define MXT_GRIPFACE_XLOGRIP 1 | ||
127 | #define MXT_GRIPFACE_XHIGRIP 2 | ||
128 | #define MXT_GRIPFACE_YLOGRIP 3 | ||
129 | #define MXT_GRIPFACE_YHIGRIP 4 | ||
130 | #define MXT_GRIPFACE_MAXTCHS 5 | ||
131 | #define MXT_GRIPFACE_SZTHR1 7 | ||
132 | #define MXT_GRIPFACE_SZTHR2 8 | ||
133 | #define MXT_GRIPFACE_SHPTHR1 9 | ||
134 | #define MXT_GRIPFACE_SHPTHR2 10 | ||
135 | #define MXT_GRIPFACE_SUPEXTTO 11 | ||
136 | |||
137 | /* MXT_PROCI_NOISE field */ | ||
138 | #define MXT_NOISE_CTRL 0 | ||
139 | #define MXT_NOISE_OUTFLEN 1 | ||
140 | #define MXT_NOISE_GCAFUL_LSB 3 | ||
141 | #define MXT_NOISE_GCAFUL_MSB 4 | ||
142 | #define MXT_NOISE_GCAFLL_LSB 5 | ||
143 | #define MXT_NOISE_GCAFLL_MSB 6 | ||
144 | #define MXT_NOISE_ACTVGCAFVALID 7 | ||
145 | #define MXT_NOISE_NOISETHR 8 | ||
146 | #define MXT_NOISE_FREQHOPSCALE 10 | ||
147 | #define MXT_NOISE_FREQ0 11 | ||
148 | #define MXT_NOISE_FREQ1 12 | ||
149 | #define MXT_NOISE_FREQ2 13 | ||
150 | #define MXT_NOISE_FREQ3 14 | ||
151 | #define MXT_NOISE_FREQ4 15 | ||
152 | #define MXT_NOISE_IDLEGCAFVALID 16 | ||
153 | |||
154 | /* MXT_SPT_COMMSCONFIG */ | ||
155 | #define MXT_COMMS_CTRL 0 | ||
156 | #define MXT_COMMS_CMD 1 | ||
157 | |||
158 | /* MXT_SPT_CTECONFIG field */ | ||
159 | #define MXT_CTE_CTRL 0 | ||
160 | #define MXT_CTE_CMD 1 | ||
161 | #define MXT_CTE_MODE 2 | ||
162 | #define MXT_CTE_IDLEGCAFDEPTH 3 | ||
163 | #define MXT_CTE_ACTVGCAFDEPTH 4 | ||
164 | #define MXT_CTE_VOLTAGE 5 | ||
165 | |||
166 | #define MXT_VOLTAGE_DEFAULT 2700000 | ||
167 | #define MXT_VOLTAGE_STEP 10000 | ||
168 | |||
169 | /* Define for MXT_GEN_COMMAND */ | ||
170 | #define MXT_BOOT_VALUE 0xa5 | ||
171 | #define MXT_BACKUP_VALUE 0x55 | ||
172 | #define MXT_BACKUP_TIME 25 /* msec */ | ||
173 | #define MXT_RESET_TIME 65 /* msec */ | ||
174 | |||
175 | #define MXT_FWRESET_TIME 175 /* msec */ | ||
176 | |||
177 | /* Command to unlock bootloader */ | ||
178 | #define MXT_UNLOCK_CMD_MSB 0xaa | ||
179 | #define MXT_UNLOCK_CMD_LSB 0xdc | ||
180 | |||
181 | /* Bootloader mode status */ | ||
182 | #define MXT_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */ | ||
183 | #define MXT_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */ | ||
184 | #define MXT_FRAME_CRC_CHECK 0x02 | ||
185 | #define MXT_FRAME_CRC_FAIL 0x03 | ||
186 | #define MXT_FRAME_CRC_PASS 0x04 | ||
187 | #define MXT_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */ | ||
188 | #define MXT_BOOT_STATUS_MASK 0x3f | ||
189 | |||
190 | /* Touch status */ | ||
191 | #define MXT_SUPPRESS (1 << 1) | ||
192 | #define MXT_AMP (1 << 2) | ||
193 | #define MXT_VECTOR (1 << 3) | ||
194 | #define MXT_MOVE (1 << 4) | ||
195 | #define MXT_RELEASE (1 << 5) | ||
196 | #define MXT_PRESS (1 << 6) | ||
197 | #define MXT_DETECT (1 << 7) | ||
198 | |||
199 | /* Touchscreen absolute values */ | ||
200 | #define MXT_MAX_XC 0x3ff | ||
201 | #define MXT_MAX_YC 0x3ff | ||
202 | #define MXT_MAX_AREA 0xff | ||
203 | |||
204 | #define MXT_MAX_FINGER 10 | ||
205 | |||
206 | struct mxt_info { | ||
207 | u8 family_id; | ||
208 | u8 variant_id; | ||
209 | u8 version; | ||
210 | u8 build; | ||
211 | u8 matrix_xsize; | ||
212 | u8 matrix_ysize; | ||
213 | u8 object_num; | ||
214 | }; | ||
215 | |||
216 | struct mxt_object { | ||
217 | u8 type; | ||
218 | u16 start_address; | ||
219 | u8 size; | ||
220 | u8 instances; | ||
221 | u8 num_report_ids; | ||
222 | |||
223 | /* to map object and message */ | ||
224 | u8 max_reportid; | ||
225 | }; | ||
226 | |||
227 | struct mxt_message { | ||
228 | u8 reportid; | ||
229 | u8 message[7]; | ||
230 | u8 checksum; | ||
231 | }; | ||
232 | |||
233 | struct mxt_finger { | ||
234 | int status; | ||
235 | int x; | ||
236 | int y; | ||
237 | int area; | ||
238 | }; | ||
239 | |||
240 | /* Each client has this additional data */ | ||
241 | struct mxt_data { | ||
242 | struct i2c_client *client; | ||
243 | struct input_dev *input_dev; | ||
244 | const struct mxt_platform_data *pdata; | ||
245 | struct mxt_object *object_table; | ||
246 | struct mxt_info info; | ||
247 | struct mxt_finger finger[MXT_MAX_FINGER]; | ||
248 | unsigned int irq; | ||
249 | }; | ||
250 | |||
251 | static bool mxt_object_readable(unsigned int type) | ||
252 | { | ||
253 | switch (type) { | ||
254 | case MXT_GEN_MESSAGE: | ||
255 | case MXT_GEN_COMMAND: | ||
256 | case MXT_GEN_POWER: | ||
257 | case MXT_GEN_ACQUIRE: | ||
258 | case MXT_TOUCH_MULTI: | ||
259 | case MXT_TOUCH_KEYARRAY: | ||
260 | case MXT_TOUCH_PROXIMITY: | ||
261 | case MXT_PROCI_GRIPFACE: | ||
262 | case MXT_PROCG_NOISE: | ||
263 | case MXT_PROCI_ONETOUCH: | ||
264 | case MXT_PROCI_TWOTOUCH: | ||
265 | case MXT_PROCI_GRIP: | ||
266 | case MXT_PROCI_PALM: | ||
267 | case MXT_SPT_COMMSCONFIG: | ||
268 | case MXT_SPT_GPIOPWM: | ||
269 | case MXT_SPT_SELFTEST: | ||
270 | case MXT_SPT_CTECONFIG: | ||
271 | case MXT_SPT_USERDATA: | ||
272 | return true; | ||
273 | default: | ||
274 | return false; | ||
275 | } | ||
276 | } | ||
277 | |||
278 | static bool mxt_object_writable(unsigned int type) | ||
279 | { | ||
280 | switch (type) { | ||
281 | case MXT_GEN_COMMAND: | ||
282 | case MXT_GEN_POWER: | ||
283 | case MXT_GEN_ACQUIRE: | ||
284 | case MXT_TOUCH_MULTI: | ||
285 | case MXT_TOUCH_KEYARRAY: | ||
286 | case MXT_TOUCH_PROXIMITY: | ||
287 | case MXT_PROCI_GRIPFACE: | ||
288 | case MXT_PROCG_NOISE: | ||
289 | case MXT_PROCI_ONETOUCH: | ||
290 | case MXT_PROCI_TWOTOUCH: | ||
291 | case MXT_PROCI_GRIP: | ||
292 | case MXT_PROCI_PALM: | ||
293 | case MXT_SPT_GPIOPWM: | ||
294 | case MXT_SPT_SELFTEST: | ||
295 | case MXT_SPT_CTECONFIG: | ||
296 | return true; | ||
297 | default: | ||
298 | return false; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | static void mxt_dump_message(struct device *dev, | ||
303 | struct mxt_message *message) | ||
304 | { | ||
305 | dev_dbg(dev, "reportid:\t0x%x\n", message->reportid); | ||
306 | dev_dbg(dev, "message1:\t0x%x\n", message->message[0]); | ||
307 | dev_dbg(dev, "message2:\t0x%x\n", message->message[1]); | ||
308 | dev_dbg(dev, "message3:\t0x%x\n", message->message[2]); | ||
309 | dev_dbg(dev, "message4:\t0x%x\n", message->message[3]); | ||
310 | dev_dbg(dev, "message5:\t0x%x\n", message->message[4]); | ||
311 | dev_dbg(dev, "message6:\t0x%x\n", message->message[5]); | ||
312 | dev_dbg(dev, "message7:\t0x%x\n", message->message[6]); | ||
313 | dev_dbg(dev, "checksum:\t0x%x\n", message->checksum); | ||
314 | } | ||
315 | |||
316 | static int mxt_check_bootloader(struct i2c_client *client, | ||
317 | unsigned int state) | ||
318 | { | ||
319 | u8 val; | ||
320 | |||
321 | recheck: | ||
322 | if (i2c_master_recv(client, &val, 1) != 1) { | ||
323 | dev_err(&client->dev, "%s: i2c recv failed\n", __func__); | ||
324 | return -EIO; | ||
325 | } | ||
326 | |||
327 | switch (state) { | ||
328 | case MXT_WAITING_BOOTLOAD_CMD: | ||
329 | case MXT_WAITING_FRAME_DATA: | ||
330 | val &= ~MXT_BOOT_STATUS_MASK; | ||
331 | break; | ||
332 | case MXT_FRAME_CRC_PASS: | ||
333 | if (val == MXT_FRAME_CRC_CHECK) | ||
334 | goto recheck; | ||
335 | break; | ||
336 | default: | ||
337 | return -EINVAL; | ||
338 | } | ||
339 | |||
340 | if (val != state) { | ||
341 | dev_err(&client->dev, "Unvalid bootloader mode state\n"); | ||
342 | return -EINVAL; | ||
343 | } | ||
344 | |||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static int mxt_unlock_bootloader(struct i2c_client *client) | ||
349 | { | ||
350 | u8 buf[2]; | ||
351 | |||
352 | buf[0] = MXT_UNLOCK_CMD_LSB; | ||
353 | buf[1] = MXT_UNLOCK_CMD_MSB; | ||
354 | |||
355 | if (i2c_master_send(client, buf, 2) != 2) { | ||
356 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
357 | return -EIO; | ||
358 | } | ||
359 | |||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int mxt_fw_write(struct i2c_client *client, | ||
364 | const u8 *data, unsigned int frame_size) | ||
365 | { | ||
366 | if (i2c_master_send(client, data, frame_size) != frame_size) { | ||
367 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
368 | return -EIO; | ||
369 | } | ||
370 | |||
371 | return 0; | ||
372 | } | ||
373 | |||
374 | static int __mxt_read_reg(struct i2c_client *client, | ||
375 | u16 reg, u16 len, void *val) | ||
376 | { | ||
377 | struct i2c_msg xfer[2]; | ||
378 | u8 buf[2]; | ||
379 | |||
380 | buf[0] = reg & 0xff; | ||
381 | buf[1] = (reg >> 8) & 0xff; | ||
382 | |||
383 | /* Write register */ | ||
384 | xfer[0].addr = client->addr; | ||
385 | xfer[0].flags = 0; | ||
386 | xfer[0].len = 2; | ||
387 | xfer[0].buf = buf; | ||
388 | |||
389 | /* Read data */ | ||
390 | xfer[1].addr = client->addr; | ||
391 | xfer[1].flags = I2C_M_RD; | ||
392 | xfer[1].len = len; | ||
393 | xfer[1].buf = val; | ||
394 | |||
395 | if (i2c_transfer(client->adapter, xfer, 2) != 2) { | ||
396 | dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); | ||
397 | return -EIO; | ||
398 | } | ||
399 | |||
400 | return 0; | ||
401 | } | ||
402 | |||
403 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | ||
404 | { | ||
405 | return __mxt_read_reg(client, reg, 1, val); | ||
406 | } | ||
407 | |||
408 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) | ||
409 | { | ||
410 | u8 buf[3]; | ||
411 | |||
412 | buf[0] = reg & 0xff; | ||
413 | buf[1] = (reg >> 8) & 0xff; | ||
414 | buf[2] = val; | ||
415 | |||
416 | if (i2c_master_send(client, buf, 3) != 3) { | ||
417 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
418 | return -EIO; | ||
419 | } | ||
420 | |||
421 | return 0; | ||
422 | } | ||
423 | |||
424 | static int mxt_read_object_table(struct i2c_client *client, | ||
425 | u16 reg, u8 *object_buf) | ||
426 | { | ||
427 | return __mxt_read_reg(client, reg, MXT_OBJECT_SIZE, | ||
428 | object_buf); | ||
429 | } | ||
430 | |||
431 | static struct mxt_object * | ||
432 | mxt_get_object(struct mxt_data *data, u8 type) | ||
433 | { | ||
434 | struct mxt_object *object; | ||
435 | int i; | ||
436 | |||
437 | for (i = 0; i < data->info.object_num; i++) { | ||
438 | object = data->object_table + i; | ||
439 | if (object->type == type) | ||
440 | return object; | ||
441 | } | ||
442 | |||
443 | dev_err(&data->client->dev, "Invalid object type\n"); | ||
444 | return NULL; | ||
445 | } | ||
446 | |||
447 | static int mxt_read_message(struct mxt_data *data, | ||
448 | struct mxt_message *message) | ||
449 | { | ||
450 | struct mxt_object *object; | ||
451 | u16 reg; | ||
452 | |||
453 | object = mxt_get_object(data, MXT_GEN_MESSAGE); | ||
454 | if (!object) | ||
455 | return -EINVAL; | ||
456 | |||
457 | reg = object->start_address; | ||
458 | return __mxt_read_reg(data->client, reg, | ||
459 | sizeof(struct mxt_message), message); | ||
460 | } | ||
461 | |||
462 | static int mxt_read_object(struct mxt_data *data, | ||
463 | u8 type, u8 offset, u8 *val) | ||
464 | { | ||
465 | struct mxt_object *object; | ||
466 | u16 reg; | ||
467 | |||
468 | object = mxt_get_object(data, type); | ||
469 | if (!object) | ||
470 | return -EINVAL; | ||
471 | |||
472 | reg = object->start_address; | ||
473 | return __mxt_read_reg(data->client, reg + offset, 1, val); | ||
474 | } | ||
475 | |||
476 | static int mxt_write_object(struct mxt_data *data, | ||
477 | u8 type, u8 offset, u8 val) | ||
478 | { | ||
479 | struct mxt_object *object; | ||
480 | u16 reg; | ||
481 | |||
482 | object = mxt_get_object(data, type); | ||
483 | if (!object) | ||
484 | return -EINVAL; | ||
485 | |||
486 | reg = object->start_address; | ||
487 | return mxt_write_reg(data->client, reg + offset, val); | ||
488 | } | ||
489 | |||
490 | static void mxt_input_report(struct mxt_data *data, int single_id) | ||
491 | { | ||
492 | struct mxt_finger *finger = data->finger; | ||
493 | struct input_dev *input_dev = data->input_dev; | ||
494 | int status = finger[single_id].status; | ||
495 | int finger_num = 0; | ||
496 | int id; | ||
497 | |||
498 | for (id = 0; id < MXT_MAX_FINGER; id++) { | ||
499 | if (!finger[id].status) | ||
500 | continue; | ||
501 | |||
502 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
503 | finger[id].status != MXT_RELEASE ? | ||
504 | finger[id].area : 0); | ||
505 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
506 | finger[id].x); | ||
507 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
508 | finger[id].y); | ||
509 | input_mt_sync(input_dev); | ||
510 | |||
511 | if (finger[id].status == MXT_RELEASE) | ||
512 | finger[id].status = 0; | ||
513 | else | ||
514 | finger_num++; | ||
515 | } | ||
516 | |||
517 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); | ||
518 | |||
519 | if (status != MXT_RELEASE) { | ||
520 | input_report_abs(input_dev, ABS_X, finger[single_id].x); | ||
521 | input_report_abs(input_dev, ABS_Y, finger[single_id].y); | ||
522 | } | ||
523 | |||
524 | input_sync(input_dev); | ||
525 | } | ||
526 | |||
527 | static void mxt_input_touchevent(struct mxt_data *data, | ||
528 | struct mxt_message *message, int id) | ||
529 | { | ||
530 | struct mxt_finger *finger = data->finger; | ||
531 | struct device *dev = &data->client->dev; | ||
532 | u8 status = message->message[0]; | ||
533 | int x; | ||
534 | int y; | ||
535 | int area; | ||
536 | |||
537 | /* Check the touch is present on the screen */ | ||
538 | if (!(status & MXT_DETECT)) { | ||
539 | if (status & MXT_RELEASE) { | ||
540 | dev_dbg(dev, "[%d] released\n", id); | ||
541 | |||
542 | finger[id].status = MXT_RELEASE; | ||
543 | mxt_input_report(data, id); | ||
544 | } | ||
545 | return; | ||
546 | } | ||
547 | |||
548 | /* Check only AMP detection */ | ||
549 | if (!(status & (MXT_PRESS | MXT_MOVE))) | ||
550 | return; | ||
551 | |||
552 | x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); | ||
553 | y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); | ||
554 | area = message->message[4]; | ||
555 | |||
556 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | ||
557 | status & MXT_MOVE ? "moved" : "pressed", | ||
558 | x, y, area); | ||
559 | |||
560 | finger[id].status = status & MXT_MOVE ? | ||
561 | MXT_MOVE : MXT_PRESS; | ||
562 | finger[id].x = x; | ||
563 | finger[id].y = y; | ||
564 | finger[id].area = area; | ||
565 | |||
566 | mxt_input_report(data, id); | ||
567 | } | ||
568 | |||
569 | static irqreturn_t mxt_interrupt(int irq, void *dev_id) | ||
570 | { | ||
571 | struct mxt_data *data = dev_id; | ||
572 | struct mxt_message message; | ||
573 | struct mxt_object *object; | ||
574 | struct device *dev = &data->client->dev; | ||
575 | int id; | ||
576 | u8 reportid; | ||
577 | u8 max_reportid; | ||
578 | u8 min_reportid; | ||
579 | |||
580 | do { | ||
581 | if (mxt_read_message(data, &message)) { | ||
582 | dev_err(dev, "Failed to read message\n"); | ||
583 | goto end; | ||
584 | } | ||
585 | |||
586 | reportid = message.reportid; | ||
587 | |||
588 | /* whether reportid is thing of MXT_TOUCH_MULTI */ | ||
589 | object = mxt_get_object(data, MXT_TOUCH_MULTI); | ||
590 | if (!object) | ||
591 | goto end; | ||
592 | |||
593 | max_reportid = object->max_reportid; | ||
594 | min_reportid = max_reportid - object->num_report_ids + 1; | ||
595 | id = reportid - min_reportid; | ||
596 | |||
597 | if (reportid >= min_reportid && reportid <= max_reportid) | ||
598 | mxt_input_touchevent(data, &message, id); | ||
599 | else | ||
600 | mxt_dump_message(dev, &message); | ||
601 | } while (reportid != 0xff); | ||
602 | |||
603 | end: | ||
604 | return IRQ_HANDLED; | ||
605 | } | ||
606 | |||
607 | static int mxt_check_reg_init(struct mxt_data *data) | ||
608 | { | ||
609 | const struct mxt_platform_data *pdata = data->pdata; | ||
610 | struct mxt_object *object; | ||
611 | struct device *dev = &data->client->dev; | ||
612 | int index = 0; | ||
613 | int i, j, config_offset; | ||
614 | |||
615 | if (!pdata->config) { | ||
616 | dev_dbg(dev, "No cfg data defined, skipping reg init\n"); | ||
617 | return 0; | ||
618 | } | ||
619 | |||
620 | for (i = 0; i < data->info.object_num; i++) { | ||
621 | object = data->object_table + i; | ||
622 | |||
623 | if (!mxt_object_writable(object->type)) | ||
624 | continue; | ||
625 | |||
626 | for (j = 0; j < object->size + 1; j++) { | ||
627 | config_offset = index + j; | ||
628 | if (config_offset > pdata->config_length) { | ||
629 | dev_err(dev, "Not enough config data!\n"); | ||
630 | return -EINVAL; | ||
631 | } | ||
632 | mxt_write_object(data, object->type, j, | ||
633 | pdata->config[config_offset]); | ||
634 | } | ||
635 | index += object->size + 1; | ||
636 | } | ||
637 | |||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static int mxt_make_highchg(struct mxt_data *data) | ||
642 | { | ||
643 | struct device *dev = &data->client->dev; | ||
644 | struct mxt_message message; | ||
645 | int count = 10; | ||
646 | int error; | ||
647 | |||
648 | /* Read dummy message to make high CHG pin */ | ||
649 | do { | ||
650 | error = mxt_read_message(data, &message); | ||
651 | if (error) | ||
652 | return error; | ||
653 | } while (message.reportid != 0xff && --count); | ||
654 | |||
655 | if (!count) { | ||
656 | dev_err(dev, "CHG pin isn't cleared\n"); | ||
657 | return -EBUSY; | ||
658 | } | ||
659 | |||
660 | return 0; | ||
661 | } | ||
662 | |||
663 | static void mxt_handle_pdata(struct mxt_data *data) | ||
664 | { | ||
665 | const struct mxt_platform_data *pdata = data->pdata; | ||
666 | u8 voltage; | ||
667 | |||
668 | /* Set touchscreen lines */ | ||
669 | mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_XSIZE, | ||
670 | pdata->x_line); | ||
671 | mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_YSIZE, | ||
672 | pdata->y_line); | ||
673 | |||
674 | /* Set touchscreen orient */ | ||
675 | mxt_write_object(data, MXT_TOUCH_MULTI, MXT_TOUCH_ORIENT, | ||
676 | pdata->orient); | ||
677 | |||
678 | /* Set touchscreen burst length */ | ||
679 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
680 | MXT_TOUCH_BLEN, pdata->blen); | ||
681 | |||
682 | /* Set touchscreen threshold */ | ||
683 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
684 | MXT_TOUCH_TCHTHR, pdata->threshold); | ||
685 | |||
686 | /* Set touchscreen resolution */ | ||
687 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
688 | MXT_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff); | ||
689 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
690 | MXT_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8); | ||
691 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
692 | MXT_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff); | ||
693 | mxt_write_object(data, MXT_TOUCH_MULTI, | ||
694 | MXT_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8); | ||
695 | |||
696 | /* Set touchscreen voltage */ | ||
697 | if (pdata->voltage) { | ||
698 | if (pdata->voltage < MXT_VOLTAGE_DEFAULT) { | ||
699 | voltage = (MXT_VOLTAGE_DEFAULT - pdata->voltage) / | ||
700 | MXT_VOLTAGE_STEP; | ||
701 | voltage = 0xff - voltage + 1; | ||
702 | } else | ||
703 | voltage = (pdata->voltage - MXT_VOLTAGE_DEFAULT) / | ||
704 | MXT_VOLTAGE_STEP; | ||
705 | |||
706 | mxt_write_object(data, MXT_SPT_CTECONFIG, | ||
707 | MXT_CTE_VOLTAGE, voltage); | ||
708 | } | ||
709 | } | ||
710 | |||
711 | static int mxt_get_info(struct mxt_data *data) | ||
712 | { | ||
713 | struct i2c_client *client = data->client; | ||
714 | struct mxt_info *info = &data->info; | ||
715 | int error; | ||
716 | u8 val; | ||
717 | |||
718 | error = mxt_read_reg(client, MXT_FAMILY_ID, &val); | ||
719 | if (error) | ||
720 | return error; | ||
721 | info->family_id = val; | ||
722 | |||
723 | error = mxt_read_reg(client, MXT_VARIANT_ID, &val); | ||
724 | if (error) | ||
725 | return error; | ||
726 | info->variant_id = val; | ||
727 | |||
728 | error = mxt_read_reg(client, MXT_VERSION, &val); | ||
729 | if (error) | ||
730 | return error; | ||
731 | info->version = val; | ||
732 | |||
733 | error = mxt_read_reg(client, MXT_BUILD, &val); | ||
734 | if (error) | ||
735 | return error; | ||
736 | info->build = val; | ||
737 | |||
738 | error = mxt_read_reg(client, MXT_OBJECT_NUM, &val); | ||
739 | if (error) | ||
740 | return error; | ||
741 | info->object_num = val; | ||
742 | |||
743 | return 0; | ||
744 | } | ||
745 | |||
746 | static int mxt_get_object_table(struct mxt_data *data) | ||
747 | { | ||
748 | int error; | ||
749 | int i; | ||
750 | u16 reg; | ||
751 | u8 reportid = 0; | ||
752 | u8 buf[MXT_OBJECT_SIZE]; | ||
753 | |||
754 | for (i = 0; i < data->info.object_num; i++) { | ||
755 | struct mxt_object *object = data->object_table + i; | ||
756 | |||
757 | reg = MXT_OBJECT_START + MXT_OBJECT_SIZE * i; | ||
758 | error = mxt_read_object_table(data->client, reg, buf); | ||
759 | if (error) | ||
760 | return error; | ||
761 | |||
762 | object->type = buf[0]; | ||
763 | object->start_address = (buf[2] << 8) | buf[1]; | ||
764 | object->size = buf[3]; | ||
765 | object->instances = buf[4]; | ||
766 | object->num_report_ids = buf[5]; | ||
767 | |||
768 | if (object->num_report_ids) { | ||
769 | reportid += object->num_report_ids * | ||
770 | (object->instances + 1); | ||
771 | object->max_reportid = reportid; | ||
772 | } | ||
773 | } | ||
774 | |||
775 | return 0; | ||
776 | } | ||
777 | |||
778 | static int mxt_initialize(struct mxt_data *data) | ||
779 | { | ||
780 | struct i2c_client *client = data->client; | ||
781 | struct mxt_info *info = &data->info; | ||
782 | int error; | ||
783 | u8 val; | ||
784 | |||
785 | error = mxt_get_info(data); | ||
786 | if (error) | ||
787 | return error; | ||
788 | |||
789 | data->object_table = kcalloc(info->object_num, | ||
790 | sizeof(struct mxt_object), | ||
791 | GFP_KERNEL); | ||
792 | if (!data->object_table) { | ||
793 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
794 | return -ENOMEM; | ||
795 | } | ||
796 | |||
797 | /* Get object table information */ | ||
798 | error = mxt_get_object_table(data); | ||
799 | if (error) | ||
800 | return error; | ||
801 | |||
802 | /* Check register init values */ | ||
803 | error = mxt_check_reg_init(data); | ||
804 | if (error) | ||
805 | return error; | ||
806 | |||
807 | error = mxt_make_highchg(data); | ||
808 | if (error) | ||
809 | return error; | ||
810 | |||
811 | mxt_handle_pdata(data); | ||
812 | |||
813 | /* Backup to memory */ | ||
814 | mxt_write_object(data, MXT_GEN_COMMAND, | ||
815 | MXT_COMMAND_BACKUPNV, | ||
816 | MXT_BACKUP_VALUE); | ||
817 | msleep(MXT_BACKUP_TIME); | ||
818 | |||
819 | /* Soft reset */ | ||
820 | mxt_write_object(data, MXT_GEN_COMMAND, | ||
821 | MXT_COMMAND_RESET, 1); | ||
822 | msleep(MXT_RESET_TIME); | ||
823 | |||
824 | /* Update matrix size at info struct */ | ||
825 | error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); | ||
826 | if (error) | ||
827 | return error; | ||
828 | info->matrix_xsize = val; | ||
829 | |||
830 | error = mxt_read_reg(client, MXT_MATRIX_Y_SIZE, &val); | ||
831 | if (error) | ||
832 | return error; | ||
833 | info->matrix_ysize = val; | ||
834 | |||
835 | dev_info(&client->dev, | ||
836 | "Family ID: %d Variant ID: %d Version: %d Build: %d\n", | ||
837 | info->family_id, info->variant_id, info->version, | ||
838 | info->build); | ||
839 | |||
840 | dev_info(&client->dev, | ||
841 | "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", | ||
842 | info->matrix_xsize, info->matrix_ysize, | ||
843 | info->object_num); | ||
844 | |||
845 | return 0; | ||
846 | } | ||
847 | |||
848 | static ssize_t mxt_object_show(struct device *dev, | ||
849 | struct device_attribute *attr, char *buf) | ||
850 | { | ||
851 | struct mxt_data *data = dev_get_drvdata(dev); | ||
852 | struct mxt_object *object; | ||
853 | int count = 0; | ||
854 | int i, j; | ||
855 | int error; | ||
856 | u8 val; | ||
857 | |||
858 | for (i = 0; i < data->info.object_num; i++) { | ||
859 | object = data->object_table + i; | ||
860 | |||
861 | count += sprintf(buf + count, | ||
862 | "Object Table Element %d(Type %d)\n", | ||
863 | i + 1, object->type); | ||
864 | |||
865 | if (!mxt_object_readable(object->type)) { | ||
866 | count += sprintf(buf + count, "\n"); | ||
867 | continue; | ||
868 | } | ||
869 | |||
870 | for (j = 0; j < object->size + 1; j++) { | ||
871 | error = mxt_read_object(data, | ||
872 | object->type, j, &val); | ||
873 | if (error) | ||
874 | return error; | ||
875 | |||
876 | count += sprintf(buf + count, | ||
877 | " Byte %d: 0x%x (%d)\n", j, val, val); | ||
878 | } | ||
879 | |||
880 | count += sprintf(buf + count, "\n"); | ||
881 | } | ||
882 | |||
883 | return count; | ||
884 | } | ||
885 | |||
886 | static int mxt_load_fw(struct device *dev, const char *fn) | ||
887 | { | ||
888 | struct mxt_data *data = dev_get_drvdata(dev); | ||
889 | struct i2c_client *client = data->client; | ||
890 | const struct firmware *fw = NULL; | ||
891 | unsigned int frame_size; | ||
892 | unsigned int pos = 0; | ||
893 | int ret; | ||
894 | |||
895 | ret = request_firmware(&fw, fn, dev); | ||
896 | if (ret) { | ||
897 | dev_err(dev, "Unable to open firmware %s\n", fn); | ||
898 | return ret; | ||
899 | } | ||
900 | |||
901 | /* Change to the bootloader mode */ | ||
902 | mxt_write_object(data, MXT_GEN_COMMAND, | ||
903 | MXT_COMMAND_RESET, MXT_BOOT_VALUE); | ||
904 | msleep(MXT_RESET_TIME); | ||
905 | |||
906 | /* Change to slave address of bootloader */ | ||
907 | if (client->addr == MXT_APP_LOW) | ||
908 | client->addr = MXT_BOOT_LOW; | ||
909 | else | ||
910 | client->addr = MXT_BOOT_HIGH; | ||
911 | |||
912 | ret = mxt_check_bootloader(client, MXT_WAITING_BOOTLOAD_CMD); | ||
913 | if (ret) | ||
914 | goto out; | ||
915 | |||
916 | /* Unlock bootloader */ | ||
917 | mxt_unlock_bootloader(client); | ||
918 | |||
919 | while (pos < fw->size) { | ||
920 | ret = mxt_check_bootloader(client, | ||
921 | MXT_WAITING_FRAME_DATA); | ||
922 | if (ret) | ||
923 | goto out; | ||
924 | |||
925 | frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); | ||
926 | |||
927 | /* We should add 2 at frame size as the the firmware data is not | ||
928 | * included the CRC bytes. | ||
929 | */ | ||
930 | frame_size += 2; | ||
931 | |||
932 | /* Write one frame to device */ | ||
933 | mxt_fw_write(client, fw->data + pos, frame_size); | ||
934 | |||
935 | ret = mxt_check_bootloader(client, | ||
936 | MXT_FRAME_CRC_PASS); | ||
937 | if (ret) | ||
938 | goto out; | ||
939 | |||
940 | pos += frame_size; | ||
941 | |||
942 | dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size); | ||
943 | } | ||
944 | |||
945 | out: | ||
946 | release_firmware(fw); | ||
947 | |||
948 | /* Change to slave address of application */ | ||
949 | if (client->addr == MXT_BOOT_LOW) | ||
950 | client->addr = MXT_APP_LOW; | ||
951 | else | ||
952 | client->addr = MXT_APP_HIGH; | ||
953 | |||
954 | return ret; | ||
955 | } | ||
956 | |||
957 | static ssize_t mxt_update_fw_store(struct device *dev, | ||
958 | struct device_attribute *attr, | ||
959 | const char *buf, size_t count) | ||
960 | { | ||
961 | struct mxt_data *data = dev_get_drvdata(dev); | ||
962 | int error; | ||
963 | |||
964 | disable_irq(data->irq); | ||
965 | |||
966 | error = mxt_load_fw(dev, MXT_FW_NAME); | ||
967 | if (error) { | ||
968 | dev_err(dev, "The firmware update failed(%d)\n", error); | ||
969 | count = error; | ||
970 | } else { | ||
971 | dev_dbg(dev, "The firmware update succeeded\n"); | ||
972 | |||
973 | /* Wait for reset */ | ||
974 | msleep(MXT_FWRESET_TIME); | ||
975 | |||
976 | kfree(data->object_table); | ||
977 | data->object_table = NULL; | ||
978 | |||
979 | mxt_initialize(data); | ||
980 | } | ||
981 | |||
982 | enable_irq(data->irq); | ||
983 | |||
984 | return count; | ||
985 | } | ||
986 | |||
987 | static DEVICE_ATTR(object, 0444, mxt_object_show, NULL); | ||
988 | static DEVICE_ATTR(update_fw, 0664, NULL, mxt_update_fw_store); | ||
989 | |||
990 | static struct attribute *mxt_attrs[] = { | ||
991 | &dev_attr_object.attr, | ||
992 | &dev_attr_update_fw.attr, | ||
993 | NULL | ||
994 | }; | ||
995 | |||
996 | static const struct attribute_group mxt_attr_group = { | ||
997 | .attrs = mxt_attrs, | ||
998 | }; | ||
999 | |||
1000 | static void mxt_start(struct mxt_data *data) | ||
1001 | { | ||
1002 | /* Touch enable */ | ||
1003 | mxt_write_object(data, | ||
1004 | MXT_TOUCH_MULTI, MXT_TOUCH_CTRL, 0x83); | ||
1005 | } | ||
1006 | |||
1007 | static void mxt_stop(struct mxt_data *data) | ||
1008 | { | ||
1009 | /* Touch disable */ | ||
1010 | mxt_write_object(data, | ||
1011 | MXT_TOUCH_MULTI, MXT_TOUCH_CTRL, 0); | ||
1012 | } | ||
1013 | |||
1014 | static int mxt_input_open(struct input_dev *dev) | ||
1015 | { | ||
1016 | struct mxt_data *data = input_get_drvdata(dev); | ||
1017 | |||
1018 | mxt_start(data); | ||
1019 | |||
1020 | return 0; | ||
1021 | } | ||
1022 | |||
1023 | static void mxt_input_close(struct input_dev *dev) | ||
1024 | { | ||
1025 | struct mxt_data *data = input_get_drvdata(dev); | ||
1026 | |||
1027 | mxt_stop(data); | ||
1028 | } | ||
1029 | |||
1030 | static int __devinit mxt_probe(struct i2c_client *client, | ||
1031 | const struct i2c_device_id *id) | ||
1032 | { | ||
1033 | const struct mxt_platform_data *pdata = client->dev.platform_data; | ||
1034 | struct mxt_data *data; | ||
1035 | struct input_dev *input_dev; | ||
1036 | int error; | ||
1037 | |||
1038 | if (!pdata) | ||
1039 | return -EINVAL; | ||
1040 | |||
1041 | data = kzalloc(sizeof(struct mxt_data), GFP_KERNEL); | ||
1042 | input_dev = input_allocate_device(); | ||
1043 | if (!data || !input_dev) { | ||
1044 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
1045 | error = -ENOMEM; | ||
1046 | goto err_free_mem; | ||
1047 | } | ||
1048 | |||
1049 | input_dev->name = "Atmel maXTouch Touchscreen"; | ||
1050 | input_dev->id.bustype = BUS_I2C; | ||
1051 | input_dev->dev.parent = &client->dev; | ||
1052 | input_dev->open = mxt_input_open; | ||
1053 | input_dev->close = mxt_input_close; | ||
1054 | |||
1055 | __set_bit(EV_ABS, input_dev->evbit); | ||
1056 | __set_bit(EV_KEY, input_dev->evbit); | ||
1057 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
1058 | |||
1059 | /* For single touch */ | ||
1060 | input_set_abs_params(input_dev, ABS_X, | ||
1061 | 0, MXT_MAX_XC, 0, 0); | ||
1062 | input_set_abs_params(input_dev, ABS_Y, | ||
1063 | 0, MXT_MAX_YC, 0, 0); | ||
1064 | |||
1065 | /* For multi touch */ | ||
1066 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | ||
1067 | 0, MXT_MAX_AREA, 0, 0); | ||
1068 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | ||
1069 | 0, MXT_MAX_XC, 0, 0); | ||
1070 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | ||
1071 | 0, MXT_MAX_YC, 0, 0); | ||
1072 | |||
1073 | input_set_drvdata(input_dev, data); | ||
1074 | |||
1075 | data->client = client; | ||
1076 | data->input_dev = input_dev; | ||
1077 | data->pdata = pdata; | ||
1078 | data->irq = client->irq; | ||
1079 | |||
1080 | i2c_set_clientdata(client, data); | ||
1081 | |||
1082 | error = mxt_initialize(data); | ||
1083 | if (error) | ||
1084 | goto err_free_object; | ||
1085 | |||
1086 | error = request_threaded_irq(client->irq, NULL, mxt_interrupt, | ||
1087 | pdata->irqflags, client->dev.driver->name, data); | ||
1088 | if (error) { | ||
1089 | dev_err(&client->dev, "Failed to register interrupt\n"); | ||
1090 | goto err_free_object; | ||
1091 | } | ||
1092 | |||
1093 | error = input_register_device(input_dev); | ||
1094 | if (error) | ||
1095 | goto err_free_irq; | ||
1096 | |||
1097 | error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); | ||
1098 | if (error) | ||
1099 | goto err_unregister_device; | ||
1100 | |||
1101 | return 0; | ||
1102 | |||
1103 | err_unregister_device: | ||
1104 | input_unregister_device(input_dev); | ||
1105 | input_dev = NULL; | ||
1106 | err_free_irq: | ||
1107 | free_irq(client->irq, data); | ||
1108 | err_free_object: | ||
1109 | kfree(data->object_table); | ||
1110 | err_free_mem: | ||
1111 | input_free_device(input_dev); | ||
1112 | kfree(data); | ||
1113 | return error; | ||
1114 | } | ||
1115 | |||
1116 | static int __devexit mxt_remove(struct i2c_client *client) | ||
1117 | { | ||
1118 | struct mxt_data *data = i2c_get_clientdata(client); | ||
1119 | |||
1120 | sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); | ||
1121 | free_irq(data->irq, data); | ||
1122 | input_unregister_device(data->input_dev); | ||
1123 | kfree(data->object_table); | ||
1124 | kfree(data); | ||
1125 | |||
1126 | return 0; | ||
1127 | } | ||
1128 | |||
1129 | #ifdef CONFIG_PM | ||
1130 | static int mxt_suspend(struct device *dev) | ||
1131 | { | ||
1132 | struct i2c_client *client = to_i2c_client(dev); | ||
1133 | struct mxt_data *data = i2c_get_clientdata(client); | ||
1134 | struct input_dev *input_dev = data->input_dev; | ||
1135 | |||
1136 | mutex_lock(&input_dev->mutex); | ||
1137 | |||
1138 | if (input_dev->users) | ||
1139 | mxt_stop(data); | ||
1140 | |||
1141 | mutex_unlock(&input_dev->mutex); | ||
1142 | |||
1143 | return 0; | ||
1144 | } | ||
1145 | |||
1146 | static int mxt_resume(struct device *dev) | ||
1147 | { | ||
1148 | struct i2c_client *client = to_i2c_client(dev); | ||
1149 | struct mxt_data *data = i2c_get_clientdata(client); | ||
1150 | struct input_dev *input_dev = data->input_dev; | ||
1151 | |||
1152 | /* Soft reset */ | ||
1153 | mxt_write_object(data, MXT_GEN_COMMAND, | ||
1154 | MXT_COMMAND_RESET, 1); | ||
1155 | |||
1156 | msleep(MXT_RESET_TIME); | ||
1157 | |||
1158 | mutex_lock(&input_dev->mutex); | ||
1159 | |||
1160 | if (input_dev->users) | ||
1161 | mxt_start(data); | ||
1162 | |||
1163 | mutex_unlock(&input_dev->mutex); | ||
1164 | |||
1165 | return 0; | ||
1166 | } | ||
1167 | |||
1168 | static const struct dev_pm_ops mxt_pm_ops = { | ||
1169 | .suspend = mxt_suspend, | ||
1170 | .resume = mxt_resume, | ||
1171 | }; | ||
1172 | #endif | ||
1173 | |||
1174 | static const struct i2c_device_id mxt_id[] = { | ||
1175 | { "qt602240_ts", 0 }, | ||
1176 | { "atmel_mxt_ts", 0 }, | ||
1177 | { "mXT224", 0 }, | ||
1178 | { } | ||
1179 | }; | ||
1180 | MODULE_DEVICE_TABLE(i2c, mxt_id); | ||
1181 | |||
1182 | static struct i2c_driver mxt_driver = { | ||
1183 | .driver = { | ||
1184 | .name = "atmel_mxt_ts", | ||
1185 | .owner = THIS_MODULE, | ||
1186 | #ifdef CONFIG_PM | ||
1187 | .pm = &mxt_pm_ops, | ||
1188 | #endif | ||
1189 | }, | ||
1190 | .probe = mxt_probe, | ||
1191 | .remove = __devexit_p(mxt_remove), | ||
1192 | .id_table = mxt_id, | ||
1193 | }; | ||
1194 | |||
1195 | static int __init mxt_init(void) | ||
1196 | { | ||
1197 | return i2c_add_driver(&mxt_driver); | ||
1198 | } | ||
1199 | |||
1200 | static void __exit mxt_exit(void) | ||
1201 | { | ||
1202 | i2c_del_driver(&mxt_driver); | ||
1203 | } | ||
1204 | |||
1205 | module_init(mxt_init); | ||
1206 | module_exit(mxt_exit); | ||
1207 | |||
1208 | /* Module information */ | ||
1209 | MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); | ||
1210 | MODULE_DESCRIPTION("Atmel maXTouch Touchscreen driver"); | ||
1211 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/qt602240_ts.c b/drivers/input/touchscreen/qt602240_ts.c deleted file mode 100644 index 4dcb0e872f6a..000000000000 --- a/drivers/input/touchscreen/qt602240_ts.c +++ /dev/null | |||
@@ -1,1406 +0,0 @@ | |||
1 | /* | ||
2 | * AT42QT602240/ATMXT224 Touchscreen driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Samsung Electronics Co.Ltd | ||
5 | * Author: Joonyoung Shim <jy0922.shim@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/firmware.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/i2c/qt602240_ts.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/slab.h> | ||
23 | |||
24 | /* Version */ | ||
25 | #define QT602240_VER_20 20 | ||
26 | #define QT602240_VER_21 21 | ||
27 | #define QT602240_VER_22 22 | ||
28 | |||
29 | /* Slave addresses */ | ||
30 | #define QT602240_APP_LOW 0x4a | ||
31 | #define QT602240_APP_HIGH 0x4b | ||
32 | #define QT602240_BOOT_LOW 0x24 | ||
33 | #define QT602240_BOOT_HIGH 0x25 | ||
34 | |||
35 | /* Firmware */ | ||
36 | #define QT602240_FW_NAME "qt602240.fw" | ||
37 | |||
38 | /* Registers */ | ||
39 | #define QT602240_FAMILY_ID 0x00 | ||
40 | #define QT602240_VARIANT_ID 0x01 | ||
41 | #define QT602240_VERSION 0x02 | ||
42 | #define QT602240_BUILD 0x03 | ||
43 | #define QT602240_MATRIX_X_SIZE 0x04 | ||
44 | #define QT602240_MATRIX_Y_SIZE 0x05 | ||
45 | #define QT602240_OBJECT_NUM 0x06 | ||
46 | #define QT602240_OBJECT_START 0x07 | ||
47 | |||
48 | #define QT602240_OBJECT_SIZE 6 | ||
49 | |||
50 | /* Object types */ | ||
51 | #define QT602240_DEBUG_DIAGNOSTIC 37 | ||
52 | #define QT602240_GEN_MESSAGE 5 | ||
53 | #define QT602240_GEN_COMMAND 6 | ||
54 | #define QT602240_GEN_POWER 7 | ||
55 | #define QT602240_GEN_ACQUIRE 8 | ||
56 | #define QT602240_TOUCH_MULTI 9 | ||
57 | #define QT602240_TOUCH_KEYARRAY 15 | ||
58 | #define QT602240_TOUCH_PROXIMITY 23 | ||
59 | #define QT602240_PROCI_GRIPFACE 20 | ||
60 | #define QT602240_PROCG_NOISE 22 | ||
61 | #define QT602240_PROCI_ONETOUCH 24 | ||
62 | #define QT602240_PROCI_TWOTOUCH 27 | ||
63 | #define QT602240_SPT_COMMSCONFIG 18 /* firmware ver 21 over */ | ||
64 | #define QT602240_SPT_GPIOPWM 19 | ||
65 | #define QT602240_SPT_SELFTEST 25 | ||
66 | #define QT602240_SPT_CTECONFIG 28 | ||
67 | #define QT602240_SPT_USERDATA 38 /* firmware ver 21 over */ | ||
68 | |||
69 | /* QT602240_GEN_COMMAND field */ | ||
70 | #define QT602240_COMMAND_RESET 0 | ||
71 | #define QT602240_COMMAND_BACKUPNV 1 | ||
72 | #define QT602240_COMMAND_CALIBRATE 2 | ||
73 | #define QT602240_COMMAND_REPORTALL 3 | ||
74 | #define QT602240_COMMAND_DIAGNOSTIC 5 | ||
75 | |||
76 | /* QT602240_GEN_POWER field */ | ||
77 | #define QT602240_POWER_IDLEACQINT 0 | ||
78 | #define QT602240_POWER_ACTVACQINT 1 | ||
79 | #define QT602240_POWER_ACTV2IDLETO 2 | ||
80 | |||
81 | /* QT602240_GEN_ACQUIRE field */ | ||
82 | #define QT602240_ACQUIRE_CHRGTIME 0 | ||
83 | #define QT602240_ACQUIRE_TCHDRIFT 2 | ||
84 | #define QT602240_ACQUIRE_DRIFTST 3 | ||
85 | #define QT602240_ACQUIRE_TCHAUTOCAL 4 | ||
86 | #define QT602240_ACQUIRE_SYNC 5 | ||
87 | #define QT602240_ACQUIRE_ATCHCALST 6 | ||
88 | #define QT602240_ACQUIRE_ATCHCALSTHR 7 | ||
89 | |||
90 | /* QT602240_TOUCH_MULTI field */ | ||
91 | #define QT602240_TOUCH_CTRL 0 | ||
92 | #define QT602240_TOUCH_XORIGIN 1 | ||
93 | #define QT602240_TOUCH_YORIGIN 2 | ||
94 | #define QT602240_TOUCH_XSIZE 3 | ||
95 | #define QT602240_TOUCH_YSIZE 4 | ||
96 | #define QT602240_TOUCH_BLEN 6 | ||
97 | #define QT602240_TOUCH_TCHTHR 7 | ||
98 | #define QT602240_TOUCH_TCHDI 8 | ||
99 | #define QT602240_TOUCH_ORIENT 9 | ||
100 | #define QT602240_TOUCH_MOVHYSTI 11 | ||
101 | #define QT602240_TOUCH_MOVHYSTN 12 | ||
102 | #define QT602240_TOUCH_NUMTOUCH 14 | ||
103 | #define QT602240_TOUCH_MRGHYST 15 | ||
104 | #define QT602240_TOUCH_MRGTHR 16 | ||
105 | #define QT602240_TOUCH_AMPHYST 17 | ||
106 | #define QT602240_TOUCH_XRANGE_LSB 18 | ||
107 | #define QT602240_TOUCH_XRANGE_MSB 19 | ||
108 | #define QT602240_TOUCH_YRANGE_LSB 20 | ||
109 | #define QT602240_TOUCH_YRANGE_MSB 21 | ||
110 | #define QT602240_TOUCH_XLOCLIP 22 | ||
111 | #define QT602240_TOUCH_XHICLIP 23 | ||
112 | #define QT602240_TOUCH_YLOCLIP 24 | ||
113 | #define QT602240_TOUCH_YHICLIP 25 | ||
114 | #define QT602240_TOUCH_XEDGECTRL 26 | ||
115 | #define QT602240_TOUCH_XEDGEDIST 27 | ||
116 | #define QT602240_TOUCH_YEDGECTRL 28 | ||
117 | #define QT602240_TOUCH_YEDGEDIST 29 | ||
118 | #define QT602240_TOUCH_JUMPLIMIT 30 /* firmware ver 22 over */ | ||
119 | |||
120 | /* QT602240_PROCI_GRIPFACE field */ | ||
121 | #define QT602240_GRIPFACE_CTRL 0 | ||
122 | #define QT602240_GRIPFACE_XLOGRIP 1 | ||
123 | #define QT602240_GRIPFACE_XHIGRIP 2 | ||
124 | #define QT602240_GRIPFACE_YLOGRIP 3 | ||
125 | #define QT602240_GRIPFACE_YHIGRIP 4 | ||
126 | #define QT602240_GRIPFACE_MAXTCHS 5 | ||
127 | #define QT602240_GRIPFACE_SZTHR1 7 | ||
128 | #define QT602240_GRIPFACE_SZTHR2 8 | ||
129 | #define QT602240_GRIPFACE_SHPTHR1 9 | ||
130 | #define QT602240_GRIPFACE_SHPTHR2 10 | ||
131 | #define QT602240_GRIPFACE_SUPEXTTO 11 | ||
132 | |||
133 | /* QT602240_PROCI_NOISE field */ | ||
134 | #define QT602240_NOISE_CTRL 0 | ||
135 | #define QT602240_NOISE_OUTFLEN 1 | ||
136 | #define QT602240_NOISE_GCAFUL_LSB 3 | ||
137 | #define QT602240_NOISE_GCAFUL_MSB 4 | ||
138 | #define QT602240_NOISE_GCAFLL_LSB 5 | ||
139 | #define QT602240_NOISE_GCAFLL_MSB 6 | ||
140 | #define QT602240_NOISE_ACTVGCAFVALID 7 | ||
141 | #define QT602240_NOISE_NOISETHR 8 | ||
142 | #define QT602240_NOISE_FREQHOPSCALE 10 | ||
143 | #define QT602240_NOISE_FREQ0 11 | ||
144 | #define QT602240_NOISE_FREQ1 12 | ||
145 | #define QT602240_NOISE_FREQ2 13 | ||
146 | #define QT602240_NOISE_FREQ3 14 | ||
147 | #define QT602240_NOISE_FREQ4 15 | ||
148 | #define QT602240_NOISE_IDLEGCAFVALID 16 | ||
149 | |||
150 | /* QT602240_SPT_COMMSCONFIG */ | ||
151 | #define QT602240_COMMS_CTRL 0 | ||
152 | #define QT602240_COMMS_CMD 1 | ||
153 | |||
154 | /* QT602240_SPT_CTECONFIG field */ | ||
155 | #define QT602240_CTE_CTRL 0 | ||
156 | #define QT602240_CTE_CMD 1 | ||
157 | #define QT602240_CTE_MODE 2 | ||
158 | #define QT602240_CTE_IDLEGCAFDEPTH 3 | ||
159 | #define QT602240_CTE_ACTVGCAFDEPTH 4 | ||
160 | #define QT602240_CTE_VOLTAGE 5 /* firmware ver 21 over */ | ||
161 | |||
162 | #define QT602240_VOLTAGE_DEFAULT 2700000 | ||
163 | #define QT602240_VOLTAGE_STEP 10000 | ||
164 | |||
165 | /* Define for QT602240_GEN_COMMAND */ | ||
166 | #define QT602240_BOOT_VALUE 0xa5 | ||
167 | #define QT602240_BACKUP_VALUE 0x55 | ||
168 | #define QT602240_BACKUP_TIME 25 /* msec */ | ||
169 | #define QT602240_RESET_TIME 65 /* msec */ | ||
170 | |||
171 | #define QT602240_FWRESET_TIME 175 /* msec */ | ||
172 | |||
173 | /* Command to unlock bootloader */ | ||
174 | #define QT602240_UNLOCK_CMD_MSB 0xaa | ||
175 | #define QT602240_UNLOCK_CMD_LSB 0xdc | ||
176 | |||
177 | /* Bootloader mode status */ | ||
178 | #define QT602240_WAITING_BOOTLOAD_CMD 0xc0 /* valid 7 6 bit only */ | ||
179 | #define QT602240_WAITING_FRAME_DATA 0x80 /* valid 7 6 bit only */ | ||
180 | #define QT602240_FRAME_CRC_CHECK 0x02 | ||
181 | #define QT602240_FRAME_CRC_FAIL 0x03 | ||
182 | #define QT602240_FRAME_CRC_PASS 0x04 | ||
183 | #define QT602240_APP_CRC_FAIL 0x40 /* valid 7 8 bit only */ | ||
184 | #define QT602240_BOOT_STATUS_MASK 0x3f | ||
185 | |||
186 | /* Touch status */ | ||
187 | #define QT602240_SUPPRESS (1 << 1) | ||
188 | #define QT602240_AMP (1 << 2) | ||
189 | #define QT602240_VECTOR (1 << 3) | ||
190 | #define QT602240_MOVE (1 << 4) | ||
191 | #define QT602240_RELEASE (1 << 5) | ||
192 | #define QT602240_PRESS (1 << 6) | ||
193 | #define QT602240_DETECT (1 << 7) | ||
194 | |||
195 | /* Touchscreen absolute values */ | ||
196 | #define QT602240_MAX_XC 0x3ff | ||
197 | #define QT602240_MAX_YC 0x3ff | ||
198 | #define QT602240_MAX_AREA 0xff | ||
199 | |||
200 | #define QT602240_MAX_FINGER 10 | ||
201 | |||
202 | /* Initial register values recommended from chip vendor */ | ||
203 | static const u8 init_vals_ver_20[] = { | ||
204 | /* QT602240_GEN_COMMAND(6) */ | ||
205 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
206 | /* QT602240_GEN_POWER(7) */ | ||
207 | 0x20, 0xff, 0x32, | ||
208 | /* QT602240_GEN_ACQUIRE(8) */ | ||
209 | 0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14, | ||
210 | /* QT602240_TOUCH_MULTI(9) */ | ||
211 | 0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
212 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
213 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64, | ||
214 | /* QT602240_TOUCH_KEYARRAY(15) */ | ||
215 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
216 | 0x00, | ||
217 | /* QT602240_SPT_GPIOPWM(19) */ | ||
218 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
219 | 0x00, 0x00, | ||
220 | /* QT602240_PROCI_GRIPFACE(20) */ | ||
221 | 0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04, | ||
222 | 0x1e, 0x00, | ||
223 | /* QT602240_PROCG_NOISE(22) */ | ||
224 | 0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00, | ||
225 | 0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8, | ||
226 | /* QT602240_TOUCH_PROXIMITY(23) */ | ||
227 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
228 | 0x00, 0x00, 0x00, | ||
229 | /* QT602240_PROCI_ONETOUCH(24) */ | ||
230 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
231 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
232 | /* QT602240_SPT_SELFTEST(25) */ | ||
233 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
234 | 0x00, 0x00, 0x00, 0x00, | ||
235 | /* QT602240_PROCI_TWOTOUCH(27) */ | ||
236 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
237 | /* QT602240_SPT_CTECONFIG(28) */ | ||
238 | 0x00, 0x00, 0x00, 0x04, 0x08, | ||
239 | }; | ||
240 | |||
241 | static const u8 init_vals_ver_21[] = { | ||
242 | /* QT602240_GEN_COMMAND(6) */ | ||
243 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
244 | /* QT602240_GEN_POWER(7) */ | ||
245 | 0x20, 0xff, 0x32, | ||
246 | /* QT602240_GEN_ACQUIRE(8) */ | ||
247 | 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, | ||
248 | /* QT602240_TOUCH_MULTI(9) */ | ||
249 | 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
250 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
251 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
252 | /* QT602240_TOUCH_KEYARRAY(15) */ | ||
253 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
254 | 0x00, | ||
255 | /* QT602240_SPT_GPIOPWM(19) */ | ||
256 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
257 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
258 | /* QT602240_PROCI_GRIPFACE(20) */ | ||
259 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, | ||
260 | 0x0f, 0x0a, | ||
261 | /* QT602240_PROCG_NOISE(22) */ | ||
262 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, | ||
263 | 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, | ||
264 | /* QT602240_TOUCH_PROXIMITY(23) */ | ||
265 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
266 | 0x00, 0x00, 0x00, | ||
267 | /* QT602240_PROCI_ONETOUCH(24) */ | ||
268 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
269 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
270 | /* QT602240_SPT_SELFTEST(25) */ | ||
271 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
272 | 0x00, 0x00, 0x00, 0x00, | ||
273 | /* QT602240_PROCI_TWOTOUCH(27) */ | ||
274 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
275 | /* QT602240_SPT_CTECONFIG(28) */ | ||
276 | 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, | ||
277 | }; | ||
278 | |||
279 | static const u8 init_vals_ver_22[] = { | ||
280 | /* QT602240_GEN_COMMAND(6) */ | ||
281 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
282 | /* QT602240_GEN_POWER(7) */ | ||
283 | 0x20, 0xff, 0x32, | ||
284 | /* QT602240_GEN_ACQUIRE(8) */ | ||
285 | 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23, | ||
286 | /* QT602240_TOUCH_MULTI(9) */ | ||
287 | 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, | ||
288 | 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, | ||
289 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
290 | 0x00, | ||
291 | /* QT602240_TOUCH_KEYARRAY(15) */ | ||
292 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
293 | 0x00, | ||
294 | /* QT602240_SPT_GPIOPWM(19) */ | ||
295 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
296 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
297 | /* QT602240_PROCI_GRIPFACE(20) */ | ||
298 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04, | ||
299 | 0x0f, 0x0a, | ||
300 | /* QT602240_PROCG_NOISE(22) */ | ||
301 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00, | ||
302 | 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03, | ||
303 | /* QT602240_TOUCH_PROXIMITY(23) */ | ||
304 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
305 | 0x00, 0x00, 0x00, 0x00, 0x00, | ||
306 | /* QT602240_PROCI_ONETOUCH(24) */ | ||
307 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
308 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
309 | /* QT602240_SPT_SELFTEST(25) */ | ||
310 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
311 | 0x00, 0x00, 0x00, 0x00, | ||
312 | /* QT602240_PROCI_TWOTOUCH(27) */ | ||
313 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
314 | /* QT602240_SPT_CTECONFIG(28) */ | ||
315 | 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, | ||
316 | }; | ||
317 | |||
318 | struct qt602240_info { | ||
319 | u8 family_id; | ||
320 | u8 variant_id; | ||
321 | u8 version; | ||
322 | u8 build; | ||
323 | u8 matrix_xsize; | ||
324 | u8 matrix_ysize; | ||
325 | u8 object_num; | ||
326 | }; | ||
327 | |||
328 | struct qt602240_object { | ||
329 | u8 type; | ||
330 | u16 start_address; | ||
331 | u8 size; | ||
332 | u8 instances; | ||
333 | u8 num_report_ids; | ||
334 | |||
335 | /* to map object and message */ | ||
336 | u8 max_reportid; | ||
337 | }; | ||
338 | |||
339 | struct qt602240_message { | ||
340 | u8 reportid; | ||
341 | u8 message[7]; | ||
342 | u8 checksum; | ||
343 | }; | ||
344 | |||
345 | struct qt602240_finger { | ||
346 | int status; | ||
347 | int x; | ||
348 | int y; | ||
349 | int area; | ||
350 | }; | ||
351 | |||
352 | /* Each client has this additional data */ | ||
353 | struct qt602240_data { | ||
354 | struct i2c_client *client; | ||
355 | struct input_dev *input_dev; | ||
356 | const struct qt602240_platform_data *pdata; | ||
357 | struct qt602240_object *object_table; | ||
358 | struct qt602240_info info; | ||
359 | struct qt602240_finger finger[QT602240_MAX_FINGER]; | ||
360 | unsigned int irq; | ||
361 | }; | ||
362 | |||
363 | static bool qt602240_object_readable(unsigned int type) | ||
364 | { | ||
365 | switch (type) { | ||
366 | case QT602240_GEN_MESSAGE: | ||
367 | case QT602240_GEN_COMMAND: | ||
368 | case QT602240_GEN_POWER: | ||
369 | case QT602240_GEN_ACQUIRE: | ||
370 | case QT602240_TOUCH_MULTI: | ||
371 | case QT602240_TOUCH_KEYARRAY: | ||
372 | case QT602240_TOUCH_PROXIMITY: | ||
373 | case QT602240_PROCI_GRIPFACE: | ||
374 | case QT602240_PROCG_NOISE: | ||
375 | case QT602240_PROCI_ONETOUCH: | ||
376 | case QT602240_PROCI_TWOTOUCH: | ||
377 | case QT602240_SPT_COMMSCONFIG: | ||
378 | case QT602240_SPT_GPIOPWM: | ||
379 | case QT602240_SPT_SELFTEST: | ||
380 | case QT602240_SPT_CTECONFIG: | ||
381 | case QT602240_SPT_USERDATA: | ||
382 | return true; | ||
383 | default: | ||
384 | return false; | ||
385 | } | ||
386 | } | ||
387 | |||
388 | static bool qt602240_object_writable(unsigned int type) | ||
389 | { | ||
390 | switch (type) { | ||
391 | case QT602240_GEN_COMMAND: | ||
392 | case QT602240_GEN_POWER: | ||
393 | case QT602240_GEN_ACQUIRE: | ||
394 | case QT602240_TOUCH_MULTI: | ||
395 | case QT602240_TOUCH_KEYARRAY: | ||
396 | case QT602240_TOUCH_PROXIMITY: | ||
397 | case QT602240_PROCI_GRIPFACE: | ||
398 | case QT602240_PROCG_NOISE: | ||
399 | case QT602240_PROCI_ONETOUCH: | ||
400 | case QT602240_PROCI_TWOTOUCH: | ||
401 | case QT602240_SPT_GPIOPWM: | ||
402 | case QT602240_SPT_SELFTEST: | ||
403 | case QT602240_SPT_CTECONFIG: | ||
404 | return true; | ||
405 | default: | ||
406 | return false; | ||
407 | } | ||
408 | } | ||
409 | |||
410 | static void qt602240_dump_message(struct device *dev, | ||
411 | struct qt602240_message *message) | ||
412 | { | ||
413 | dev_dbg(dev, "reportid:\t0x%x\n", message->reportid); | ||
414 | dev_dbg(dev, "message1:\t0x%x\n", message->message[0]); | ||
415 | dev_dbg(dev, "message2:\t0x%x\n", message->message[1]); | ||
416 | dev_dbg(dev, "message3:\t0x%x\n", message->message[2]); | ||
417 | dev_dbg(dev, "message4:\t0x%x\n", message->message[3]); | ||
418 | dev_dbg(dev, "message5:\t0x%x\n", message->message[4]); | ||
419 | dev_dbg(dev, "message6:\t0x%x\n", message->message[5]); | ||
420 | dev_dbg(dev, "message7:\t0x%x\n", message->message[6]); | ||
421 | dev_dbg(dev, "checksum:\t0x%x\n", message->checksum); | ||
422 | } | ||
423 | |||
424 | static int qt602240_check_bootloader(struct i2c_client *client, | ||
425 | unsigned int state) | ||
426 | { | ||
427 | u8 val; | ||
428 | |||
429 | recheck: | ||
430 | if (i2c_master_recv(client, &val, 1) != 1) { | ||
431 | dev_err(&client->dev, "%s: i2c recv failed\n", __func__); | ||
432 | return -EIO; | ||
433 | } | ||
434 | |||
435 | switch (state) { | ||
436 | case QT602240_WAITING_BOOTLOAD_CMD: | ||
437 | case QT602240_WAITING_FRAME_DATA: | ||
438 | val &= ~QT602240_BOOT_STATUS_MASK; | ||
439 | break; | ||
440 | case QT602240_FRAME_CRC_PASS: | ||
441 | if (val == QT602240_FRAME_CRC_CHECK) | ||
442 | goto recheck; | ||
443 | break; | ||
444 | default: | ||
445 | return -EINVAL; | ||
446 | } | ||
447 | |||
448 | if (val != state) { | ||
449 | dev_err(&client->dev, "Unvalid bootloader mode state\n"); | ||
450 | return -EINVAL; | ||
451 | } | ||
452 | |||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | static int qt602240_unlock_bootloader(struct i2c_client *client) | ||
457 | { | ||
458 | u8 buf[2]; | ||
459 | |||
460 | buf[0] = QT602240_UNLOCK_CMD_LSB; | ||
461 | buf[1] = QT602240_UNLOCK_CMD_MSB; | ||
462 | |||
463 | if (i2c_master_send(client, buf, 2) != 2) { | ||
464 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
465 | return -EIO; | ||
466 | } | ||
467 | |||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | static int qt602240_fw_write(struct i2c_client *client, | ||
472 | const u8 *data, unsigned int frame_size) | ||
473 | { | ||
474 | if (i2c_master_send(client, data, frame_size) != frame_size) { | ||
475 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
476 | return -EIO; | ||
477 | } | ||
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static int __qt602240_read_reg(struct i2c_client *client, | ||
483 | u16 reg, u16 len, void *val) | ||
484 | { | ||
485 | struct i2c_msg xfer[2]; | ||
486 | u8 buf[2]; | ||
487 | |||
488 | buf[0] = reg & 0xff; | ||
489 | buf[1] = (reg >> 8) & 0xff; | ||
490 | |||
491 | /* Write register */ | ||
492 | xfer[0].addr = client->addr; | ||
493 | xfer[0].flags = 0; | ||
494 | xfer[0].len = 2; | ||
495 | xfer[0].buf = buf; | ||
496 | |||
497 | /* Read data */ | ||
498 | xfer[1].addr = client->addr; | ||
499 | xfer[1].flags = I2C_M_RD; | ||
500 | xfer[1].len = len; | ||
501 | xfer[1].buf = val; | ||
502 | |||
503 | if (i2c_transfer(client->adapter, xfer, 2) != 2) { | ||
504 | dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); | ||
505 | return -EIO; | ||
506 | } | ||
507 | |||
508 | return 0; | ||
509 | } | ||
510 | |||
511 | static int qt602240_read_reg(struct i2c_client *client, u16 reg, u8 *val) | ||
512 | { | ||
513 | return __qt602240_read_reg(client, reg, 1, val); | ||
514 | } | ||
515 | |||
516 | static int qt602240_write_reg(struct i2c_client *client, u16 reg, u8 val) | ||
517 | { | ||
518 | u8 buf[3]; | ||
519 | |||
520 | buf[0] = reg & 0xff; | ||
521 | buf[1] = (reg >> 8) & 0xff; | ||
522 | buf[2] = val; | ||
523 | |||
524 | if (i2c_master_send(client, buf, 3) != 3) { | ||
525 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | ||
526 | return -EIO; | ||
527 | } | ||
528 | |||
529 | return 0; | ||
530 | } | ||
531 | |||
532 | static int qt602240_read_object_table(struct i2c_client *client, | ||
533 | u16 reg, u8 *object_buf) | ||
534 | { | ||
535 | return __qt602240_read_reg(client, reg, QT602240_OBJECT_SIZE, | ||
536 | object_buf); | ||
537 | } | ||
538 | |||
539 | static struct qt602240_object * | ||
540 | qt602240_get_object(struct qt602240_data *data, u8 type) | ||
541 | { | ||
542 | struct qt602240_object *object; | ||
543 | int i; | ||
544 | |||
545 | for (i = 0; i < data->info.object_num; i++) { | ||
546 | object = data->object_table + i; | ||
547 | if (object->type == type) | ||
548 | return object; | ||
549 | } | ||
550 | |||
551 | dev_err(&data->client->dev, "Invalid object type\n"); | ||
552 | return NULL; | ||
553 | } | ||
554 | |||
555 | static int qt602240_read_message(struct qt602240_data *data, | ||
556 | struct qt602240_message *message) | ||
557 | { | ||
558 | struct qt602240_object *object; | ||
559 | u16 reg; | ||
560 | |||
561 | object = qt602240_get_object(data, QT602240_GEN_MESSAGE); | ||
562 | if (!object) | ||
563 | return -EINVAL; | ||
564 | |||
565 | reg = object->start_address; | ||
566 | return __qt602240_read_reg(data->client, reg, | ||
567 | sizeof(struct qt602240_message), message); | ||
568 | } | ||
569 | |||
570 | static int qt602240_read_object(struct qt602240_data *data, | ||
571 | u8 type, u8 offset, u8 *val) | ||
572 | { | ||
573 | struct qt602240_object *object; | ||
574 | u16 reg; | ||
575 | |||
576 | object = qt602240_get_object(data, type); | ||
577 | if (!object) | ||
578 | return -EINVAL; | ||
579 | |||
580 | reg = object->start_address; | ||
581 | return __qt602240_read_reg(data->client, reg + offset, 1, val); | ||
582 | } | ||
583 | |||
584 | static int qt602240_write_object(struct qt602240_data *data, | ||
585 | u8 type, u8 offset, u8 val) | ||
586 | { | ||
587 | struct qt602240_object *object; | ||
588 | u16 reg; | ||
589 | |||
590 | object = qt602240_get_object(data, type); | ||
591 | if (!object) | ||
592 | return -EINVAL; | ||
593 | |||
594 | reg = object->start_address; | ||
595 | return qt602240_write_reg(data->client, reg + offset, val); | ||
596 | } | ||
597 | |||
598 | static void qt602240_input_report(struct qt602240_data *data, int single_id) | ||
599 | { | ||
600 | struct qt602240_finger *finger = data->finger; | ||
601 | struct input_dev *input_dev = data->input_dev; | ||
602 | int status = finger[single_id].status; | ||
603 | int finger_num = 0; | ||
604 | int id; | ||
605 | |||
606 | for (id = 0; id < QT602240_MAX_FINGER; id++) { | ||
607 | if (!finger[id].status) | ||
608 | continue; | ||
609 | |||
610 | input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, | ||
611 | finger[id].status != QT602240_RELEASE ? | ||
612 | finger[id].area : 0); | ||
613 | input_report_abs(input_dev, ABS_MT_POSITION_X, | ||
614 | finger[id].x); | ||
615 | input_report_abs(input_dev, ABS_MT_POSITION_Y, | ||
616 | finger[id].y); | ||
617 | input_mt_sync(input_dev); | ||
618 | |||
619 | if (finger[id].status == QT602240_RELEASE) | ||
620 | finger[id].status = 0; | ||
621 | else | ||
622 | finger_num++; | ||
623 | } | ||
624 | |||
625 | input_report_key(input_dev, BTN_TOUCH, finger_num > 0); | ||
626 | |||
627 | if (status != QT602240_RELEASE) { | ||
628 | input_report_abs(input_dev, ABS_X, finger[single_id].x); | ||
629 | input_report_abs(input_dev, ABS_Y, finger[single_id].y); | ||
630 | } | ||
631 | |||
632 | input_sync(input_dev); | ||
633 | } | ||
634 | |||
635 | static void qt602240_input_touchevent(struct qt602240_data *data, | ||
636 | struct qt602240_message *message, int id) | ||
637 | { | ||
638 | struct qt602240_finger *finger = data->finger; | ||
639 | struct device *dev = &data->client->dev; | ||
640 | u8 status = message->message[0]; | ||
641 | int x; | ||
642 | int y; | ||
643 | int area; | ||
644 | |||
645 | /* Check the touch is present on the screen */ | ||
646 | if (!(status & QT602240_DETECT)) { | ||
647 | if (status & QT602240_RELEASE) { | ||
648 | dev_dbg(dev, "[%d] released\n", id); | ||
649 | |||
650 | finger[id].status = QT602240_RELEASE; | ||
651 | qt602240_input_report(data, id); | ||
652 | } | ||
653 | return; | ||
654 | } | ||
655 | |||
656 | /* Check only AMP detection */ | ||
657 | if (!(status & (QT602240_PRESS | QT602240_MOVE))) | ||
658 | return; | ||
659 | |||
660 | x = (message->message[1] << 2) | ((message->message[3] & ~0x3f) >> 6); | ||
661 | y = (message->message[2] << 2) | ((message->message[3] & ~0xf3) >> 2); | ||
662 | area = message->message[4]; | ||
663 | |||
664 | dev_dbg(dev, "[%d] %s x: %d, y: %d, area: %d\n", id, | ||
665 | status & QT602240_MOVE ? "moved" : "pressed", | ||
666 | x, y, area); | ||
667 | |||
668 | finger[id].status = status & QT602240_MOVE ? | ||
669 | QT602240_MOVE : QT602240_PRESS; | ||
670 | finger[id].x = x; | ||
671 | finger[id].y = y; | ||
672 | finger[id].area = area; | ||
673 | |||
674 | qt602240_input_report(data, id); | ||
675 | } | ||
676 | |||
677 | static irqreturn_t qt602240_interrupt(int irq, void *dev_id) | ||
678 | { | ||
679 | struct qt602240_data *data = dev_id; | ||
680 | struct qt602240_message message; | ||
681 | struct qt602240_object *object; | ||
682 | struct device *dev = &data->client->dev; | ||
683 | int id; | ||
684 | u8 reportid; | ||
685 | u8 max_reportid; | ||
686 | u8 min_reportid; | ||
687 | |||
688 | do { | ||
689 | if (qt602240_read_message(data, &message)) { | ||
690 | dev_err(dev, "Failed to read message\n"); | ||
691 | goto end; | ||
692 | } | ||
693 | |||
694 | reportid = message.reportid; | ||
695 | |||
696 | /* whether reportid is thing of QT602240_TOUCH_MULTI */ | ||
697 | object = qt602240_get_object(data, QT602240_TOUCH_MULTI); | ||
698 | if (!object) | ||
699 | goto end; | ||
700 | |||
701 | max_reportid = object->max_reportid; | ||
702 | min_reportid = max_reportid - object->num_report_ids + 1; | ||
703 | id = reportid - min_reportid; | ||
704 | |||
705 | if (reportid >= min_reportid && reportid <= max_reportid) | ||
706 | qt602240_input_touchevent(data, &message, id); | ||
707 | else | ||
708 | qt602240_dump_message(dev, &message); | ||
709 | } while (reportid != 0xff); | ||
710 | |||
711 | end: | ||
712 | return IRQ_HANDLED; | ||
713 | } | ||
714 | |||
715 | static int qt602240_check_reg_init(struct qt602240_data *data) | ||
716 | { | ||
717 | struct qt602240_object *object; | ||
718 | struct device *dev = &data->client->dev; | ||
719 | int index = 0; | ||
720 | int i, j; | ||
721 | u8 version = data->info.version; | ||
722 | u8 *init_vals; | ||
723 | |||
724 | switch (version) { | ||
725 | case QT602240_VER_20: | ||
726 | init_vals = (u8 *)init_vals_ver_20; | ||
727 | break; | ||
728 | case QT602240_VER_21: | ||
729 | init_vals = (u8 *)init_vals_ver_21; | ||
730 | break; | ||
731 | case QT602240_VER_22: | ||
732 | init_vals = (u8 *)init_vals_ver_22; | ||
733 | break; | ||
734 | default: | ||
735 | dev_err(dev, "Firmware version %d doesn't support\n", version); | ||
736 | return -EINVAL; | ||
737 | } | ||
738 | |||
739 | for (i = 0; i < data->info.object_num; i++) { | ||
740 | object = data->object_table + i; | ||
741 | |||
742 | if (!qt602240_object_writable(object->type)) | ||
743 | continue; | ||
744 | |||
745 | for (j = 0; j < object->size + 1; j++) | ||
746 | qt602240_write_object(data, object->type, j, | ||
747 | init_vals[index + j]); | ||
748 | |||
749 | index += object->size + 1; | ||
750 | } | ||
751 | |||
752 | return 0; | ||
753 | } | ||
754 | |||
755 | static int qt602240_check_matrix_size(struct qt602240_data *data) | ||
756 | { | ||
757 | const struct qt602240_platform_data *pdata = data->pdata; | ||
758 | struct device *dev = &data->client->dev; | ||
759 | int mode = -1; | ||
760 | int error; | ||
761 | u8 val; | ||
762 | |||
763 | dev_dbg(dev, "Number of X lines: %d\n", pdata->x_line); | ||
764 | dev_dbg(dev, "Number of Y lines: %d\n", pdata->y_line); | ||
765 | |||
766 | switch (pdata->x_line) { | ||
767 | case 0 ... 15: | ||
768 | if (pdata->y_line <= 14) | ||
769 | mode = 0; | ||
770 | break; | ||
771 | case 16: | ||
772 | if (pdata->y_line <= 12) | ||
773 | mode = 1; | ||
774 | if (pdata->y_line == 13 || pdata->y_line == 14) | ||
775 | mode = 0; | ||
776 | break; | ||
777 | case 17: | ||
778 | if (pdata->y_line <= 11) | ||
779 | mode = 2; | ||
780 | if (pdata->y_line == 12 || pdata->y_line == 13) | ||
781 | mode = 1; | ||
782 | break; | ||
783 | case 18: | ||
784 | if (pdata->y_line <= 10) | ||
785 | mode = 3; | ||
786 | if (pdata->y_line == 11 || pdata->y_line == 12) | ||
787 | mode = 2; | ||
788 | break; | ||
789 | case 19: | ||
790 | if (pdata->y_line <= 9) | ||
791 | mode = 4; | ||
792 | if (pdata->y_line == 10 || pdata->y_line == 11) | ||
793 | mode = 3; | ||
794 | break; | ||
795 | case 20: | ||
796 | mode = 4; | ||
797 | } | ||
798 | |||
799 | if (mode < 0) { | ||
800 | dev_err(dev, "Invalid X/Y lines\n"); | ||
801 | return -EINVAL; | ||
802 | } | ||
803 | |||
804 | error = qt602240_read_object(data, QT602240_SPT_CTECONFIG, | ||
805 | QT602240_CTE_MODE, &val); | ||
806 | if (error) | ||
807 | return error; | ||
808 | |||
809 | if (mode == val) | ||
810 | return 0; | ||
811 | |||
812 | /* Change the CTE configuration */ | ||
813 | qt602240_write_object(data, QT602240_SPT_CTECONFIG, | ||
814 | QT602240_CTE_CTRL, 1); | ||
815 | qt602240_write_object(data, QT602240_SPT_CTECONFIG, | ||
816 | QT602240_CTE_MODE, mode); | ||
817 | qt602240_write_object(data, QT602240_SPT_CTECONFIG, | ||
818 | QT602240_CTE_CTRL, 0); | ||
819 | |||
820 | return 0; | ||
821 | } | ||
822 | |||
823 | static int qt602240_make_highchg(struct qt602240_data *data) | ||
824 | { | ||
825 | struct device *dev = &data->client->dev; | ||
826 | int count = 10; | ||
827 | int error; | ||
828 | u8 val; | ||
829 | |||
830 | /* Read dummy message to make high CHG pin */ | ||
831 | do { | ||
832 | error = qt602240_read_object(data, QT602240_GEN_MESSAGE, 0, &val); | ||
833 | if (error) | ||
834 | return error; | ||
835 | } while ((val != 0xff) && --count); | ||
836 | |||
837 | if (!count) { | ||
838 | dev_err(dev, "CHG pin isn't cleared\n"); | ||
839 | return -EBUSY; | ||
840 | } | ||
841 | |||
842 | return 0; | ||
843 | } | ||
844 | |||
845 | static void qt602240_handle_pdata(struct qt602240_data *data) | ||
846 | { | ||
847 | const struct qt602240_platform_data *pdata = data->pdata; | ||
848 | u8 voltage; | ||
849 | |||
850 | /* Set touchscreen lines */ | ||
851 | qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_XSIZE, | ||
852 | pdata->x_line); | ||
853 | qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_YSIZE, | ||
854 | pdata->y_line); | ||
855 | |||
856 | /* Set touchscreen orient */ | ||
857 | qt602240_write_object(data, QT602240_TOUCH_MULTI, QT602240_TOUCH_ORIENT, | ||
858 | pdata->orient); | ||
859 | |||
860 | /* Set touchscreen burst length */ | ||
861 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
862 | QT602240_TOUCH_BLEN, pdata->blen); | ||
863 | |||
864 | /* Set touchscreen threshold */ | ||
865 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
866 | QT602240_TOUCH_TCHTHR, pdata->threshold); | ||
867 | |||
868 | /* Set touchscreen resolution */ | ||
869 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
870 | QT602240_TOUCH_XRANGE_LSB, (pdata->x_size - 1) & 0xff); | ||
871 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
872 | QT602240_TOUCH_XRANGE_MSB, (pdata->x_size - 1) >> 8); | ||
873 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
874 | QT602240_TOUCH_YRANGE_LSB, (pdata->y_size - 1) & 0xff); | ||
875 | qt602240_write_object(data, QT602240_TOUCH_MULTI, | ||
876 | QT602240_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8); | ||
877 | |||
878 | /* Set touchscreen voltage */ | ||
879 | if (data->info.version >= QT602240_VER_21 && pdata->voltage) { | ||
880 | if (pdata->voltage < QT602240_VOLTAGE_DEFAULT) { | ||
881 | voltage = (QT602240_VOLTAGE_DEFAULT - pdata->voltage) / | ||
882 | QT602240_VOLTAGE_STEP; | ||
883 | voltage = 0xff - voltage + 1; | ||
884 | } else | ||
885 | voltage = (pdata->voltage - QT602240_VOLTAGE_DEFAULT) / | ||
886 | QT602240_VOLTAGE_STEP; | ||
887 | |||
888 | qt602240_write_object(data, QT602240_SPT_CTECONFIG, | ||
889 | QT602240_CTE_VOLTAGE, voltage); | ||
890 | } | ||
891 | } | ||
892 | |||
893 | static int qt602240_get_info(struct qt602240_data *data) | ||
894 | { | ||
895 | struct i2c_client *client = data->client; | ||
896 | struct qt602240_info *info = &data->info; | ||
897 | int error; | ||
898 | u8 val; | ||
899 | |||
900 | error = qt602240_read_reg(client, QT602240_FAMILY_ID, &val); | ||
901 | if (error) | ||
902 | return error; | ||
903 | info->family_id = val; | ||
904 | |||
905 | error = qt602240_read_reg(client, QT602240_VARIANT_ID, &val); | ||
906 | if (error) | ||
907 | return error; | ||
908 | info->variant_id = val; | ||
909 | |||
910 | error = qt602240_read_reg(client, QT602240_VERSION, &val); | ||
911 | if (error) | ||
912 | return error; | ||
913 | info->version = val; | ||
914 | |||
915 | error = qt602240_read_reg(client, QT602240_BUILD, &val); | ||
916 | if (error) | ||
917 | return error; | ||
918 | info->build = val; | ||
919 | |||
920 | error = qt602240_read_reg(client, QT602240_OBJECT_NUM, &val); | ||
921 | if (error) | ||
922 | return error; | ||
923 | info->object_num = val; | ||
924 | |||
925 | return 0; | ||
926 | } | ||
927 | |||
928 | static int qt602240_get_object_table(struct qt602240_data *data) | ||
929 | { | ||
930 | int error; | ||
931 | int i; | ||
932 | u16 reg; | ||
933 | u8 reportid = 0; | ||
934 | u8 buf[QT602240_OBJECT_SIZE]; | ||
935 | |||
936 | for (i = 0; i < data->info.object_num; i++) { | ||
937 | struct qt602240_object *object = data->object_table + i; | ||
938 | |||
939 | reg = QT602240_OBJECT_START + QT602240_OBJECT_SIZE * i; | ||
940 | error = qt602240_read_object_table(data->client, reg, buf); | ||
941 | if (error) | ||
942 | return error; | ||
943 | |||
944 | object->type = buf[0]; | ||
945 | object->start_address = (buf[2] << 8) | buf[1]; | ||
946 | object->size = buf[3]; | ||
947 | object->instances = buf[4]; | ||
948 | object->num_report_ids = buf[5]; | ||
949 | |||
950 | if (object->num_report_ids) { | ||
951 | reportid += object->num_report_ids * | ||
952 | (object->instances + 1); | ||
953 | object->max_reportid = reportid; | ||
954 | } | ||
955 | } | ||
956 | |||
957 | return 0; | ||
958 | } | ||
959 | |||
960 | static int qt602240_initialize(struct qt602240_data *data) | ||
961 | { | ||
962 | struct i2c_client *client = data->client; | ||
963 | struct qt602240_info *info = &data->info; | ||
964 | int error; | ||
965 | u8 val; | ||
966 | |||
967 | error = qt602240_get_info(data); | ||
968 | if (error) | ||
969 | return error; | ||
970 | |||
971 | data->object_table = kcalloc(info->object_num, | ||
972 | sizeof(struct qt602240_object), | ||
973 | GFP_KERNEL); | ||
974 | if (!data->object_table) { | ||
975 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
976 | return -ENOMEM; | ||
977 | } | ||
978 | |||
979 | /* Get object table information */ | ||
980 | error = qt602240_get_object_table(data); | ||
981 | if (error) | ||
982 | return error; | ||
983 | |||
984 | /* Check register init values */ | ||
985 | error = qt602240_check_reg_init(data); | ||
986 | if (error) | ||
987 | return error; | ||
988 | |||
989 | /* Check X/Y matrix size */ | ||
990 | error = qt602240_check_matrix_size(data); | ||
991 | if (error) | ||
992 | return error; | ||
993 | |||
994 | error = qt602240_make_highchg(data); | ||
995 | if (error) | ||
996 | return error; | ||
997 | |||
998 | qt602240_handle_pdata(data); | ||
999 | |||
1000 | /* Backup to memory */ | ||
1001 | qt602240_write_object(data, QT602240_GEN_COMMAND, | ||
1002 | QT602240_COMMAND_BACKUPNV, | ||
1003 | QT602240_BACKUP_VALUE); | ||
1004 | msleep(QT602240_BACKUP_TIME); | ||
1005 | |||
1006 | /* Soft reset */ | ||
1007 | qt602240_write_object(data, QT602240_GEN_COMMAND, | ||
1008 | QT602240_COMMAND_RESET, 1); | ||
1009 | msleep(QT602240_RESET_TIME); | ||
1010 | |||
1011 | /* Update matrix size at info struct */ | ||
1012 | error = qt602240_read_reg(client, QT602240_MATRIX_X_SIZE, &val); | ||
1013 | if (error) | ||
1014 | return error; | ||
1015 | info->matrix_xsize = val; | ||
1016 | |||
1017 | error = qt602240_read_reg(client, QT602240_MATRIX_Y_SIZE, &val); | ||
1018 | if (error) | ||
1019 | return error; | ||
1020 | info->matrix_ysize = val; | ||
1021 | |||
1022 | dev_info(&client->dev, | ||
1023 | "Family ID: %d Variant ID: %d Version: %d Build: %d\n", | ||
1024 | info->family_id, info->variant_id, info->version, | ||
1025 | info->build); | ||
1026 | |||
1027 | dev_info(&client->dev, | ||
1028 | "Matrix X Size: %d Matrix Y Size: %d Object Num: %d\n", | ||
1029 | info->matrix_xsize, info->matrix_ysize, | ||
1030 | info->object_num); | ||
1031 | |||
1032 | return 0; | ||
1033 | } | ||
1034 | |||
1035 | static ssize_t qt602240_object_show(struct device *dev, | ||
1036 | struct device_attribute *attr, char *buf) | ||
1037 | { | ||
1038 | struct qt602240_data *data = dev_get_drvdata(dev); | ||
1039 | struct qt602240_object *object; | ||
1040 | int count = 0; | ||
1041 | int i, j; | ||
1042 | int error; | ||
1043 | u8 val; | ||
1044 | |||
1045 | for (i = 0; i < data->info.object_num; i++) { | ||
1046 | object = data->object_table + i; | ||
1047 | |||
1048 | count += sprintf(buf + count, | ||
1049 | "Object Table Element %d(Type %d)\n", | ||
1050 | i + 1, object->type); | ||
1051 | |||
1052 | if (!qt602240_object_readable(object->type)) { | ||
1053 | count += sprintf(buf + count, "\n"); | ||
1054 | continue; | ||
1055 | } | ||
1056 | |||
1057 | for (j = 0; j < object->size + 1; j++) { | ||
1058 | error = qt602240_read_object(data, | ||
1059 | object->type, j, &val); | ||
1060 | if (error) | ||
1061 | return error; | ||
1062 | |||
1063 | count += sprintf(buf + count, | ||
1064 | " Byte %d: 0x%x (%d)\n", j, val, val); | ||
1065 | } | ||
1066 | |||
1067 | count += sprintf(buf + count, "\n"); | ||
1068 | } | ||
1069 | |||
1070 | return count; | ||
1071 | } | ||
1072 | |||
1073 | static int qt602240_load_fw(struct device *dev, const char *fn) | ||
1074 | { | ||
1075 | struct qt602240_data *data = dev_get_drvdata(dev); | ||
1076 | struct i2c_client *client = data->client; | ||
1077 | const struct firmware *fw = NULL; | ||
1078 | unsigned int frame_size; | ||
1079 | unsigned int pos = 0; | ||
1080 | int ret; | ||
1081 | |||
1082 | ret = request_firmware(&fw, fn, dev); | ||
1083 | if (ret) { | ||
1084 | dev_err(dev, "Unable to open firmware %s\n", fn); | ||
1085 | return ret; | ||
1086 | } | ||
1087 | |||
1088 | /* Change to the bootloader mode */ | ||
1089 | qt602240_write_object(data, QT602240_GEN_COMMAND, | ||
1090 | QT602240_COMMAND_RESET, QT602240_BOOT_VALUE); | ||
1091 | msleep(QT602240_RESET_TIME); | ||
1092 | |||
1093 | /* Change to slave address of bootloader */ | ||
1094 | if (client->addr == QT602240_APP_LOW) | ||
1095 | client->addr = QT602240_BOOT_LOW; | ||
1096 | else | ||
1097 | client->addr = QT602240_BOOT_HIGH; | ||
1098 | |||
1099 | ret = qt602240_check_bootloader(client, QT602240_WAITING_BOOTLOAD_CMD); | ||
1100 | if (ret) | ||
1101 | goto out; | ||
1102 | |||
1103 | /* Unlock bootloader */ | ||
1104 | qt602240_unlock_bootloader(client); | ||
1105 | |||
1106 | while (pos < fw->size) { | ||
1107 | ret = qt602240_check_bootloader(client, | ||
1108 | QT602240_WAITING_FRAME_DATA); | ||
1109 | if (ret) | ||
1110 | goto out; | ||
1111 | |||
1112 | frame_size = ((*(fw->data + pos) << 8) | *(fw->data + pos + 1)); | ||
1113 | |||
1114 | /* We should add 2 at frame size as the the firmware data is not | ||
1115 | * included the CRC bytes. | ||
1116 | */ | ||
1117 | frame_size += 2; | ||
1118 | |||
1119 | /* Write one frame to device */ | ||
1120 | qt602240_fw_write(client, fw->data + pos, frame_size); | ||
1121 | |||
1122 | ret = qt602240_check_bootloader(client, | ||
1123 | QT602240_FRAME_CRC_PASS); | ||
1124 | if (ret) | ||
1125 | goto out; | ||
1126 | |||
1127 | pos += frame_size; | ||
1128 | |||
1129 | dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size); | ||
1130 | } | ||
1131 | |||
1132 | out: | ||
1133 | release_firmware(fw); | ||
1134 | |||
1135 | /* Change to slave address of application */ | ||
1136 | if (client->addr == QT602240_BOOT_LOW) | ||
1137 | client->addr = QT602240_APP_LOW; | ||
1138 | else | ||
1139 | client->addr = QT602240_APP_HIGH; | ||
1140 | |||
1141 | return ret; | ||
1142 | } | ||
1143 | |||
1144 | static ssize_t qt602240_update_fw_store(struct device *dev, | ||
1145 | struct device_attribute *attr, | ||
1146 | const char *buf, size_t count) | ||
1147 | { | ||
1148 | struct qt602240_data *data = dev_get_drvdata(dev); | ||
1149 | unsigned int version; | ||
1150 | int error; | ||
1151 | |||
1152 | if (sscanf(buf, "%u", &version) != 1) { | ||
1153 | dev_err(dev, "Invalid values\n"); | ||
1154 | return -EINVAL; | ||
1155 | } | ||
1156 | |||
1157 | if (data->info.version < QT602240_VER_21 || version < QT602240_VER_21) { | ||
1158 | dev_err(dev, "FW update supported starting with version 21\n"); | ||
1159 | return -EINVAL; | ||
1160 | } | ||
1161 | |||
1162 | disable_irq(data->irq); | ||
1163 | |||
1164 | error = qt602240_load_fw(dev, QT602240_FW_NAME); | ||
1165 | if (error) { | ||
1166 | dev_err(dev, "The firmware update failed(%d)\n", error); | ||
1167 | count = error; | ||
1168 | } else { | ||
1169 | dev_dbg(dev, "The firmware update succeeded\n"); | ||
1170 | |||
1171 | /* Wait for reset */ | ||
1172 | msleep(QT602240_FWRESET_TIME); | ||
1173 | |||
1174 | kfree(data->object_table); | ||
1175 | data->object_table = NULL; | ||
1176 | |||
1177 | qt602240_initialize(data); | ||
1178 | } | ||
1179 | |||
1180 | enable_irq(data->irq); | ||
1181 | |||
1182 | return count; | ||
1183 | } | ||
1184 | |||
1185 | static DEVICE_ATTR(object, 0444, qt602240_object_show, NULL); | ||
1186 | static DEVICE_ATTR(update_fw, 0664, NULL, qt602240_update_fw_store); | ||
1187 | |||
1188 | static struct attribute *qt602240_attrs[] = { | ||
1189 | &dev_attr_object.attr, | ||
1190 | &dev_attr_update_fw.attr, | ||
1191 | NULL | ||
1192 | }; | ||
1193 | |||
1194 | static const struct attribute_group qt602240_attr_group = { | ||
1195 | .attrs = qt602240_attrs, | ||
1196 | }; | ||
1197 | |||
1198 | static void qt602240_start(struct qt602240_data *data) | ||
1199 | { | ||
1200 | /* Touch enable */ | ||
1201 | qt602240_write_object(data, | ||
1202 | QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0x83); | ||
1203 | } | ||
1204 | |||
1205 | static void qt602240_stop(struct qt602240_data *data) | ||
1206 | { | ||
1207 | /* Touch disable */ | ||
1208 | qt602240_write_object(data, | ||
1209 | QT602240_TOUCH_MULTI, QT602240_TOUCH_CTRL, 0); | ||
1210 | } | ||
1211 | |||
1212 | static int qt602240_input_open(struct input_dev *dev) | ||
1213 | { | ||
1214 | struct qt602240_data *data = input_get_drvdata(dev); | ||
1215 | |||
1216 | qt602240_start(data); | ||
1217 | |||
1218 | return 0; | ||
1219 | } | ||
1220 | |||
1221 | static void qt602240_input_close(struct input_dev *dev) | ||
1222 | { | ||
1223 | struct qt602240_data *data = input_get_drvdata(dev); | ||
1224 | |||
1225 | qt602240_stop(data); | ||
1226 | } | ||
1227 | |||
1228 | static int __devinit qt602240_probe(struct i2c_client *client, | ||
1229 | const struct i2c_device_id *id) | ||
1230 | { | ||
1231 | struct qt602240_data *data; | ||
1232 | struct input_dev *input_dev; | ||
1233 | int error; | ||
1234 | |||
1235 | if (!client->dev.platform_data) | ||
1236 | return -EINVAL; | ||
1237 | |||
1238 | data = kzalloc(sizeof(struct qt602240_data), GFP_KERNEL); | ||
1239 | input_dev = input_allocate_device(); | ||
1240 | if (!data || !input_dev) { | ||
1241 | dev_err(&client->dev, "Failed to allocate memory\n"); | ||
1242 | error = -ENOMEM; | ||
1243 | goto err_free_mem; | ||
1244 | } | ||
1245 | |||
1246 | input_dev->name = "AT42QT602240/ATMXT224 Touchscreen"; | ||
1247 | input_dev->id.bustype = BUS_I2C; | ||
1248 | input_dev->dev.parent = &client->dev; | ||
1249 | input_dev->open = qt602240_input_open; | ||
1250 | input_dev->close = qt602240_input_close; | ||
1251 | |||
1252 | __set_bit(EV_ABS, input_dev->evbit); | ||
1253 | __set_bit(EV_KEY, input_dev->evbit); | ||
1254 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
1255 | |||
1256 | /* For single touch */ | ||
1257 | input_set_abs_params(input_dev, ABS_X, | ||
1258 | 0, QT602240_MAX_XC, 0, 0); | ||
1259 | input_set_abs_params(input_dev, ABS_Y, | ||
1260 | 0, QT602240_MAX_YC, 0, 0); | ||
1261 | |||
1262 | /* For multi touch */ | ||
1263 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | ||
1264 | 0, QT602240_MAX_AREA, 0, 0); | ||
1265 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | ||
1266 | 0, QT602240_MAX_XC, 0, 0); | ||
1267 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | ||
1268 | 0, QT602240_MAX_YC, 0, 0); | ||
1269 | |||
1270 | input_set_drvdata(input_dev, data); | ||
1271 | |||
1272 | data->client = client; | ||
1273 | data->input_dev = input_dev; | ||
1274 | data->pdata = client->dev.platform_data; | ||
1275 | data->irq = client->irq; | ||
1276 | |||
1277 | i2c_set_clientdata(client, data); | ||
1278 | |||
1279 | error = qt602240_initialize(data); | ||
1280 | if (error) | ||
1281 | goto err_free_object; | ||
1282 | |||
1283 | error = request_threaded_irq(client->irq, NULL, qt602240_interrupt, | ||
1284 | IRQF_TRIGGER_FALLING, client->dev.driver->name, data); | ||
1285 | if (error) { | ||
1286 | dev_err(&client->dev, "Failed to register interrupt\n"); | ||
1287 | goto err_free_object; | ||
1288 | } | ||
1289 | |||
1290 | error = input_register_device(input_dev); | ||
1291 | if (error) | ||
1292 | goto err_free_irq; | ||
1293 | |||
1294 | error = sysfs_create_group(&client->dev.kobj, &qt602240_attr_group); | ||
1295 | if (error) | ||
1296 | goto err_unregister_device; | ||
1297 | |||
1298 | return 0; | ||
1299 | |||
1300 | err_unregister_device: | ||
1301 | input_unregister_device(input_dev); | ||
1302 | input_dev = NULL; | ||
1303 | err_free_irq: | ||
1304 | free_irq(client->irq, data); | ||
1305 | err_free_object: | ||
1306 | kfree(data->object_table); | ||
1307 | err_free_mem: | ||
1308 | input_free_device(input_dev); | ||
1309 | kfree(data); | ||
1310 | return error; | ||
1311 | } | ||
1312 | |||
1313 | static int __devexit qt602240_remove(struct i2c_client *client) | ||
1314 | { | ||
1315 | struct qt602240_data *data = i2c_get_clientdata(client); | ||
1316 | |||
1317 | sysfs_remove_group(&client->dev.kobj, &qt602240_attr_group); | ||
1318 | free_irq(data->irq, data); | ||
1319 | input_unregister_device(data->input_dev); | ||
1320 | kfree(data->object_table); | ||
1321 | kfree(data); | ||
1322 | |||
1323 | return 0; | ||
1324 | } | ||
1325 | |||
1326 | #ifdef CONFIG_PM | ||
1327 | static int qt602240_suspend(struct device *dev) | ||
1328 | { | ||
1329 | struct i2c_client *client = to_i2c_client(dev); | ||
1330 | struct qt602240_data *data = i2c_get_clientdata(client); | ||
1331 | struct input_dev *input_dev = data->input_dev; | ||
1332 | |||
1333 | mutex_lock(&input_dev->mutex); | ||
1334 | |||
1335 | if (input_dev->users) | ||
1336 | qt602240_stop(data); | ||
1337 | |||
1338 | mutex_unlock(&input_dev->mutex); | ||
1339 | |||
1340 | return 0; | ||
1341 | } | ||
1342 | |||
1343 | static int qt602240_resume(struct device *dev) | ||
1344 | { | ||
1345 | struct i2c_client *client = to_i2c_client(dev); | ||
1346 | struct qt602240_data *data = i2c_get_clientdata(client); | ||
1347 | struct input_dev *input_dev = data->input_dev; | ||
1348 | |||
1349 | /* Soft reset */ | ||
1350 | qt602240_write_object(data, QT602240_GEN_COMMAND, | ||
1351 | QT602240_COMMAND_RESET, 1); | ||
1352 | |||
1353 | msleep(QT602240_RESET_TIME); | ||
1354 | |||
1355 | mutex_lock(&input_dev->mutex); | ||
1356 | |||
1357 | if (input_dev->users) | ||
1358 | qt602240_start(data); | ||
1359 | |||
1360 | mutex_unlock(&input_dev->mutex); | ||
1361 | |||
1362 | return 0; | ||
1363 | } | ||
1364 | |||
1365 | static const struct dev_pm_ops qt602240_pm_ops = { | ||
1366 | .suspend = qt602240_suspend, | ||
1367 | .resume = qt602240_resume, | ||
1368 | }; | ||
1369 | #endif | ||
1370 | |||
1371 | static const struct i2c_device_id qt602240_id[] = { | ||
1372 | { "qt602240_ts", 0 }, | ||
1373 | { } | ||
1374 | }; | ||
1375 | MODULE_DEVICE_TABLE(i2c, qt602240_id); | ||
1376 | |||
1377 | static struct i2c_driver qt602240_driver = { | ||
1378 | .driver = { | ||
1379 | .name = "qt602240_ts", | ||
1380 | .owner = THIS_MODULE, | ||
1381 | #ifdef CONFIG_PM | ||
1382 | .pm = &qt602240_pm_ops, | ||
1383 | #endif | ||
1384 | }, | ||
1385 | .probe = qt602240_probe, | ||
1386 | .remove = __devexit_p(qt602240_remove), | ||
1387 | .id_table = qt602240_id, | ||
1388 | }; | ||
1389 | |||
1390 | static int __init qt602240_init(void) | ||
1391 | { | ||
1392 | return i2c_add_driver(&qt602240_driver); | ||
1393 | } | ||
1394 | |||
1395 | static void __exit qt602240_exit(void) | ||
1396 | { | ||
1397 | i2c_del_driver(&qt602240_driver); | ||
1398 | } | ||
1399 | |||
1400 | module_init(qt602240_init); | ||
1401 | module_exit(qt602240_exit); | ||
1402 | |||
1403 | /* Module information */ | ||
1404 | MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); | ||
1405 | MODULE_DESCRIPTION("AT42QT602240/ATMXT224 Touchscreen driver"); | ||
1406 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c new file mode 100644 index 000000000000..87420616efa4 --- /dev/null +++ b/drivers/input/touchscreen/tsc2005.c | |||
@@ -0,0 +1,756 @@ | |||
1 | /* | ||
2 | * TSC2005 touchscreen driver | ||
3 | * | ||
4 | * Copyright (C) 2006-2010 Nokia Corporation | ||
5 | * | ||
6 | * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com> | ||
7 | * based on TSC2301 driver by Klaus K. Pedersen <klaus.k.pedersen@nokia.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/input.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/pm.h> | ||
31 | #include <linux/spi/spi.h> | ||
32 | #include <linux/spi/tsc2005.h> | ||
33 | |||
34 | /* | ||
35 | * The touchscreen interface operates as follows: | ||
36 | * | ||
37 | * 1) Pen is pressed against the touchscreen. | ||
38 | * 2) TSC2005 performs AD conversion. | ||
39 | * 3) After the conversion is done TSC2005 drives DAV line down. | ||
40 | * 4) GPIO IRQ is received and tsc2005_irq_thread() is scheduled. | ||
41 | * 5) tsc2005_irq_thread() queues up an spi transfer to fetch the x, y, z1, z2 | ||
42 | * values. | ||
43 | * 6) tsc2005_irq_thread() reports coordinates to input layer and sets up | ||
44 | * tsc2005_penup_timer() to be called after TSC2005_PENUP_TIME_MS (40ms). | ||
45 | * 7) When the penup timer expires, there have not been touch or DAV interrupts | ||
46 | * during the last 40ms which means the pen has been lifted. | ||
47 | * | ||
48 | * ESD recovery via a hardware reset is done if the TSC2005 doesn't respond | ||
49 | * after a configurable period (in ms) of activity. If esd_timeout is 0, the | ||
50 | * watchdog is disabled. | ||
51 | */ | ||
52 | |||
53 | /* control byte 1 */ | ||
54 | #define TSC2005_CMD 0x80 | ||
55 | #define TSC2005_CMD_NORMAL 0x00 | ||
56 | #define TSC2005_CMD_STOP 0x01 | ||
57 | #define TSC2005_CMD_12BIT 0x04 | ||
58 | |||
59 | /* control byte 0 */ | ||
60 | #define TSC2005_REG_READ 0x0001 | ||
61 | #define TSC2005_REG_PND0 0x0002 | ||
62 | #define TSC2005_REG_X 0x0000 | ||
63 | #define TSC2005_REG_Y 0x0008 | ||
64 | #define TSC2005_REG_Z1 0x0010 | ||
65 | #define TSC2005_REG_Z2 0x0018 | ||
66 | #define TSC2005_REG_TEMP_HIGH 0x0050 | ||
67 | #define TSC2005_REG_CFR0 0x0060 | ||
68 | #define TSC2005_REG_CFR1 0x0068 | ||
69 | #define TSC2005_REG_CFR2 0x0070 | ||
70 | |||
71 | /* configuration register 0 */ | ||
72 | #define TSC2005_CFR0_PRECHARGE_276US 0x0040 | ||
73 | #define TSC2005_CFR0_STABTIME_1MS 0x0300 | ||
74 | #define TSC2005_CFR0_CLOCK_1MHZ 0x1000 | ||
75 | #define TSC2005_CFR0_RESOLUTION12 0x2000 | ||
76 | #define TSC2005_CFR0_PENMODE 0x8000 | ||
77 | #define TSC2005_CFR0_INITVALUE (TSC2005_CFR0_STABTIME_1MS | \ | ||
78 | TSC2005_CFR0_CLOCK_1MHZ | \ | ||
79 | TSC2005_CFR0_RESOLUTION12 | \ | ||
80 | TSC2005_CFR0_PRECHARGE_276US | \ | ||
81 | TSC2005_CFR0_PENMODE) | ||
82 | |||
83 | /* bits common to both read and write of configuration register 0 */ | ||
84 | #define TSC2005_CFR0_RW_MASK 0x3fff | ||
85 | |||
86 | /* configuration register 1 */ | ||
87 | #define TSC2005_CFR1_BATCHDELAY_4MS 0x0003 | ||
88 | #define TSC2005_CFR1_INITVALUE TSC2005_CFR1_BATCHDELAY_4MS | ||
89 | |||
90 | /* configuration register 2 */ | ||
91 | #define TSC2005_CFR2_MAVE_Z 0x0004 | ||
92 | #define TSC2005_CFR2_MAVE_Y 0x0008 | ||
93 | #define TSC2005_CFR2_MAVE_X 0x0010 | ||
94 | #define TSC2005_CFR2_AVG_7 0x0800 | ||
95 | #define TSC2005_CFR2_MEDIUM_15 0x3000 | ||
96 | #define TSC2005_CFR2_INITVALUE (TSC2005_CFR2_MAVE_X | \ | ||
97 | TSC2005_CFR2_MAVE_Y | \ | ||
98 | TSC2005_CFR2_MAVE_Z | \ | ||
99 | TSC2005_CFR2_MEDIUM_15 | \ | ||
100 | TSC2005_CFR2_AVG_7) | ||
101 | |||
102 | #define MAX_12BIT 0xfff | ||
103 | #define TSC2005_SPI_MAX_SPEED_HZ 10000000 | ||
104 | #define TSC2005_PENUP_TIME_MS 40 | ||
105 | |||
106 | struct tsc2005_spi_rd { | ||
107 | struct spi_transfer spi_xfer; | ||
108 | u32 spi_tx; | ||
109 | u32 spi_rx; | ||
110 | }; | ||
111 | |||
112 | struct tsc2005 { | ||
113 | struct spi_device *spi; | ||
114 | |||
115 | struct spi_message spi_read_msg; | ||
116 | struct tsc2005_spi_rd spi_x; | ||
117 | struct tsc2005_spi_rd spi_y; | ||
118 | struct tsc2005_spi_rd spi_z1; | ||
119 | struct tsc2005_spi_rd spi_z2; | ||
120 | |||
121 | struct input_dev *idev; | ||
122 | char phys[32]; | ||
123 | |||
124 | struct mutex mutex; | ||
125 | |||
126 | /* raw copy of previous x,y,z */ | ||
127 | int in_x; | ||
128 | int in_y; | ||
129 | int in_z1; | ||
130 | int in_z2; | ||
131 | |||
132 | spinlock_t lock; | ||
133 | struct timer_list penup_timer; | ||
134 | |||
135 | unsigned int esd_timeout; | ||
136 | struct delayed_work esd_work; | ||
137 | unsigned long last_valid_interrupt; | ||
138 | |||
139 | unsigned int x_plate_ohm; | ||
140 | |||
141 | bool opened; | ||
142 | bool suspended; | ||
143 | |||
144 | bool pen_down; | ||
145 | |||
146 | void (*set_reset)(bool enable); | ||
147 | }; | ||
148 | |||
149 | static int tsc2005_cmd(struct tsc2005 *ts, u8 cmd) | ||
150 | { | ||
151 | u8 tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd; | ||
152 | struct spi_transfer xfer = { | ||
153 | .tx_buf = &tx, | ||
154 | .len = 1, | ||
155 | .bits_per_word = 8, | ||
156 | }; | ||
157 | struct spi_message msg; | ||
158 | int error; | ||
159 | |||
160 | spi_message_init(&msg); | ||
161 | spi_message_add_tail(&xfer, &msg); | ||
162 | |||
163 | error = spi_sync(ts->spi, &msg); | ||
164 | if (error) { | ||
165 | dev_err(&ts->spi->dev, "%s: failed, command: %x, error: %d\n", | ||
166 | __func__, cmd, error); | ||
167 | return error; | ||
168 | } | ||
169 | |||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | static int tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value) | ||
174 | { | ||
175 | u32 tx = ((reg | TSC2005_REG_PND0) << 16) | value; | ||
176 | struct spi_transfer xfer = { | ||
177 | .tx_buf = &tx, | ||
178 | .len = 4, | ||
179 | .bits_per_word = 24, | ||
180 | }; | ||
181 | struct spi_message msg; | ||
182 | int error; | ||
183 | |||
184 | spi_message_init(&msg); | ||
185 | spi_message_add_tail(&xfer, &msg); | ||
186 | |||
187 | error = spi_sync(ts->spi, &msg); | ||
188 | if (error) { | ||
189 | dev_err(&ts->spi->dev, | ||
190 | "%s: failed, register: %x, value: %x, error: %d\n", | ||
191 | __func__, reg, value, error); | ||
192 | return error; | ||
193 | } | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last) | ||
199 | { | ||
200 | memset(rd, 0, sizeof(*rd)); | ||
201 | |||
202 | rd->spi_tx = (reg | TSC2005_REG_READ) << 16; | ||
203 | rd->spi_xfer.tx_buf = &rd->spi_tx; | ||
204 | rd->spi_xfer.rx_buf = &rd->spi_rx; | ||
205 | rd->spi_xfer.len = 4; | ||
206 | rd->spi_xfer.bits_per_word = 24; | ||
207 | rd->spi_xfer.cs_change = !last; | ||
208 | } | ||
209 | |||
210 | static int tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value) | ||
211 | { | ||
212 | struct tsc2005_spi_rd spi_rd; | ||
213 | struct spi_message msg; | ||
214 | int error; | ||
215 | |||
216 | tsc2005_setup_read(&spi_rd, reg, true); | ||
217 | |||
218 | spi_message_init(&msg); | ||
219 | spi_message_add_tail(&spi_rd.spi_xfer, &msg); | ||
220 | |||
221 | error = spi_sync(ts->spi, &msg); | ||
222 | if (error) | ||
223 | return error; | ||
224 | |||
225 | *value = spi_rd.spi_rx; | ||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static void tsc2005_update_pen_state(struct tsc2005 *ts, | ||
230 | int x, int y, int pressure) | ||
231 | { | ||
232 | if (pressure) { | ||
233 | input_report_abs(ts->idev, ABS_X, x); | ||
234 | input_report_abs(ts->idev, ABS_Y, y); | ||
235 | input_report_abs(ts->idev, ABS_PRESSURE, pressure); | ||
236 | if (!ts->pen_down) { | ||
237 | input_report_key(ts->idev, BTN_TOUCH, !!pressure); | ||
238 | ts->pen_down = true; | ||
239 | } | ||
240 | } else { | ||
241 | input_report_abs(ts->idev, ABS_PRESSURE, 0); | ||
242 | if (ts->pen_down) { | ||
243 | input_report_key(ts->idev, BTN_TOUCH, 0); | ||
244 | ts->pen_down = false; | ||
245 | } | ||
246 | } | ||
247 | input_sync(ts->idev); | ||
248 | dev_dbg(&ts->spi->dev, "point(%4d,%4d), pressure (%4d)\n", x, y, | ||
249 | pressure); | ||
250 | } | ||
251 | |||
252 | static irqreturn_t tsc2005_irq_thread(int irq, void *_ts) | ||
253 | { | ||
254 | struct tsc2005 *ts = _ts; | ||
255 | unsigned long flags; | ||
256 | unsigned int pressure; | ||
257 | u32 x, y; | ||
258 | u32 z1, z2; | ||
259 | int error; | ||
260 | |||
261 | /* read the coordinates */ | ||
262 | error = spi_sync(ts->spi, &ts->spi_read_msg); | ||
263 | if (unlikely(error)) | ||
264 | goto out; | ||
265 | |||
266 | x = ts->spi_x.spi_rx; | ||
267 | y = ts->spi_y.spi_rx; | ||
268 | z1 = ts->spi_z1.spi_rx; | ||
269 | z2 = ts->spi_z2.spi_rx; | ||
270 | |||
271 | /* validate position */ | ||
272 | if (unlikely(x > MAX_12BIT || y > MAX_12BIT)) | ||
273 | goto out; | ||
274 | |||
275 | /* Skip reading if the pressure components are out of range */ | ||
276 | if (unlikely(z1 == 0 || z2 > MAX_12BIT || z1 >= z2)) | ||
277 | goto out; | ||
278 | |||
279 | /* | ||
280 | * Skip point if this is a pen down with the exact same values as | ||
281 | * the value before pen-up - that implies SPI fed us stale data | ||
282 | */ | ||
283 | if (!ts->pen_down && | ||
284 | ts->in_x == x && ts->in_y == y && | ||
285 | ts->in_z1 == z1 && ts->in_z2 == z2) { | ||
286 | goto out; | ||
287 | } | ||
288 | |||
289 | /* | ||
290 | * At this point we are happy we have a valid and useful reading. | ||
291 | * Remember it for later comparisons. We may now begin downsampling. | ||
292 | */ | ||
293 | ts->in_x = x; | ||
294 | ts->in_y = y; | ||
295 | ts->in_z1 = z1; | ||
296 | ts->in_z2 = z2; | ||
297 | |||
298 | /* Compute touch pressure resistance using equation #1 */ | ||
299 | pressure = x * (z2 - z1) / z1; | ||
300 | pressure = pressure * ts->x_plate_ohm / 4096; | ||
301 | if (unlikely(pressure > MAX_12BIT)) | ||
302 | goto out; | ||
303 | |||
304 | spin_lock_irqsave(&ts->lock, flags); | ||
305 | |||
306 | tsc2005_update_pen_state(ts, x, y, pressure); | ||
307 | mod_timer(&ts->penup_timer, | ||
308 | jiffies + msecs_to_jiffies(TSC2005_PENUP_TIME_MS)); | ||
309 | |||
310 | spin_unlock_irqrestore(&ts->lock, flags); | ||
311 | |||
312 | ts->last_valid_interrupt = jiffies; | ||
313 | out: | ||
314 | return IRQ_HANDLED; | ||
315 | } | ||
316 | |||
317 | static void tsc2005_penup_timer(unsigned long data) | ||
318 | { | ||
319 | struct tsc2005 *ts = (struct tsc2005 *)data; | ||
320 | unsigned long flags; | ||
321 | |||
322 | spin_lock_irqsave(&ts->lock, flags); | ||
323 | tsc2005_update_pen_state(ts, 0, 0, 0); | ||
324 | spin_unlock_irqrestore(&ts->lock, flags); | ||
325 | } | ||
326 | |||
327 | static void tsc2005_start_scan(struct tsc2005 *ts) | ||
328 | { | ||
329 | tsc2005_write(ts, TSC2005_REG_CFR0, TSC2005_CFR0_INITVALUE); | ||
330 | tsc2005_write(ts, TSC2005_REG_CFR1, TSC2005_CFR1_INITVALUE); | ||
331 | tsc2005_write(ts, TSC2005_REG_CFR2, TSC2005_CFR2_INITVALUE); | ||
332 | tsc2005_cmd(ts, TSC2005_CMD_NORMAL); | ||
333 | } | ||
334 | |||
335 | static void tsc2005_stop_scan(struct tsc2005 *ts) | ||
336 | { | ||
337 | tsc2005_cmd(ts, TSC2005_CMD_STOP); | ||
338 | } | ||
339 | |||
340 | /* must be called with ts->mutex held */ | ||
341 | static void __tsc2005_disable(struct tsc2005 *ts) | ||
342 | { | ||
343 | tsc2005_stop_scan(ts); | ||
344 | |||
345 | disable_irq(ts->spi->irq); | ||
346 | del_timer_sync(&ts->penup_timer); | ||
347 | |||
348 | cancel_delayed_work_sync(&ts->esd_work); | ||
349 | |||
350 | enable_irq(ts->spi->irq); | ||
351 | } | ||
352 | |||
353 | /* must be called with ts->mutex held */ | ||
354 | static void __tsc2005_enable(struct tsc2005 *ts) | ||
355 | { | ||
356 | tsc2005_start_scan(ts); | ||
357 | |||
358 | if (ts->esd_timeout && ts->set_reset) { | ||
359 | ts->last_valid_interrupt = jiffies; | ||
360 | schedule_delayed_work(&ts->esd_work, | ||
361 | round_jiffies(jiffies + | ||
362 | msecs_to_jiffies(ts->esd_timeout))); | ||
363 | } | ||
364 | |||
365 | } | ||
366 | |||
367 | static ssize_t tsc2005_selftest_show(struct device *dev, | ||
368 | struct device_attribute *attr, | ||
369 | char *buf) | ||
370 | { | ||
371 | struct spi_device *spi = to_spi_device(dev); | ||
372 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
373 | u16 temp_high; | ||
374 | u16 temp_high_orig; | ||
375 | u16 temp_high_test; | ||
376 | bool success = true; | ||
377 | int error; | ||
378 | |||
379 | mutex_lock(&ts->mutex); | ||
380 | |||
381 | /* | ||
382 | * Test TSC2005 communications via temp high register. | ||
383 | */ | ||
384 | __tsc2005_disable(ts); | ||
385 | |||
386 | error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high_orig); | ||
387 | if (error) { | ||
388 | dev_warn(dev, "selftest failed: read error %d\n", error); | ||
389 | success = false; | ||
390 | goto out; | ||
391 | } | ||
392 | |||
393 | temp_high_test = (temp_high_orig - 1) & MAX_12BIT; | ||
394 | |||
395 | error = tsc2005_write(ts, TSC2005_REG_TEMP_HIGH, temp_high_test); | ||
396 | if (error) { | ||
397 | dev_warn(dev, "selftest failed: write error %d\n", error); | ||
398 | success = false; | ||
399 | goto out; | ||
400 | } | ||
401 | |||
402 | error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high); | ||
403 | if (error) { | ||
404 | dev_warn(dev, "selftest failed: read error %d after write\n", | ||
405 | error); | ||
406 | success = false; | ||
407 | goto out; | ||
408 | } | ||
409 | |||
410 | if (temp_high != temp_high_test) { | ||
411 | dev_warn(dev, "selftest failed: %d != %d\n", | ||
412 | temp_high, temp_high_test); | ||
413 | success = false; | ||
414 | } | ||
415 | |||
416 | /* hardware reset */ | ||
417 | ts->set_reset(false); | ||
418 | usleep_range(100, 500); /* only 10us required */ | ||
419 | ts->set_reset(true); | ||
420 | |||
421 | if (!success) | ||
422 | goto out; | ||
423 | |||
424 | /* test that the reset really happened */ | ||
425 | error = tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high); | ||
426 | if (error) { | ||
427 | dev_warn(dev, "selftest failed: read error %d after reset\n", | ||
428 | error); | ||
429 | success = false; | ||
430 | goto out; | ||
431 | } | ||
432 | |||
433 | if (temp_high != temp_high_orig) { | ||
434 | dev_warn(dev, "selftest failed after reset: %d != %d\n", | ||
435 | temp_high, temp_high_orig); | ||
436 | success = false; | ||
437 | } | ||
438 | |||
439 | out: | ||
440 | __tsc2005_enable(ts); | ||
441 | mutex_unlock(&ts->mutex); | ||
442 | |||
443 | return sprintf(buf, "%d\n", success); | ||
444 | } | ||
445 | |||
446 | static DEVICE_ATTR(selftest, S_IRUGO, tsc2005_selftest_show, NULL); | ||
447 | |||
448 | static struct attribute *tsc2005_attrs[] = { | ||
449 | &dev_attr_selftest.attr, | ||
450 | NULL | ||
451 | }; | ||
452 | |||
453 | static mode_t tsc2005_attr_is_visible(struct kobject *kobj, | ||
454 | struct attribute *attr, int n) | ||
455 | { | ||
456 | struct device *dev = container_of(kobj, struct device, kobj); | ||
457 | struct spi_device *spi = to_spi_device(dev); | ||
458 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
459 | mode_t mode = attr->mode; | ||
460 | |||
461 | if (attr == &dev_attr_selftest.attr) { | ||
462 | if (!ts->set_reset) | ||
463 | mode = 0; | ||
464 | } | ||
465 | |||
466 | return mode; | ||
467 | } | ||
468 | |||
469 | static const struct attribute_group tsc2005_attr_group = { | ||
470 | .is_visible = tsc2005_attr_is_visible, | ||
471 | .attrs = tsc2005_attrs, | ||
472 | }; | ||
473 | |||
474 | static void tsc2005_esd_work(struct work_struct *work) | ||
475 | { | ||
476 | struct tsc2005 *ts = container_of(work, struct tsc2005, esd_work.work); | ||
477 | int error; | ||
478 | u16 r; | ||
479 | |||
480 | mutex_lock(&ts->mutex); | ||
481 | |||
482 | if (time_is_after_jiffies(ts->last_valid_interrupt + | ||
483 | msecs_to_jiffies(ts->esd_timeout))) | ||
484 | goto out; | ||
485 | |||
486 | /* We should be able to read register without disabling interrupts. */ | ||
487 | error = tsc2005_read(ts, TSC2005_REG_CFR0, &r); | ||
488 | if (!error && | ||
489 | !((r ^ TSC2005_CFR0_INITVALUE) & TSC2005_CFR0_RW_MASK)) { | ||
490 | goto out; | ||
491 | } | ||
492 | |||
493 | /* | ||
494 | * If we could not read our known value from configuration register 0 | ||
495 | * then we should reset the controller as if from power-up and start | ||
496 | * scanning again. | ||
497 | */ | ||
498 | dev_info(&ts->spi->dev, "TSC2005 not responding - resetting\n"); | ||
499 | |||
500 | disable_irq(ts->spi->irq); | ||
501 | del_timer_sync(&ts->penup_timer); | ||
502 | |||
503 | tsc2005_update_pen_state(ts, 0, 0, 0); | ||
504 | |||
505 | ts->set_reset(false); | ||
506 | usleep_range(100, 500); /* only 10us required */ | ||
507 | ts->set_reset(true); | ||
508 | |||
509 | enable_irq(ts->spi->irq); | ||
510 | tsc2005_start_scan(ts); | ||
511 | |||
512 | out: | ||
513 | /* re-arm the watchdog */ | ||
514 | schedule_delayed_work(&ts->esd_work, | ||
515 | round_jiffies(jiffies + | ||
516 | msecs_to_jiffies(ts->esd_timeout))); | ||
517 | mutex_unlock(&ts->mutex); | ||
518 | } | ||
519 | |||
520 | static int tsc2005_open(struct input_dev *input) | ||
521 | { | ||
522 | struct tsc2005 *ts = input_get_drvdata(input); | ||
523 | |||
524 | mutex_lock(&ts->mutex); | ||
525 | |||
526 | if (!ts->suspended) | ||
527 | __tsc2005_enable(ts); | ||
528 | |||
529 | ts->opened = true; | ||
530 | |||
531 | mutex_unlock(&ts->mutex); | ||
532 | |||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | static void tsc2005_close(struct input_dev *input) | ||
537 | { | ||
538 | struct tsc2005 *ts = input_get_drvdata(input); | ||
539 | |||
540 | mutex_lock(&ts->mutex); | ||
541 | |||
542 | if (!ts->suspended) | ||
543 | __tsc2005_disable(ts); | ||
544 | |||
545 | ts->opened = false; | ||
546 | |||
547 | mutex_unlock(&ts->mutex); | ||
548 | } | ||
549 | |||
550 | static void __devinit tsc2005_setup_spi_xfer(struct tsc2005 *ts) | ||
551 | { | ||
552 | tsc2005_setup_read(&ts->spi_x, TSC2005_REG_X, false); | ||
553 | tsc2005_setup_read(&ts->spi_y, TSC2005_REG_Y, false); | ||
554 | tsc2005_setup_read(&ts->spi_z1, TSC2005_REG_Z1, false); | ||
555 | tsc2005_setup_read(&ts->spi_z2, TSC2005_REG_Z2, true); | ||
556 | |||
557 | spi_message_init(&ts->spi_read_msg); | ||
558 | spi_message_add_tail(&ts->spi_x.spi_xfer, &ts->spi_read_msg); | ||
559 | spi_message_add_tail(&ts->spi_y.spi_xfer, &ts->spi_read_msg); | ||
560 | spi_message_add_tail(&ts->spi_z1.spi_xfer, &ts->spi_read_msg); | ||
561 | spi_message_add_tail(&ts->spi_z2.spi_xfer, &ts->spi_read_msg); | ||
562 | } | ||
563 | |||
564 | static int __devinit tsc2005_probe(struct spi_device *spi) | ||
565 | { | ||
566 | const struct tsc2005_platform_data *pdata = spi->dev.platform_data; | ||
567 | struct tsc2005 *ts; | ||
568 | struct input_dev *input_dev; | ||
569 | unsigned int max_x, max_y, max_p; | ||
570 | unsigned int fudge_x, fudge_y, fudge_p; | ||
571 | int error; | ||
572 | |||
573 | if (!pdata) { | ||
574 | dev_dbg(&spi->dev, "no platform data\n"); | ||
575 | return -ENODEV; | ||
576 | } | ||
577 | |||
578 | fudge_x = pdata->ts_x_fudge ? : 4; | ||
579 | fudge_y = pdata->ts_y_fudge ? : 8; | ||
580 | fudge_p = pdata->ts_pressure_fudge ? : 2; | ||
581 | max_x = pdata->ts_x_max ? : MAX_12BIT; | ||
582 | max_y = pdata->ts_y_max ? : MAX_12BIT; | ||
583 | max_p = pdata->ts_pressure_max ? : MAX_12BIT; | ||
584 | |||
585 | if (spi->irq <= 0) { | ||
586 | dev_dbg(&spi->dev, "no irq\n"); | ||
587 | return -ENODEV; | ||
588 | } | ||
589 | |||
590 | spi->mode = SPI_MODE_0; | ||
591 | spi->bits_per_word = 8; | ||
592 | if (!spi->max_speed_hz) | ||
593 | spi->max_speed_hz = TSC2005_SPI_MAX_SPEED_HZ; | ||
594 | |||
595 | error = spi_setup(spi); | ||
596 | if (error) | ||
597 | return error; | ||
598 | |||
599 | ts = kzalloc(sizeof(*ts), GFP_KERNEL); | ||
600 | input_dev = input_allocate_device(); | ||
601 | if (!ts || !input_dev) { | ||
602 | error = -ENOMEM; | ||
603 | goto err_free_mem; | ||
604 | } | ||
605 | |||
606 | ts->spi = spi; | ||
607 | ts->idev = input_dev; | ||
608 | |||
609 | ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280; | ||
610 | ts->esd_timeout = pdata->esd_timeout_ms; | ||
611 | ts->set_reset = pdata->set_reset; | ||
612 | |||
613 | mutex_init(&ts->mutex); | ||
614 | |||
615 | spin_lock_init(&ts->lock); | ||
616 | setup_timer(&ts->penup_timer, tsc2005_penup_timer, (unsigned long)ts); | ||
617 | |||
618 | INIT_DELAYED_WORK(&ts->esd_work, tsc2005_esd_work); | ||
619 | |||
620 | tsc2005_setup_spi_xfer(ts); | ||
621 | |||
622 | snprintf(ts->phys, sizeof(ts->phys), | ||
623 | "%s/input-ts", dev_name(&spi->dev)); | ||
624 | |||
625 | input_dev->name = "TSC2005 touchscreen"; | ||
626 | input_dev->phys = ts->phys; | ||
627 | input_dev->id.bustype = BUS_SPI; | ||
628 | input_dev->dev.parent = &spi->dev; | ||
629 | input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | ||
630 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | ||
631 | |||
632 | input_set_abs_params(input_dev, ABS_X, 0, max_x, fudge_x, 0); | ||
633 | input_set_abs_params(input_dev, ABS_Y, 0, max_y, fudge_y, 0); | ||
634 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0); | ||
635 | |||
636 | input_dev->open = tsc2005_open; | ||
637 | input_dev->close = tsc2005_close; | ||
638 | |||
639 | input_set_drvdata(input_dev, ts); | ||
640 | |||
641 | /* Ensure the touchscreen is off */ | ||
642 | tsc2005_stop_scan(ts); | ||
643 | |||
644 | error = request_threaded_irq(spi->irq, NULL, tsc2005_irq_thread, | ||
645 | IRQF_TRIGGER_RISING, "tsc2005", ts); | ||
646 | if (error) { | ||
647 | dev_err(&spi->dev, "Failed to request irq, err: %d\n", error); | ||
648 | goto err_free_mem; | ||
649 | } | ||
650 | |||
651 | spi_set_drvdata(spi, ts); | ||
652 | error = sysfs_create_group(&spi->dev.kobj, &tsc2005_attr_group); | ||
653 | if (error) { | ||
654 | dev_err(&spi->dev, | ||
655 | "Failed to create sysfs attributes, err: %d\n", error); | ||
656 | goto err_clear_drvdata; | ||
657 | } | ||
658 | |||
659 | error = input_register_device(ts->idev); | ||
660 | if (error) { | ||
661 | dev_err(&spi->dev, | ||
662 | "Failed to register input device, err: %d\n", error); | ||
663 | goto err_remove_sysfs; | ||
664 | } | ||
665 | |||
666 | set_irq_wake(spi->irq, 1); | ||
667 | return 0; | ||
668 | |||
669 | err_remove_sysfs: | ||
670 | sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group); | ||
671 | err_clear_drvdata: | ||
672 | spi_set_drvdata(spi, NULL); | ||
673 | free_irq(spi->irq, ts); | ||
674 | err_free_mem: | ||
675 | input_free_device(input_dev); | ||
676 | kfree(ts); | ||
677 | return error; | ||
678 | } | ||
679 | |||
680 | static int __devexit tsc2005_remove(struct spi_device *spi) | ||
681 | { | ||
682 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
683 | |||
684 | sysfs_remove_group(&ts->spi->dev.kobj, &tsc2005_attr_group); | ||
685 | |||
686 | free_irq(ts->spi->irq, ts); | ||
687 | input_unregister_device(ts->idev); | ||
688 | kfree(ts); | ||
689 | |||
690 | spi_set_drvdata(spi, NULL); | ||
691 | return 0; | ||
692 | } | ||
693 | |||
694 | #ifdef CONFIG_PM_SLEEP | ||
695 | static int tsc2005_suspend(struct device *dev) | ||
696 | { | ||
697 | struct spi_device *spi = to_spi_device(dev); | ||
698 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
699 | |||
700 | mutex_lock(&ts->mutex); | ||
701 | |||
702 | if (!ts->suspended && ts->opened) | ||
703 | __tsc2005_disable(ts); | ||
704 | |||
705 | ts->suspended = true; | ||
706 | |||
707 | mutex_unlock(&ts->mutex); | ||
708 | |||
709 | return 0; | ||
710 | } | ||
711 | |||
712 | static int tsc2005_resume(struct device *dev) | ||
713 | { | ||
714 | struct spi_device *spi = to_spi_device(dev); | ||
715 | struct tsc2005 *ts = spi_get_drvdata(spi); | ||
716 | |||
717 | mutex_lock(&ts->mutex); | ||
718 | |||
719 | if (ts->suspended && ts->opened) | ||
720 | __tsc2005_enable(ts); | ||
721 | |||
722 | ts->suspended = false; | ||
723 | |||
724 | mutex_unlock(&ts->mutex); | ||
725 | |||
726 | return 0; | ||
727 | } | ||
728 | #endif | ||
729 | |||
730 | static SIMPLE_DEV_PM_OPS(tsc2005_pm_ops, tsc2005_suspend, tsc2005_resume); | ||
731 | |||
732 | static struct spi_driver tsc2005_driver = { | ||
733 | .driver = { | ||
734 | .name = "tsc2005", | ||
735 | .owner = THIS_MODULE, | ||
736 | .pm = &tsc2005_pm_ops, | ||
737 | }, | ||
738 | .probe = tsc2005_probe, | ||
739 | .remove = __devexit_p(tsc2005_remove), | ||
740 | }; | ||
741 | |||
742 | static int __init tsc2005_init(void) | ||
743 | { | ||
744 | return spi_register_driver(&tsc2005_driver); | ||
745 | } | ||
746 | module_init(tsc2005_init); | ||
747 | |||
748 | static void __exit tsc2005_exit(void) | ||
749 | { | ||
750 | spi_unregister_driver(&tsc2005_driver); | ||
751 | } | ||
752 | module_exit(tsc2005_exit); | ||
753 | |||
754 | MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>"); | ||
755 | MODULE_DESCRIPTION("TSC2005 Touchscreen Driver"); | ||
756 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c new file mode 100644 index 000000000000..6ae054f8e0aa --- /dev/null +++ b/drivers/input/touchscreen/wm831x-ts.c | |||
@@ -0,0 +1,368 @@ | |||
1 | /* | ||
2 | * Touchscreen driver for WM831x PMICs | ||
3 | * | ||
4 | * Copyright 2011 Wolfson Microelectronics plc. | ||
5 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/pm.h> | ||
19 | #include <linux/input.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/mfd/wm831x/core.h> | ||
23 | #include <linux/mfd/wm831x/irq.h> | ||
24 | #include <linux/mfd/wm831x/pdata.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/types.h> | ||
28 | |||
29 | /* | ||
30 | * R16424 (0x4028) - Touch Control 1 | ||
31 | */ | ||
32 | #define WM831X_TCH_ENA 0x8000 /* TCH_ENA */ | ||
33 | #define WM831X_TCH_CVT_ENA 0x4000 /* TCH_CVT_ENA */ | ||
34 | #define WM831X_TCH_SLPENA 0x1000 /* TCH_SLPENA */ | ||
35 | #define WM831X_TCH_Z_ENA 0x0400 /* TCH_Z_ENA */ | ||
36 | #define WM831X_TCH_Y_ENA 0x0200 /* TCH_Y_ENA */ | ||
37 | #define WM831X_TCH_X_ENA 0x0100 /* TCH_X_ENA */ | ||
38 | #define WM831X_TCH_DELAY_MASK 0x00E0 /* TCH_DELAY - [7:5] */ | ||
39 | #define WM831X_TCH_DELAY_SHIFT 5 /* TCH_DELAY - [7:5] */ | ||
40 | #define WM831X_TCH_DELAY_WIDTH 3 /* TCH_DELAY - [7:5] */ | ||
41 | #define WM831X_TCH_RATE_MASK 0x001F /* TCH_RATE - [4:0] */ | ||
42 | #define WM831X_TCH_RATE_SHIFT 0 /* TCH_RATE - [4:0] */ | ||
43 | #define WM831X_TCH_RATE_WIDTH 5 /* TCH_RATE - [4:0] */ | ||
44 | |||
45 | /* | ||
46 | * R16425 (0x4029) - Touch Control 2 | ||
47 | */ | ||
48 | #define WM831X_TCH_PD_WK 0x2000 /* TCH_PD_WK */ | ||
49 | #define WM831X_TCH_5WIRE 0x1000 /* TCH_5WIRE */ | ||
50 | #define WM831X_TCH_PDONLY 0x0800 /* TCH_PDONLY */ | ||
51 | #define WM831X_TCH_ISEL 0x0100 /* TCH_ISEL */ | ||
52 | #define WM831X_TCH_RPU_MASK 0x000F /* TCH_RPU - [3:0] */ | ||
53 | #define WM831X_TCH_RPU_SHIFT 0 /* TCH_RPU - [3:0] */ | ||
54 | #define WM831X_TCH_RPU_WIDTH 4 /* TCH_RPU - [3:0] */ | ||
55 | |||
56 | /* | ||
57 | * R16426-8 (0x402A-C) - Touch Data X/Y/X | ||
58 | */ | ||
59 | #define WM831X_TCH_PD 0x8000 /* TCH_PD1 */ | ||
60 | #define WM831X_TCH_DATA_MASK 0x0FFF /* TCH_DATA - [11:0] */ | ||
61 | #define WM831X_TCH_DATA_SHIFT 0 /* TCH_DATA - [11:0] */ | ||
62 | #define WM831X_TCH_DATA_WIDTH 12 /* TCH_DATA - [11:0] */ | ||
63 | |||
64 | struct wm831x_ts { | ||
65 | struct input_dev *input_dev; | ||
66 | struct wm831x *wm831x; | ||
67 | unsigned int data_irq; | ||
68 | unsigned int pd_irq; | ||
69 | bool pressure; | ||
70 | bool pen_down; | ||
71 | }; | ||
72 | |||
73 | static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) | ||
74 | { | ||
75 | struct wm831x_ts *wm831x_ts = irq_data; | ||
76 | struct wm831x *wm831x = wm831x_ts->wm831x; | ||
77 | static int data_types[] = { ABS_X, ABS_Y, ABS_PRESSURE }; | ||
78 | u16 data[3]; | ||
79 | int count; | ||
80 | int i, ret; | ||
81 | |||
82 | if (wm831x_ts->pressure) | ||
83 | count = 3; | ||
84 | else | ||
85 | count = 2; | ||
86 | |||
87 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, | ||
88 | WM831X_TCHDATA_EINT, WM831X_TCHDATA_EINT); | ||
89 | |||
90 | ret = wm831x_bulk_read(wm831x, WM831X_TOUCH_DATA_X, count, | ||
91 | data); | ||
92 | if (ret != 0) { | ||
93 | dev_err(wm831x->dev, "Failed to read touch data: %d\n", | ||
94 | ret); | ||
95 | return IRQ_NONE; | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * We get a pen down reading on every reading, report pen up if any | ||
100 | * individual reading does so. | ||
101 | */ | ||
102 | wm831x_ts->pen_down = true; | ||
103 | for (i = 0; i < count; i++) { | ||
104 | if (!(data[i] & WM831X_TCH_PD)) { | ||
105 | wm831x_ts->pen_down = false; | ||
106 | continue; | ||
107 | } | ||
108 | input_report_abs(wm831x_ts->input_dev, data_types[i], | ||
109 | data[i] & WM831X_TCH_DATA_MASK); | ||
110 | } | ||
111 | |||
112 | if (!wm831x_ts->pen_down) { | ||
113 | disable_irq_nosync(wm831x_ts->data_irq); | ||
114 | |||
115 | /* Don't need data any more */ | ||
116 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
117 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | | ||
118 | WM831X_TCH_Z_ENA, 0); | ||
119 | |||
120 | /* Flush any final samples that arrived while reading */ | ||
121 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, | ||
122 | WM831X_TCHDATA_EINT, WM831X_TCHDATA_EINT); | ||
123 | |||
124 | wm831x_bulk_read(wm831x, WM831X_TOUCH_DATA_X, count, data); | ||
125 | |||
126 | if (wm831x_ts->pressure) | ||
127 | input_report_abs(wm831x_ts->input_dev, | ||
128 | ABS_PRESSURE, 0); | ||
129 | |||
130 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); | ||
131 | } | ||
132 | |||
133 | input_sync(wm831x_ts->input_dev); | ||
134 | |||
135 | return IRQ_HANDLED; | ||
136 | } | ||
137 | |||
138 | static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data) | ||
139 | { | ||
140 | struct wm831x_ts *wm831x_ts = irq_data; | ||
141 | struct wm831x *wm831x = wm831x_ts->wm831x; | ||
142 | int ena = 0; | ||
143 | |||
144 | /* Start collecting data */ | ||
145 | if (wm831x_ts->pressure) | ||
146 | ena |= WM831X_TCH_Z_ENA; | ||
147 | |||
148 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
149 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, | ||
150 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); | ||
151 | |||
152 | input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); | ||
153 | input_sync(wm831x_ts->input_dev); | ||
154 | |||
155 | wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, | ||
156 | WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); | ||
157 | |||
158 | wm831x_ts->pen_down = true; | ||
159 | enable_irq(wm831x_ts->data_irq); | ||
160 | |||
161 | return IRQ_HANDLED; | ||
162 | } | ||
163 | |||
164 | static int wm831x_ts_input_open(struct input_dev *idev) | ||
165 | { | ||
166 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); | ||
167 | struct wm831x *wm831x = wm831x_ts->wm831x; | ||
168 | |||
169 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
170 | WM831X_TCH_ENA | WM831X_TCH_CVT_ENA | | ||
171 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | | ||
172 | WM831X_TCH_Z_ENA, WM831X_TCH_ENA); | ||
173 | |||
174 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
175 | WM831X_TCH_CVT_ENA, WM831X_TCH_CVT_ENA); | ||
176 | |||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | static void wm831x_ts_input_close(struct input_dev *idev) | ||
181 | { | ||
182 | struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); | ||
183 | struct wm831x *wm831x = wm831x_ts->wm831x; | ||
184 | |||
185 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
186 | WM831X_TCH_ENA | WM831X_TCH_CVT_ENA | | ||
187 | WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | | ||
188 | WM831X_TCH_Z_ENA, 0); | ||
189 | |||
190 | if (wm831x_ts->pen_down) | ||
191 | disable_irq(wm831x_ts->data_irq); | ||
192 | } | ||
193 | |||
194 | static __devinit int wm831x_ts_probe(struct platform_device *pdev) | ||
195 | { | ||
196 | struct wm831x_ts *wm831x_ts; | ||
197 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); | ||
198 | struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); | ||
199 | struct wm831x_touch_pdata *pdata = NULL; | ||
200 | struct input_dev *input_dev; | ||
201 | int error; | ||
202 | |||
203 | if (core_pdata) | ||
204 | pdata = core_pdata->touch; | ||
205 | |||
206 | wm831x_ts = kzalloc(sizeof(struct wm831x_ts), GFP_KERNEL); | ||
207 | input_dev = input_allocate_device(); | ||
208 | if (!wm831x_ts || !input_dev) { | ||
209 | error = -ENOMEM; | ||
210 | goto err_alloc; | ||
211 | } | ||
212 | |||
213 | wm831x_ts->wm831x = wm831x; | ||
214 | wm831x_ts->input_dev = input_dev; | ||
215 | |||
216 | /* | ||
217 | * If we have a direct IRQ use it, otherwise use the interrupt | ||
218 | * from the WM831x IRQ controller. | ||
219 | */ | ||
220 | if (pdata && pdata->data_irq) | ||
221 | wm831x_ts->data_irq = pdata->data_irq; | ||
222 | else | ||
223 | wm831x_ts->data_irq = platform_get_irq_byname(pdev, "TCHDATA"); | ||
224 | |||
225 | if (pdata && pdata->pd_irq) | ||
226 | wm831x_ts->pd_irq = pdata->pd_irq; | ||
227 | else | ||
228 | wm831x_ts->pd_irq = platform_get_irq_byname(pdev, "TCHPD"); | ||
229 | |||
230 | if (pdata) | ||
231 | wm831x_ts->pressure = pdata->pressure; | ||
232 | else | ||
233 | wm831x_ts->pressure = true; | ||
234 | |||
235 | /* Five wire touchscreens can't report pressure */ | ||
236 | if (pdata && pdata->fivewire) { | ||
237 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2, | ||
238 | WM831X_TCH_5WIRE, WM831X_TCH_5WIRE); | ||
239 | |||
240 | /* Pressure measurements are not possible for five wire mode */ | ||
241 | WARN_ON(pdata->pressure && pdata->fivewire); | ||
242 | wm831x_ts->pressure = false; | ||
243 | } else { | ||
244 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2, | ||
245 | WM831X_TCH_5WIRE, 0); | ||
246 | } | ||
247 | |||
248 | if (pdata) { | ||
249 | switch (pdata->isel) { | ||
250 | default: | ||
251 | dev_err(&pdev->dev, "Unsupported ISEL setting: %d\n", | ||
252 | pdata->isel); | ||
253 | /* Fall through */ | ||
254 | case 200: | ||
255 | case 0: | ||
256 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2, | ||
257 | WM831X_TCH_ISEL, 0); | ||
258 | break; | ||
259 | case 400: | ||
260 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2, | ||
261 | WM831X_TCH_ISEL, WM831X_TCH_ISEL); | ||
262 | break; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2, | ||
267 | WM831X_TCH_PDONLY, 0); | ||
268 | |||
269 | /* Default to 96 samples/sec */ | ||
270 | wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, | ||
271 | WM831X_TCH_RATE_MASK, 6); | ||
272 | |||
273 | error = request_threaded_irq(wm831x_ts->data_irq, | ||
274 | NULL, wm831x_ts_data_irq, | ||
275 | IRQF_ONESHOT, | ||
276 | "Touchscreen data", wm831x_ts); | ||
277 | if (error) { | ||
278 | dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", | ||
279 | wm831x_ts->data_irq, error); | ||
280 | goto err_alloc; | ||
281 | } | ||
282 | disable_irq(wm831x_ts->data_irq); | ||
283 | |||
284 | error = request_threaded_irq(wm831x_ts->pd_irq, | ||
285 | NULL, wm831x_ts_pen_down_irq, | ||
286 | IRQF_ONESHOT, | ||
287 | "Touchscreen pen down", wm831x_ts); | ||
288 | if (error) { | ||
289 | dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", | ||
290 | wm831x_ts->pd_irq, error); | ||
291 | goto err_data_irq; | ||
292 | } | ||
293 | |||
294 | /* set up touch configuration */ | ||
295 | input_dev->name = "WM831x touchscreen"; | ||
296 | input_dev->phys = "wm831x"; | ||
297 | input_dev->open = wm831x_ts_input_open; | ||
298 | input_dev->close = wm831x_ts_input_close; | ||
299 | |||
300 | __set_bit(EV_ABS, input_dev->evbit); | ||
301 | __set_bit(EV_KEY, input_dev->evbit); | ||
302 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
303 | |||
304 | input_set_abs_params(input_dev, ABS_X, 0, 4095, 5, 0); | ||
305 | input_set_abs_params(input_dev, ABS_Y, 0, 4095, 5, 0); | ||
306 | if (wm831x_ts->pressure) | ||
307 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 4095, 5, 0); | ||
308 | |||
309 | input_set_drvdata(input_dev, wm831x_ts); | ||
310 | input_dev->dev.parent = &pdev->dev; | ||
311 | |||
312 | error = input_register_device(input_dev); | ||
313 | if (error) | ||
314 | goto err_pd_irq; | ||
315 | |||
316 | platform_set_drvdata(pdev, wm831x_ts); | ||
317 | return 0; | ||
318 | |||
319 | err_pd_irq: | ||
320 | free_irq(wm831x_ts->pd_irq, wm831x_ts); | ||
321 | err_data_irq: | ||
322 | free_irq(wm831x_ts->data_irq, wm831x_ts); | ||
323 | err_alloc: | ||
324 | input_free_device(input_dev); | ||
325 | kfree(wm831x_ts); | ||
326 | |||
327 | return error; | ||
328 | } | ||
329 | |||
330 | static __devexit int wm831x_ts_remove(struct platform_device *pdev) | ||
331 | { | ||
332 | struct wm831x_ts *wm831x_ts = platform_get_drvdata(pdev); | ||
333 | |||
334 | free_irq(wm831x_ts->pd_irq, wm831x_ts); | ||
335 | free_irq(wm831x_ts->data_irq, wm831x_ts); | ||
336 | input_unregister_device(wm831x_ts->input_dev); | ||
337 | kfree(wm831x_ts); | ||
338 | |||
339 | platform_set_drvdata(pdev, NULL); | ||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | static struct platform_driver wm831x_ts_driver = { | ||
344 | .driver = { | ||
345 | .name = "wm831x-touch", | ||
346 | .owner = THIS_MODULE, | ||
347 | }, | ||
348 | .probe = wm831x_ts_probe, | ||
349 | .remove = __devexit_p(wm831x_ts_remove), | ||
350 | }; | ||
351 | |||
352 | static int __init wm831x_ts_init(void) | ||
353 | { | ||
354 | return platform_driver_register(&wm831x_ts_driver); | ||
355 | } | ||
356 | module_init(wm831x_ts_init); | ||
357 | |||
358 | static void __exit wm831x_ts_exit(void) | ||
359 | { | ||
360 | platform_driver_unregister(&wm831x_ts_driver); | ||
361 | } | ||
362 | module_exit(wm831x_ts_exit); | ||
363 | |||
364 | /* Module information */ | ||
365 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
366 | MODULE_DESCRIPTION("WM831x PMIC touchscreen driver"); | ||
367 | MODULE_LICENSE("GPL"); | ||
368 | MODULE_ALIAS("platform:wm831x-touch"); | ||
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile index ab638b083df9..646368fe41c9 100644 --- a/drivers/isdn/hisax/Makefile +++ b/drivers/isdn/hisax/Makefile | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | # Define maximum number of cards | 5 | # Define maximum number of cards |
6 | 6 | ||
7 | EXTRA_CFLAGS += -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS) | 7 | ccflags-y := -DHISAX_MAX_CARDS=$(CONFIG_HISAX_MAX_CARDS) |
8 | 8 | ||
9 | obj-$(CONFIG_ISDN_DRV_HISAX) += hisax.o | 9 | obj-$(CONFIG_ISDN_DRV_HISAX) += hisax.o |
10 | obj-$(CONFIG_HISAX_SEDLBAUER_CS) += sedlbauer_cs.o | 10 | obj-$(CONFIG_HISAX_SEDLBAUER_CS) += sedlbauer_cs.o |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index 23005b3cf30b..b2b9415d874d 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c | |||
@@ -8,60 +8,71 @@ | |||
8 | #include "dvb-usb-common.h" | 8 | #include "dvb-usb-common.h" |
9 | #include <linux/usb/input.h> | 9 | #include <linux/usb/input.h> |
10 | 10 | ||
11 | static unsigned int | ||
12 | legacy_dvb_usb_get_keymap_index(const struct input_keymap_entry *ke, | ||
13 | struct rc_map_table *keymap, | ||
14 | unsigned int keymap_size) | ||
15 | { | ||
16 | unsigned int index; | ||
17 | unsigned int scancode; | ||
18 | |||
19 | if (ke->flags & INPUT_KEYMAP_BY_INDEX) { | ||
20 | index = ke->index; | ||
21 | } else { | ||
22 | if (input_scancode_to_scalar(ke, &scancode)) | ||
23 | return keymap_size; | ||
24 | |||
25 | /* See if we can match the raw key code. */ | ||
26 | for (index = 0; index < keymap_size; index++) | ||
27 | if (keymap[index].scancode == scancode) | ||
28 | break; | ||
29 | |||
30 | /* See if there is an unused hole in the map */ | ||
31 | if (index >= keymap_size) { | ||
32 | for (index = 0; index < keymap_size; index++) { | ||
33 | if (keymap[index].keycode == KEY_RESERVED || | ||
34 | keymap[index].keycode == KEY_UNKNOWN) { | ||
35 | break; | ||
36 | } | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | return index; | ||
42 | } | ||
43 | |||
11 | static int legacy_dvb_usb_getkeycode(struct input_dev *dev, | 44 | static int legacy_dvb_usb_getkeycode(struct input_dev *dev, |
12 | unsigned int scancode, unsigned int *keycode) | 45 | struct input_keymap_entry *ke) |
13 | { | 46 | { |
14 | struct dvb_usb_device *d = input_get_drvdata(dev); | 47 | struct dvb_usb_device *d = input_get_drvdata(dev); |
15 | |||
16 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; | 48 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; |
17 | int i; | 49 | unsigned int keymap_size = d->props.rc.legacy.rc_map_size; |
50 | unsigned int index; | ||
18 | 51 | ||
19 | /* See if we can match the raw key code. */ | 52 | index = legacy_dvb_usb_get_keymap_index(ke, keymap, keymap_size); |
20 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) | 53 | if (index >= keymap_size) |
21 | if (keymap[i].scancode == scancode) { | 54 | return -EINVAL; |
22 | *keycode = keymap[i].keycode; | ||
23 | return 0; | ||
24 | } | ||
25 | 55 | ||
26 | /* | 56 | ke->keycode = keymap[index].keycode; |
27 | * If is there extra space, returns KEY_RESERVED, | 57 | if (ke->keycode == KEY_UNKNOWN) |
28 | * otherwise, input core won't let legacy_dvb_usb_setkeycode | 58 | ke->keycode = KEY_RESERVED; |
29 | * to work | 59 | ke->len = sizeof(keymap[index].scancode); |
30 | */ | 60 | memcpy(&ke->scancode, &keymap[index].scancode, ke->len); |
31 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) | 61 | ke->index = index; |
32 | if (keymap[i].keycode == KEY_RESERVED || | ||
33 | keymap[i].keycode == KEY_UNKNOWN) { | ||
34 | *keycode = KEY_RESERVED; | ||
35 | return 0; | ||
36 | } | ||
37 | 62 | ||
38 | return -EINVAL; | 63 | return 0; |
39 | } | 64 | } |
40 | 65 | ||
41 | static int legacy_dvb_usb_setkeycode(struct input_dev *dev, | 66 | static int legacy_dvb_usb_setkeycode(struct input_dev *dev, |
42 | unsigned int scancode, unsigned int keycode) | 67 | const struct input_keymap_entry *ke, |
68 | unsigned int *old_keycode) | ||
43 | { | 69 | { |
44 | struct dvb_usb_device *d = input_get_drvdata(dev); | 70 | struct dvb_usb_device *d = input_get_drvdata(dev); |
45 | |||
46 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; | 71 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; |
47 | int i; | 72 | unsigned int keymap_size = d->props.rc.legacy.rc_map_size; |
48 | 73 | unsigned int index; | |
49 | /* Search if it is replacing an existing keycode */ | ||
50 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) | ||
51 | if (keymap[i].scancode == scancode) { | ||
52 | keymap[i].keycode = keycode; | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | /* Search if is there a clean entry. If so, use it */ | ||
57 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) | ||
58 | if (keymap[i].keycode == KEY_RESERVED || | ||
59 | keymap[i].keycode == KEY_UNKNOWN) { | ||
60 | keymap[i].scancode = scancode; | ||
61 | keymap[i].keycode = keycode; | ||
62 | return 0; | ||
63 | } | ||
64 | 74 | ||
75 | index = legacy_dvb_usb_get_keymap_index(ke, keymap, keymap_size); | ||
65 | /* | 76 | /* |
66 | * FIXME: Currently, it is not possible to increase the size of | 77 | * FIXME: Currently, it is not possible to increase the size of |
67 | * scancode table. For it to happen, one possibility | 78 | * scancode table. For it to happen, one possibility |
@@ -69,8 +80,24 @@ static int legacy_dvb_usb_setkeycode(struct input_dev *dev, | |||
69 | * copying data, appending the new key on it, and freeing | 80 | * copying data, appending the new key on it, and freeing |
70 | * the old one - or maybe just allocating some spare space | 81 | * the old one - or maybe just allocating some spare space |
71 | */ | 82 | */ |
83 | if (index >= keymap_size) | ||
84 | return -EINVAL; | ||
85 | |||
86 | *old_keycode = keymap[index].keycode; | ||
87 | keymap->keycode = ke->keycode; | ||
88 | __set_bit(ke->keycode, dev->keybit); | ||
89 | |||
90 | if (*old_keycode != KEY_RESERVED) { | ||
91 | __clear_bit(*old_keycode, dev->keybit); | ||
92 | for (index = 0; index < keymap_size; index++) { | ||
93 | if (keymap[index].keycode == *old_keycode) { | ||
94 | __set_bit(*old_keycode, dev->keybit); | ||
95 | break; | ||
96 | } | ||
97 | } | ||
98 | } | ||
72 | 99 | ||
73 | return -EINVAL; | 100 | return 0; |
74 | } | 101 | } |
75 | 102 | ||
76 | /* Remote-control poll function - called every dib->rc_query_interval ms to see | 103 | /* Remote-control poll function - called every dib->rc_query_interval ms to see |
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 5b4422ef4e6d..5ac1baf45c8e 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -966,8 +966,8 @@ struct rc_dev *rc_allocate_device(void) | |||
966 | return NULL; | 966 | return NULL; |
967 | } | 967 | } |
968 | 968 | ||
969 | dev->input_dev->getkeycode_new = ir_getkeycode; | 969 | dev->input_dev->getkeycode = ir_getkeycode; |
970 | dev->input_dev->setkeycode_new = ir_setkeycode; | 970 | dev->input_dev->setkeycode = ir_setkeycode; |
971 | input_set_drvdata(dev->input_dev, dev); | 971 | input_set_drvdata(dev->input_dev, dev); |
972 | 972 | ||
973 | spin_lock_init(&dev->rc_map.lock); | 973 | spin_lock_init(&dev->rc_map.lock); |
diff --git a/drivers/memstick/Makefile b/drivers/memstick/Makefile index dc160fb43515..98623590c7fe 100644 --- a/drivers/memstick/Makefile +++ b/drivers/memstick/Makefile | |||
@@ -2,9 +2,7 @@ | |||
2 | # Makefile for the kernel MemoryStick device drivers. | 2 | # Makefile for the kernel MemoryStick device drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | 5 | subdir-ccflags-$(CONFIG_MEMSTICK_DEBUG) := -DDEBUG |
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | 6 | ||
9 | obj-$(CONFIG_MEMSTICK) += core/ | 7 | obj-$(CONFIG_MEMSTICK) += core/ |
10 | obj-$(CONFIG_MEMSTICK) += host/ | 8 | obj-$(CONFIG_MEMSTICK) += host/ |
diff --git a/drivers/memstick/core/Makefile b/drivers/memstick/core/Makefile index 8b2b5293877e..ecd029937738 100644 --- a/drivers/memstick/core/Makefile +++ b/drivers/memstick/core/Makefile | |||
@@ -2,10 +2,6 @@ | |||
2 | # Makefile for the kernel MemoryStick core. | 2 | # Makefile for the kernel MemoryStick core. |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | obj-$(CONFIG_MEMSTICK) += memstick.o | 5 | obj-$(CONFIG_MEMSTICK) += memstick.o |
10 | 6 | ||
11 | obj-$(CONFIG_MSPRO_BLOCK) += mspro_block.o | 7 | obj-$(CONFIG_MSPRO_BLOCK) += mspro_block.o |
diff --git a/drivers/memstick/host/Makefile b/drivers/memstick/host/Makefile index 12530e4311d3..a1815e9dd019 100644 --- a/drivers/memstick/host/Makefile +++ b/drivers/memstick/host/Makefile | |||
@@ -2,9 +2,5 @@ | |||
2 | # Makefile for MemoryStick host controller drivers | 2 | # Makefile for MemoryStick host controller drivers |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_MEMSTICK_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | obj-$(CONFIG_MEMSTICK_TIFM_MS) += tifm_ms.o | 5 | obj-$(CONFIG_MEMSTICK_TIFM_MS) += tifm_ms.o |
10 | obj-$(CONFIG_MEMSTICK_JMICRON_38X) += jmb38x_ms.o | 6 | obj-$(CONFIG_MEMSTICK_JMICRON_38X) += jmb38x_ms.o |
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile index 95c9532cb07c..d182a24b3195 100644 --- a/drivers/message/fusion/Makefile +++ b/drivers/message/fusion/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | # enable verbose logging | 3 | # enable verbose logging |
4 | # CONFIG_FUSION_LOGGING needs to be enabled in Kconfig | 4 | # CONFIG_FUSION_LOGGING needs to be enabled in Kconfig |
5 | #EXTRA_CFLAGS += -DMPT_DEBUG_VERBOSE | 5 | #ccflags-y := -DMPT_DEBUG_VERBOSE |
6 | 6 | ||
7 | 7 | ||
8 | #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC | 8 | #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index b7d5ef234ac9..203500d9b848 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -2,6 +2,14 @@ | |||
2 | # Misc strange devices | 2 | # Misc strange devices |
3 | # | 3 | # |
4 | 4 | ||
5 | # This one has to live outside of the MISC_DEVICES conditional, | ||
6 | # because it may be selected by drivers/platform/x86/hp_accel. | ||
7 | config SENSORS_LIS3LV02D | ||
8 | tristate | ||
9 | depends on INPUT | ||
10 | select INPUT_POLLDEV | ||
11 | default n | ||
12 | |||
5 | menuconfig MISC_DEVICES | 13 | menuconfig MISC_DEVICES |
6 | bool "Misc devices" | 14 | bool "Misc devices" |
7 | ---help--- | 15 | ---help--- |
@@ -462,5 +470,6 @@ source "drivers/misc/eeprom/Kconfig" | |||
462 | source "drivers/misc/cb710/Kconfig" | 470 | source "drivers/misc/cb710/Kconfig" |
463 | source "drivers/misc/iwmc3200top/Kconfig" | 471 | source "drivers/misc/iwmc3200top/Kconfig" |
464 | source "drivers/misc/ti-st/Kconfig" | 472 | source "drivers/misc/ti-st/Kconfig" |
473 | source "drivers/misc/lis3lv02d/Kconfig" | ||
465 | 474 | ||
466 | endif # MISC_DEVICES | 475 | endif # MISC_DEVICES |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 98009cc20cb9..804f421bc079 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -42,3 +42,4 @@ obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o | |||
42 | obj-$(CONFIG_PCH_PHUB) += pch_phub.o | 42 | obj-$(CONFIG_PCH_PHUB) += pch_phub.o |
43 | obj-y += ti-st/ | 43 | obj-y += ti-st/ |
44 | obj-$(CONFIG_AB8500_PWM) += ab8500-pwm.o | 44 | obj-$(CONFIG_AB8500_PWM) += ab8500-pwm.o |
45 | obj-y += lis3lv02d/ | ||
diff --git a/drivers/misc/cb710/Makefile b/drivers/misc/cb710/Makefile index 7b80cbf1a609..467c8e9ca3c9 100644 --- a/drivers/misc/cb710/Makefile +++ b/drivers/misc/cb710/Makefile | |||
@@ -1,6 +1,4 @@ | |||
1 | ifeq ($(CONFIG_CB710_DEBUG),y) | 1 | ccflags-$(CONFIG_CB710_DEBUG) := -DDEBUG |
2 | EXTRA_CFLAGS += -DDEBUG | ||
3 | endif | ||
4 | 2 | ||
5 | obj-$(CONFIG_CB710_CORE) += cb710.o | 3 | obj-$(CONFIG_CB710_CORE) += cb710.o |
6 | 4 | ||
diff --git a/drivers/misc/lis3lv02d/Kconfig b/drivers/misc/lis3lv02d/Kconfig new file mode 100644 index 000000000000..8f474e6fc7b4 --- /dev/null +++ b/drivers/misc/lis3lv02d/Kconfig | |||
@@ -0,0 +1,37 @@ | |||
1 | # | ||
2 | # STMicroelectonics LIS3LV02D and similar accelerometers | ||
3 | # | ||
4 | |||
5 | config SENSORS_LIS3_SPI | ||
6 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (SPI)" | ||
7 | depends on !ACPI && SPI_MASTER && INPUT | ||
8 | select SENSORS_LIS3LV02D | ||
9 | default n | ||
10 | help | ||
11 | This driver provides support for the LIS3LV02Dx accelerometer connected | ||
12 | via SPI. The accelerometer data is readable via | ||
13 | /sys/devices/platform/lis3lv02d. | ||
14 | |||
15 | This driver also provides an absolute input class device, allowing | ||
16 | the laptop to act as a pinball machine-esque joystick. | ||
17 | |||
18 | This driver can also be built as modules. If so, the core module | ||
19 | will be called lis3lv02d and a specific module for the SPI transport | ||
20 | is called lis3lv02d_spi. | ||
21 | |||
22 | config SENSORS_LIS3_I2C | ||
23 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (I2C)" | ||
24 | depends on I2C && INPUT | ||
25 | select SENSORS_LIS3LV02D | ||
26 | default n | ||
27 | help | ||
28 | This driver provides support for the LIS3LV02Dx accelerometer connected | ||
29 | via I2C. The accelerometer data is readable via | ||
30 | /sys/devices/platform/lis3lv02d. | ||
31 | |||
32 | This driver also provides an absolute input class device, allowing | ||
33 | the device to act as a pinball machine-esque joystick. | ||
34 | |||
35 | This driver can also be built as modules. If so, the core module | ||
36 | will be called lis3lv02d and a specific module for the I2C transport | ||
37 | is called lis3lv02d_i2c. | ||
diff --git a/drivers/misc/lis3lv02d/Makefile b/drivers/misc/lis3lv02d/Makefile new file mode 100644 index 000000000000..4bf58b16fcf8 --- /dev/null +++ b/drivers/misc/lis3lv02d/Makefile | |||
@@ -0,0 +1,7 @@ | |||
1 | # | ||
2 | # STMicroelectonics LIS3LV02D and similar accelerometers | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o | ||
6 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d_spi.o | ||
7 | obj-$(CONFIG_SENSORS_LIS3_I2C) += lis3lv02d_i2c.o | ||
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c index d805e8e57967..b928bc14e97b 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/misc/lis3lv02d/lis3lv02d.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <linux/uaccess.h> | 38 | #include <linux/uaccess.h> |
39 | #include <linux/miscdevice.h> | 39 | #include <linux/miscdevice.h> |
40 | #include <linux/pm_runtime.h> | 40 | #include <linux/pm_runtime.h> |
41 | #include <asm/atomic.h> | 41 | #include <linux/atomic.h> |
42 | #include "lis3lv02d.h" | 42 | #include "lis3lv02d.h" |
43 | 43 | ||
44 | #define DRIVER_NAME "lis3lv02d" | 44 | #define DRIVER_NAME "lis3lv02d" |
@@ -88,7 +88,6 @@ | |||
88 | struct lis3lv02d lis3_dev = { | 88 | struct lis3lv02d lis3_dev = { |
89 | .misc_wait = __WAIT_QUEUE_HEAD_INITIALIZER(lis3_dev.misc_wait), | 89 | .misc_wait = __WAIT_QUEUE_HEAD_INITIALIZER(lis3_dev.misc_wait), |
90 | }; | 90 | }; |
91 | |||
92 | EXPORT_SYMBOL_GPL(lis3_dev); | 91 | EXPORT_SYMBOL_GPL(lis3_dev); |
93 | 92 | ||
94 | /* just like param_set_int() but does sanity-check so that it won't point | 93 | /* just like param_set_int() but does sanity-check so that it won't point |
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h index a1939589eb2c..a1939589eb2c 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/misc/lis3lv02d/lis3lv02d.h | |||
diff --git a/drivers/hwmon/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c index 8853afce85ce..b20dfb4522d2 100644 --- a/drivers/hwmon/lis3lv02d_i2c.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include "lis3lv02d.h" | 34 | #include "lis3lv02d.h" |
35 | 35 | ||
36 | #define DRV_NAME "lis3lv02d_i2c" | 36 | #define DRV_NAME "lis3lv02d_i2c" |
37 | 37 | ||
38 | static const char reg_vdd[] = "Vdd"; | 38 | static const char reg_vdd[] = "Vdd"; |
39 | static const char reg_vdd_io[] = "Vdd_IO"; | 39 | static const char reg_vdd_io[] = "Vdd_IO"; |
diff --git a/drivers/hwmon/lis3lv02d_spi.c b/drivers/misc/lis3lv02d/lis3lv02d_spi.c index c1f8a8fbf694..c1f8a8fbf694 100644 --- a/drivers/hwmon/lis3lv02d_spi.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_spi.c | |||
diff --git a/drivers/misc/sgi-gru/Makefile b/drivers/misc/sgi-gru/Makefile index 7c4c306dfa8a..0003a1d56f7f 100644 --- a/drivers/misc/sgi-gru/Makefile +++ b/drivers/misc/sgi-gru/Makefile | |||
@@ -1,6 +1,4 @@ | |||
1 | ifdef CONFIG_SGI_GRU_DEBUG | 1 | ccflags-$(CONFIG_SGI_GRU_DEBUG) := -DDEBUG |
2 | EXTRA_CFLAGS += -DDEBUG | ||
3 | endif | ||
4 | 2 | ||
5 | obj-$(CONFIG_SGI_GRU) := gru.o | 3 | obj-$(CONFIG_SGI_GRU) := gru.o |
6 | gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o gruhandles.o grukdump.o | 4 | gru-y := grufile.o grumain.o grufault.o grutlbpurge.o gruprocfs.o grukservices.o gruhandles.o grukdump.o |
diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig index 2a876c4099cd..3b1f783bf924 100644 --- a/drivers/mmc/card/Kconfig +++ b/drivers/mmc/card/Kconfig | |||
@@ -58,12 +58,11 @@ config SDIO_UART | |||
58 | 58 | ||
59 | config MMC_TEST | 59 | config MMC_TEST |
60 | tristate "MMC host test driver" | 60 | tristate "MMC host test driver" |
61 | default n | ||
62 | help | 61 | help |
63 | Development driver that performs a series of reads and writes | 62 | Development driver that performs a series of reads and writes |
64 | to a memory card in order to expose certain well known bugs | 63 | to a memory card in order to expose certain well known bugs |
65 | in host controllers. The tests are executed by writing to the | 64 | in host controllers. The tests are executed by writing to the |
66 | "test" file in sysfs under each card. Note that whatever is | 65 | "test" file in debugfs under each card. Note that whatever is |
67 | on your card will be overwritten by these tests. | 66 | on your card will be overwritten by these tests. |
68 | 67 | ||
69 | This driver is only of interest to those developing or | 68 | This driver is only of interest to those developing or |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index bfc8a8ae55df..61d233a7c118 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -621,6 +621,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) | |||
621 | md->disk->private_data = md; | 621 | md->disk->private_data = md; |
622 | md->disk->queue = md->queue.queue; | 622 | md->disk->queue = md->queue.queue; |
623 | md->disk->driverfs_dev = &card->dev; | 623 | md->disk->driverfs_dev = &card->dev; |
624 | set_disk_ro(md->disk, md->read_only); | ||
624 | 625 | ||
625 | /* | 626 | /* |
626 | * As discussed on lkml, GENHD_FL_REMOVABLE should: | 627 | * As discussed on lkml, GENHD_FL_REMOVABLE should: |
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 21adc27f4132..5ec8eddfcf6e 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c | |||
@@ -88,6 +88,7 @@ struct mmc_test_area { | |||
88 | * @sectors: amount of sectors to check in one group | 88 | * @sectors: amount of sectors to check in one group |
89 | * @ts: time values of transfer | 89 | * @ts: time values of transfer |
90 | * @rate: calculated transfer rate | 90 | * @rate: calculated transfer rate |
91 | * @iops: I/O operations per second (times 100) | ||
91 | */ | 92 | */ |
92 | struct mmc_test_transfer_result { | 93 | struct mmc_test_transfer_result { |
93 | struct list_head link; | 94 | struct list_head link; |
@@ -95,6 +96,7 @@ struct mmc_test_transfer_result { | |||
95 | unsigned int sectors; | 96 | unsigned int sectors; |
96 | struct timespec ts; | 97 | struct timespec ts; |
97 | unsigned int rate; | 98 | unsigned int rate; |
99 | unsigned int iops; | ||
98 | }; | 100 | }; |
99 | 101 | ||
100 | /** | 102 | /** |
@@ -226,9 +228,10 @@ static int mmc_test_wait_busy(struct mmc_test_card *test) | |||
226 | 228 | ||
227 | if (!busy && mmc_test_busy(&cmd)) { | 229 | if (!busy && mmc_test_busy(&cmd)) { |
228 | busy = 1; | 230 | busy = 1; |
229 | printk(KERN_INFO "%s: Warning: Host did not " | 231 | if (test->card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) |
230 | "wait for busy state to end.\n", | 232 | printk(KERN_INFO "%s: Warning: Host did not " |
231 | mmc_hostname(test->card->host)); | 233 | "wait for busy state to end.\n", |
234 | mmc_hostname(test->card->host)); | ||
232 | } | 235 | } |
233 | } while (mmc_test_busy(&cmd)); | 236 | } while (mmc_test_busy(&cmd)); |
234 | 237 | ||
@@ -494,7 +497,7 @@ static unsigned int mmc_test_rate(uint64_t bytes, struct timespec *ts) | |||
494 | */ | 497 | */ |
495 | static void mmc_test_save_transfer_result(struct mmc_test_card *test, | 498 | static void mmc_test_save_transfer_result(struct mmc_test_card *test, |
496 | unsigned int count, unsigned int sectors, struct timespec ts, | 499 | unsigned int count, unsigned int sectors, struct timespec ts, |
497 | unsigned int rate) | 500 | unsigned int rate, unsigned int iops) |
498 | { | 501 | { |
499 | struct mmc_test_transfer_result *tr; | 502 | struct mmc_test_transfer_result *tr; |
500 | 503 | ||
@@ -509,6 +512,7 @@ static void mmc_test_save_transfer_result(struct mmc_test_card *test, | |||
509 | tr->sectors = sectors; | 512 | tr->sectors = sectors; |
510 | tr->ts = ts; | 513 | tr->ts = ts; |
511 | tr->rate = rate; | 514 | tr->rate = rate; |
515 | tr->iops = iops; | ||
512 | 516 | ||
513 | list_add_tail(&tr->link, &test->gr->tr_lst); | 517 | list_add_tail(&tr->link, &test->gr->tr_lst); |
514 | } | 518 | } |
@@ -519,20 +523,22 @@ static void mmc_test_save_transfer_result(struct mmc_test_card *test, | |||
519 | static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, | 523 | static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, |
520 | struct timespec *ts1, struct timespec *ts2) | 524 | struct timespec *ts1, struct timespec *ts2) |
521 | { | 525 | { |
522 | unsigned int rate, sectors = bytes >> 9; | 526 | unsigned int rate, iops, sectors = bytes >> 9; |
523 | struct timespec ts; | 527 | struct timespec ts; |
524 | 528 | ||
525 | ts = timespec_sub(*ts2, *ts1); | 529 | ts = timespec_sub(*ts2, *ts1); |
526 | 530 | ||
527 | rate = mmc_test_rate(bytes, &ts); | 531 | rate = mmc_test_rate(bytes, &ts); |
532 | iops = mmc_test_rate(100, &ts); /* I/O ops per sec x 100 */ | ||
528 | 533 | ||
529 | printk(KERN_INFO "%s: Transfer of %u sectors (%u%s KiB) took %lu.%09lu " | 534 | printk(KERN_INFO "%s: Transfer of %u sectors (%u%s KiB) took %lu.%09lu " |
530 | "seconds (%u kB/s, %u KiB/s)\n", | 535 | "seconds (%u kB/s, %u KiB/s, %u.%02u IOPS)\n", |
531 | mmc_hostname(test->card->host), sectors, sectors >> 1, | 536 | mmc_hostname(test->card->host), sectors, sectors >> 1, |
532 | (sectors & 1 ? ".5" : ""), (unsigned long)ts.tv_sec, | 537 | (sectors & 1 ? ".5" : ""), (unsigned long)ts.tv_sec, |
533 | (unsigned long)ts.tv_nsec, rate / 1000, rate / 1024); | 538 | (unsigned long)ts.tv_nsec, rate / 1000, rate / 1024, |
539 | iops / 100, iops % 100); | ||
534 | 540 | ||
535 | mmc_test_save_transfer_result(test, 1, sectors, ts, rate); | 541 | mmc_test_save_transfer_result(test, 1, sectors, ts, rate, iops); |
536 | } | 542 | } |
537 | 543 | ||
538 | /* | 544 | /* |
@@ -542,22 +548,24 @@ static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes, | |||
542 | unsigned int count, struct timespec *ts1, | 548 | unsigned int count, struct timespec *ts1, |
543 | struct timespec *ts2) | 549 | struct timespec *ts2) |
544 | { | 550 | { |
545 | unsigned int rate, sectors = bytes >> 9; | 551 | unsigned int rate, iops, sectors = bytes >> 9; |
546 | uint64_t tot = bytes * count; | 552 | uint64_t tot = bytes * count; |
547 | struct timespec ts; | 553 | struct timespec ts; |
548 | 554 | ||
549 | ts = timespec_sub(*ts2, *ts1); | 555 | ts = timespec_sub(*ts2, *ts1); |
550 | 556 | ||
551 | rate = mmc_test_rate(tot, &ts); | 557 | rate = mmc_test_rate(tot, &ts); |
558 | iops = mmc_test_rate(count * 100, &ts); /* I/O ops per sec x 100 */ | ||
552 | 559 | ||
553 | printk(KERN_INFO "%s: Transfer of %u x %u sectors (%u x %u%s KiB) took " | 560 | printk(KERN_INFO "%s: Transfer of %u x %u sectors (%u x %u%s KiB) took " |
554 | "%lu.%09lu seconds (%u kB/s, %u KiB/s)\n", | 561 | "%lu.%09lu seconds (%u kB/s, %u KiB/s, " |
562 | "%u.%02u IOPS)\n", | ||
555 | mmc_hostname(test->card->host), count, sectors, count, | 563 | mmc_hostname(test->card->host), count, sectors, count, |
556 | sectors >> 1, (sectors & 1 ? ".5" : ""), | 564 | sectors >> 1, (sectors & 1 ? ".5" : ""), |
557 | (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec, | 565 | (unsigned long)ts.tv_sec, (unsigned long)ts.tv_nsec, |
558 | rate / 1000, rate / 1024); | 566 | rate / 1000, rate / 1024, iops / 100, iops % 100); |
559 | 567 | ||
560 | mmc_test_save_transfer_result(test, count, sectors, ts, rate); | 568 | mmc_test_save_transfer_result(test, count, sectors, ts, rate, iops); |
561 | } | 569 | } |
562 | 570 | ||
563 | /* | 571 | /* |
@@ -1425,28 +1433,29 @@ static int mmc_test_area_cleanup(struct mmc_test_card *test) | |||
1425 | } | 1433 | } |
1426 | 1434 | ||
1427 | /* | 1435 | /* |
1428 | * Initialize an area for testing large transfers. The size of the area is the | 1436 | * Initialize an area for testing large transfers. The test area is set to the |
1429 | * preferred erase size which is a good size for optimal transfer speed. Note | 1437 | * middle of the card because cards may have different charateristics at the |
1430 | * that is typically 4MiB for modern cards. The test area is set to the middle | 1438 | * front (for FAT file system optimization). Optionally, the area is erased |
1431 | * of the card because cards may have different charateristics at the front | 1439 | * (if the card supports it) which may improve write performance. Optionally, |
1432 | * (for FAT file system optimization). Optionally, the area is erased (if the | 1440 | * the area is filled with data for subsequent read tests. |
1433 | * card supports it) which may improve write performance. Optionally, the area | ||
1434 | * is filled with data for subsequent read tests. | ||
1435 | */ | 1441 | */ |
1436 | static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) | 1442 | static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) |
1437 | { | 1443 | { |
1438 | struct mmc_test_area *t = &test->area; | 1444 | struct mmc_test_area *t = &test->area; |
1439 | unsigned long min_sz = 64 * 1024; | 1445 | unsigned long min_sz = 64 * 1024, sz; |
1440 | int ret; | 1446 | int ret; |
1441 | 1447 | ||
1442 | ret = mmc_test_set_blksize(test, 512); | 1448 | ret = mmc_test_set_blksize(test, 512); |
1443 | if (ret) | 1449 | if (ret) |
1444 | return ret; | 1450 | return ret; |
1445 | 1451 | ||
1446 | if (test->card->pref_erase > TEST_AREA_MAX_SIZE >> 9) | 1452 | /* Make the test area size about 4MiB */ |
1447 | t->max_sz = TEST_AREA_MAX_SIZE; | 1453 | sz = (unsigned long)test->card->pref_erase << 9; |
1448 | else | 1454 | t->max_sz = sz; |
1449 | t->max_sz = (unsigned long)test->card->pref_erase << 9; | 1455 | while (t->max_sz < 4 * 1024 * 1024) |
1456 | t->max_sz += sz; | ||
1457 | while (t->max_sz > TEST_AREA_MAX_SIZE && t->max_sz > sz) | ||
1458 | t->max_sz -= sz; | ||
1450 | 1459 | ||
1451 | t->max_segs = test->card->host->max_segs; | 1460 | t->max_segs = test->card->host->max_segs; |
1452 | t->max_seg_sz = test->card->host->max_seg_size; | 1461 | t->max_seg_sz = test->card->host->max_seg_size; |
@@ -1766,6 +1775,188 @@ static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test) | |||
1766 | return 0; | 1775 | return 0; |
1767 | } | 1776 | } |
1768 | 1777 | ||
1778 | static unsigned int rnd_next = 1; | ||
1779 | |||
1780 | static unsigned int mmc_test_rnd_num(unsigned int rnd_cnt) | ||
1781 | { | ||
1782 | uint64_t r; | ||
1783 | |||
1784 | rnd_next = rnd_next * 1103515245 + 12345; | ||
1785 | r = (rnd_next >> 16) & 0x7fff; | ||
1786 | return (r * rnd_cnt) >> 15; | ||
1787 | } | ||
1788 | |||
1789 | static int mmc_test_rnd_perf(struct mmc_test_card *test, int write, int print, | ||
1790 | unsigned long sz) | ||
1791 | { | ||
1792 | unsigned int dev_addr, cnt, rnd_addr, range1, range2, last_ea = 0, ea; | ||
1793 | unsigned int ssz; | ||
1794 | struct timespec ts1, ts2, ts; | ||
1795 | int ret; | ||
1796 | |||
1797 | ssz = sz >> 9; | ||
1798 | |||
1799 | rnd_addr = mmc_test_capacity(test->card) / 4; | ||
1800 | range1 = rnd_addr / test->card->pref_erase; | ||
1801 | range2 = range1 / ssz; | ||
1802 | |||
1803 | getnstimeofday(&ts1); | ||
1804 | for (cnt = 0; cnt < UINT_MAX; cnt++) { | ||
1805 | getnstimeofday(&ts2); | ||
1806 | ts = timespec_sub(ts2, ts1); | ||
1807 | if (ts.tv_sec >= 10) | ||
1808 | break; | ||
1809 | ea = mmc_test_rnd_num(range1); | ||
1810 | if (ea == last_ea) | ||
1811 | ea -= 1; | ||
1812 | last_ea = ea; | ||
1813 | dev_addr = rnd_addr + test->card->pref_erase * ea + | ||
1814 | ssz * mmc_test_rnd_num(range2); | ||
1815 | ret = mmc_test_area_io(test, sz, dev_addr, write, 0, 0); | ||
1816 | if (ret) | ||
1817 | return ret; | ||
1818 | } | ||
1819 | if (print) | ||
1820 | mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); | ||
1821 | return 0; | ||
1822 | } | ||
1823 | |||
1824 | static int mmc_test_random_perf(struct mmc_test_card *test, int write) | ||
1825 | { | ||
1826 | unsigned int next; | ||
1827 | unsigned long sz; | ||
1828 | int ret; | ||
1829 | |||
1830 | for (sz = 512; sz < test->area.max_tfr; sz <<= 1) { | ||
1831 | /* | ||
1832 | * When writing, try to get more consistent results by running | ||
1833 | * the test twice with exactly the same I/O but outputting the | ||
1834 | * results only for the 2nd run. | ||
1835 | */ | ||
1836 | if (write) { | ||
1837 | next = rnd_next; | ||
1838 | ret = mmc_test_rnd_perf(test, write, 0, sz); | ||
1839 | if (ret) | ||
1840 | return ret; | ||
1841 | rnd_next = next; | ||
1842 | } | ||
1843 | ret = mmc_test_rnd_perf(test, write, 1, sz); | ||
1844 | if (ret) | ||
1845 | return ret; | ||
1846 | } | ||
1847 | sz = test->area.max_tfr; | ||
1848 | if (write) { | ||
1849 | next = rnd_next; | ||
1850 | ret = mmc_test_rnd_perf(test, write, 0, sz); | ||
1851 | if (ret) | ||
1852 | return ret; | ||
1853 | rnd_next = next; | ||
1854 | } | ||
1855 | return mmc_test_rnd_perf(test, write, 1, sz); | ||
1856 | } | ||
1857 | |||
1858 | /* | ||
1859 | * Random read performance by transfer size. | ||
1860 | */ | ||
1861 | static int mmc_test_random_read_perf(struct mmc_test_card *test) | ||
1862 | { | ||
1863 | return mmc_test_random_perf(test, 0); | ||
1864 | } | ||
1865 | |||
1866 | /* | ||
1867 | * Random write performance by transfer size. | ||
1868 | */ | ||
1869 | static int mmc_test_random_write_perf(struct mmc_test_card *test) | ||
1870 | { | ||
1871 | return mmc_test_random_perf(test, 1); | ||
1872 | } | ||
1873 | |||
1874 | static int mmc_test_seq_perf(struct mmc_test_card *test, int write, | ||
1875 | unsigned int tot_sz, int max_scatter) | ||
1876 | { | ||
1877 | unsigned int dev_addr, i, cnt, sz, ssz; | ||
1878 | struct timespec ts1, ts2, ts; | ||
1879 | int ret; | ||
1880 | |||
1881 | sz = test->area.max_tfr; | ||
1882 | /* | ||
1883 | * In the case of a maximally scattered transfer, the maximum transfer | ||
1884 | * size is further limited by using PAGE_SIZE segments. | ||
1885 | */ | ||
1886 | if (max_scatter) { | ||
1887 | struct mmc_test_area *t = &test->area; | ||
1888 | unsigned long max_tfr; | ||
1889 | |||
1890 | if (t->max_seg_sz >= PAGE_SIZE) | ||
1891 | max_tfr = t->max_segs * PAGE_SIZE; | ||
1892 | else | ||
1893 | max_tfr = t->max_segs * t->max_seg_sz; | ||
1894 | if (sz > max_tfr) | ||
1895 | sz = max_tfr; | ||
1896 | } | ||
1897 | |||
1898 | ssz = sz >> 9; | ||
1899 | dev_addr = mmc_test_capacity(test->card) / 4; | ||
1900 | if (tot_sz > dev_addr << 9) | ||
1901 | tot_sz = dev_addr << 9; | ||
1902 | cnt = tot_sz / sz; | ||
1903 | dev_addr &= 0xffff0000; /* Round to 64MiB boundary */ | ||
1904 | |||
1905 | getnstimeofday(&ts1); | ||
1906 | for (i = 0; i < cnt; i++) { | ||
1907 | ret = mmc_test_area_io(test, sz, dev_addr, write, | ||
1908 | max_scatter, 0); | ||
1909 | if (ret) | ||
1910 | return ret; | ||
1911 | dev_addr += ssz; | ||
1912 | } | ||
1913 | getnstimeofday(&ts2); | ||
1914 | |||
1915 | ts = timespec_sub(ts2, ts1); | ||
1916 | mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); | ||
1917 | |||
1918 | return 0; | ||
1919 | } | ||
1920 | |||
1921 | static int mmc_test_large_seq_perf(struct mmc_test_card *test, int write) | ||
1922 | { | ||
1923 | int ret, i; | ||
1924 | |||
1925 | for (i = 0; i < 10; i++) { | ||
1926 | ret = mmc_test_seq_perf(test, write, 10 * 1024 * 1024, 1); | ||
1927 | if (ret) | ||
1928 | return ret; | ||
1929 | } | ||
1930 | for (i = 0; i < 5; i++) { | ||
1931 | ret = mmc_test_seq_perf(test, write, 100 * 1024 * 1024, 1); | ||
1932 | if (ret) | ||
1933 | return ret; | ||
1934 | } | ||
1935 | for (i = 0; i < 3; i++) { | ||
1936 | ret = mmc_test_seq_perf(test, write, 1000 * 1024 * 1024, 1); | ||
1937 | if (ret) | ||
1938 | return ret; | ||
1939 | } | ||
1940 | |||
1941 | return ret; | ||
1942 | } | ||
1943 | |||
1944 | /* | ||
1945 | * Large sequential read performance. | ||
1946 | */ | ||
1947 | static int mmc_test_large_seq_read_perf(struct mmc_test_card *test) | ||
1948 | { | ||
1949 | return mmc_test_large_seq_perf(test, 0); | ||
1950 | } | ||
1951 | |||
1952 | /* | ||
1953 | * Large sequential write performance. | ||
1954 | */ | ||
1955 | static int mmc_test_large_seq_write_perf(struct mmc_test_card *test) | ||
1956 | { | ||
1957 | return mmc_test_large_seq_perf(test, 1); | ||
1958 | } | ||
1959 | |||
1769 | static const struct mmc_test_case mmc_test_cases[] = { | 1960 | static const struct mmc_test_case mmc_test_cases[] = { |
1770 | { | 1961 | { |
1771 | .name = "Basic write (no data verification)", | 1962 | .name = "Basic write (no data verification)", |
@@ -2005,6 +2196,34 @@ static const struct mmc_test_case mmc_test_cases[] = { | |||
2005 | .cleanup = mmc_test_area_cleanup, | 2196 | .cleanup = mmc_test_area_cleanup, |
2006 | }, | 2197 | }, |
2007 | 2198 | ||
2199 | { | ||
2200 | .name = "Random read performance by transfer size", | ||
2201 | .prepare = mmc_test_area_prepare, | ||
2202 | .run = mmc_test_random_read_perf, | ||
2203 | .cleanup = mmc_test_area_cleanup, | ||
2204 | }, | ||
2205 | |||
2206 | { | ||
2207 | .name = "Random write performance by transfer size", | ||
2208 | .prepare = mmc_test_area_prepare, | ||
2209 | .run = mmc_test_random_write_perf, | ||
2210 | .cleanup = mmc_test_area_cleanup, | ||
2211 | }, | ||
2212 | |||
2213 | { | ||
2214 | .name = "Large sequential read into scattered pages", | ||
2215 | .prepare = mmc_test_area_prepare, | ||
2216 | .run = mmc_test_large_seq_read_perf, | ||
2217 | .cleanup = mmc_test_area_cleanup, | ||
2218 | }, | ||
2219 | |||
2220 | { | ||
2221 | .name = "Large sequential write from scattered pages", | ||
2222 | .prepare = mmc_test_area_prepare, | ||
2223 | .run = mmc_test_large_seq_write_perf, | ||
2224 | .cleanup = mmc_test_area_cleanup, | ||
2225 | }, | ||
2226 | |||
2008 | }; | 2227 | }; |
2009 | 2228 | ||
2010 | static DEFINE_MUTEX(mmc_test_lock); | 2229 | static DEFINE_MUTEX(mmc_test_lock); |
@@ -2148,11 +2367,11 @@ static int mtf_test_show(struct seq_file *sf, void *data) | |||
2148 | seq_printf(sf, "Test %d: %d\n", gr->testcase + 1, gr->result); | 2367 | seq_printf(sf, "Test %d: %d\n", gr->testcase + 1, gr->result); |
2149 | 2368 | ||
2150 | list_for_each_entry(tr, &gr->tr_lst, link) { | 2369 | list_for_each_entry(tr, &gr->tr_lst, link) { |
2151 | seq_printf(sf, "%u %d %lu.%09lu %u\n", | 2370 | seq_printf(sf, "%u %d %lu.%09lu %u %u.%02u\n", |
2152 | tr->count, tr->sectors, | 2371 | tr->count, tr->sectors, |
2153 | (unsigned long)tr->ts.tv_sec, | 2372 | (unsigned long)tr->ts.tv_sec, |
2154 | (unsigned long)tr->ts.tv_nsec, | 2373 | (unsigned long)tr->ts.tv_nsec, |
2155 | tr->rate); | 2374 | tr->rate, tr->iops / 100, tr->iops % 100); |
2156 | } | 2375 | } |
2157 | } | 2376 | } |
2158 | 2377 | ||
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile index 86b479119332..639501970b41 100644 --- a/drivers/mmc/core/Makefile +++ b/drivers/mmc/core/Makefile | |||
@@ -6,6 +6,7 @@ obj-$(CONFIG_MMC) += mmc_core.o | |||
6 | mmc_core-y := core.o bus.o host.o \ | 6 | mmc_core-y := core.o bus.o host.o \ |
7 | mmc.o mmc_ops.o sd.o sd_ops.o \ | 7 | mmc.o mmc_ops.o sd.o sd_ops.o \ |
8 | sdio.o sdio_ops.o sdio_bus.o \ | 8 | sdio.o sdio_ops.o sdio_bus.o \ |
9 | sdio_cis.o sdio_io.o sdio_irq.o | 9 | sdio_cis.o sdio_io.o sdio_irq.o \ |
10 | quirks.o | ||
10 | 11 | ||
11 | mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o | 12 | mmc_core-$(CONFIG_DEBUG_FS) += debugfs.o |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 150b5f3cd401..1f453acc8682 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -167,8 +167,6 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
167 | 167 | ||
168 | WARN_ON(!host->claimed); | 168 | WARN_ON(!host->claimed); |
169 | 169 | ||
170 | led_trigger_event(host->led, LED_FULL); | ||
171 | |||
172 | mrq->cmd->error = 0; | 170 | mrq->cmd->error = 0; |
173 | mrq->cmd->mrq = mrq; | 171 | mrq->cmd->mrq = mrq; |
174 | if (mrq->data) { | 172 | if (mrq->data) { |
@@ -194,6 +192,7 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
194 | } | 192 | } |
195 | } | 193 | } |
196 | mmc_host_clk_ungate(host); | 194 | mmc_host_clk_ungate(host); |
195 | led_trigger_event(host->led, LED_FULL); | ||
197 | host->ops->request(host, mrq); | 196 | host->ops->request(host, mrq); |
198 | } | 197 | } |
199 | 198 | ||
@@ -528,7 +527,14 @@ int mmc_try_claim_host(struct mmc_host *host) | |||
528 | } | 527 | } |
529 | EXPORT_SYMBOL(mmc_try_claim_host); | 528 | EXPORT_SYMBOL(mmc_try_claim_host); |
530 | 529 | ||
531 | static void mmc_do_release_host(struct mmc_host *host) | 530 | /** |
531 | * mmc_do_release_host - release a claimed host | ||
532 | * @host: mmc host to release | ||
533 | * | ||
534 | * If you successfully claimed a host, this function will | ||
535 | * release it again. | ||
536 | */ | ||
537 | void mmc_do_release_host(struct mmc_host *host) | ||
532 | { | 538 | { |
533 | unsigned long flags; | 539 | unsigned long flags; |
534 | 540 | ||
@@ -543,6 +549,7 @@ static void mmc_do_release_host(struct mmc_host *host) | |||
543 | wake_up(&host->wq); | 549 | wake_up(&host->wq); |
544 | } | 550 | } |
545 | } | 551 | } |
552 | EXPORT_SYMBOL(mmc_do_release_host); | ||
546 | 553 | ||
547 | void mmc_host_deeper_disable(struct work_struct *work) | 554 | void mmc_host_deeper_disable(struct work_struct *work) |
548 | { | 555 | { |
@@ -1002,6 +1009,13 @@ static void mmc_power_off(struct mmc_host *host) | |||
1002 | { | 1009 | { |
1003 | host->ios.clock = 0; | 1010 | host->ios.clock = 0; |
1004 | host->ios.vdd = 0; | 1011 | host->ios.vdd = 0; |
1012 | |||
1013 | /* | ||
1014 | * Reset ocr mask to be the highest possible voltage supported for | ||
1015 | * this mmc host. This value will be used at next power up. | ||
1016 | */ | ||
1017 | host->ocr = 1 << (fls(host->ocr_avail) - 1); | ||
1018 | |||
1005 | if (!mmc_host_is_spi(host)) { | 1019 | if (!mmc_host_is_spi(host)) { |
1006 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | 1020 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; |
1007 | host->ios.chip_select = MMC_CS_DONTCARE; | 1021 | host->ios.chip_select = MMC_CS_DONTCARE; |
@@ -1495,6 +1509,12 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) | |||
1495 | mmc_hostname(host), __func__, host->f_init); | 1509 | mmc_hostname(host), __func__, host->f_init); |
1496 | #endif | 1510 | #endif |
1497 | mmc_power_up(host); | 1511 | mmc_power_up(host); |
1512 | |||
1513 | /* | ||
1514 | * sdio_reset sends CMD52 to reset card. Since we do not know | ||
1515 | * if the card is being re-initialized, just send it. CMD52 | ||
1516 | * should be ignored by SD/eMMC cards. | ||
1517 | */ | ||
1498 | sdio_reset(host); | 1518 | sdio_reset(host); |
1499 | mmc_go_idle(host); | 1519 | mmc_go_idle(host); |
1500 | 1520 | ||
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index ca1fdde29df6..20b1c0831eac 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h | |||
@@ -61,6 +61,8 @@ int mmc_attach_mmc(struct mmc_host *host); | |||
61 | int mmc_attach_sd(struct mmc_host *host); | 61 | int mmc_attach_sd(struct mmc_host *host); |
62 | int mmc_attach_sdio(struct mmc_host *host); | 62 | int mmc_attach_sdio(struct mmc_host *host); |
63 | 63 | ||
64 | void mmc_fixup_device(struct mmc_card *card); | ||
65 | |||
64 | /* Module parameters */ | 66 | /* Module parameters */ |
65 | extern int use_spi_crc; | 67 | extern int use_spi_crc; |
66 | 68 | ||
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index b3ac6c5bc5c6..461e6a17fb90 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -160,10 +160,7 @@ static bool mmc_host_may_gate_card(struct mmc_card *card) | |||
160 | * gate the clock, because there is somebody out there that may still | 160 | * gate the clock, because there is somebody out there that may still |
161 | * be using it. | 161 | * be using it. |
162 | */ | 162 | */ |
163 | if (mmc_card_sdio(card)) | 163 | return !(card->quirks & MMC_QUIRK_BROKEN_CLK_GATING); |
164 | return false; | ||
165 | |||
166 | return true; | ||
167 | } | 164 | } |
168 | 165 | ||
169 | /** | 166 | /** |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 16006ef153fe..14e95f39a7bf 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -302,6 +302,44 @@ static int mmc_read_ext_csd(struct mmc_card *card) | |||
302 | } | 302 | } |
303 | 303 | ||
304 | if (card->ext_csd.rev >= 4) { | 304 | if (card->ext_csd.rev >= 4) { |
305 | /* | ||
306 | * Enhanced area feature support -- check whether the eMMC | ||
307 | * card has the Enhanced area enabled. If so, export enhanced | ||
308 | * area offset and size to user by adding sysfs interface. | ||
309 | */ | ||
310 | if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) && | ||
311 | (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) { | ||
312 | u8 hc_erase_grp_sz = | ||
313 | ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; | ||
314 | u8 hc_wp_grp_sz = | ||
315 | ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; | ||
316 | |||
317 | card->ext_csd.enhanced_area_en = 1; | ||
318 | /* | ||
319 | * calculate the enhanced data area offset, in bytes | ||
320 | */ | ||
321 | card->ext_csd.enhanced_area_offset = | ||
322 | (ext_csd[139] << 24) + (ext_csd[138] << 16) + | ||
323 | (ext_csd[137] << 8) + ext_csd[136]; | ||
324 | if (mmc_card_blockaddr(card)) | ||
325 | card->ext_csd.enhanced_area_offset <<= 9; | ||
326 | /* | ||
327 | * calculate the enhanced data area size, in kilobytes | ||
328 | */ | ||
329 | card->ext_csd.enhanced_area_size = | ||
330 | (ext_csd[142] << 16) + (ext_csd[141] << 8) + | ||
331 | ext_csd[140]; | ||
332 | card->ext_csd.enhanced_area_size *= | ||
333 | (size_t)(hc_erase_grp_sz * hc_wp_grp_sz); | ||
334 | card->ext_csd.enhanced_area_size <<= 9; | ||
335 | } else { | ||
336 | /* | ||
337 | * If the enhanced area is not enabled, disable these | ||
338 | * device attributes. | ||
339 | */ | ||
340 | card->ext_csd.enhanced_area_offset = -EINVAL; | ||
341 | card->ext_csd.enhanced_area_size = -EINVAL; | ||
342 | } | ||
305 | card->ext_csd.sec_trim_mult = | 343 | card->ext_csd.sec_trim_mult = |
306 | ext_csd[EXT_CSD_SEC_TRIM_MULT]; | 344 | ext_csd[EXT_CSD_SEC_TRIM_MULT]; |
307 | card->ext_csd.sec_erase_mult = | 345 | card->ext_csd.sec_erase_mult = |
@@ -336,6 +374,9 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); | |||
336 | MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); | 374 | MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); |
337 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); | 375 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); |
338 | MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); | 376 | MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); |
377 | MMC_DEV_ATTR(enhanced_area_offset, "%llu\n", | ||
378 | card->ext_csd.enhanced_area_offset); | ||
379 | MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size); | ||
339 | 380 | ||
340 | static struct attribute *mmc_std_attrs[] = { | 381 | static struct attribute *mmc_std_attrs[] = { |
341 | &dev_attr_cid.attr, | 382 | &dev_attr_cid.attr, |
@@ -349,6 +390,8 @@ static struct attribute *mmc_std_attrs[] = { | |||
349 | &dev_attr_name.attr, | 390 | &dev_attr_name.attr, |
350 | &dev_attr_oemid.attr, | 391 | &dev_attr_oemid.attr, |
351 | &dev_attr_serial.attr, | 392 | &dev_attr_serial.attr, |
393 | &dev_attr_enhanced_area_offset.attr, | ||
394 | &dev_attr_enhanced_area_size.attr, | ||
352 | NULL, | 395 | NULL, |
353 | }; | 396 | }; |
354 | 397 | ||
@@ -378,6 +421,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
378 | int err, ddr = 0; | 421 | int err, ddr = 0; |
379 | u32 cid[4]; | 422 | u32 cid[4]; |
380 | unsigned int max_dtr; | 423 | unsigned int max_dtr; |
424 | u32 rocr; | ||
381 | 425 | ||
382 | BUG_ON(!host); | 426 | BUG_ON(!host); |
383 | WARN_ON(!host->claimed); | 427 | WARN_ON(!host->claimed); |
@@ -391,7 +435,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
391 | mmc_go_idle(host); | 435 | mmc_go_idle(host); |
392 | 436 | ||
393 | /* The extra bit indicates that we support high capacity */ | 437 | /* The extra bit indicates that we support high capacity */ |
394 | err = mmc_send_op_cond(host, ocr | (1 << 30), NULL); | 438 | err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr); |
395 | if (err) | 439 | if (err) |
396 | goto err; | 440 | goto err; |
397 | 441 | ||
@@ -479,11 +523,51 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
479 | err = mmc_read_ext_csd(card); | 523 | err = mmc_read_ext_csd(card); |
480 | if (err) | 524 | if (err) |
481 | goto free_card; | 525 | goto free_card; |
526 | |||
527 | /* If doing byte addressing, check if required to do sector | ||
528 | * addressing. Handle the case of <2GB cards needing sector | ||
529 | * addressing. See section 8.1 JEDEC Standard JED84-A441; | ||
530 | * ocr register has bit 30 set for sector addressing. | ||
531 | */ | ||
532 | if (!(mmc_card_blockaddr(card)) && (rocr & (1<<30))) | ||
533 | mmc_card_set_blockaddr(card); | ||
534 | |||
482 | /* Erase size depends on CSD and Extended CSD */ | 535 | /* Erase size depends on CSD and Extended CSD */ |
483 | mmc_set_erase_size(card); | 536 | mmc_set_erase_size(card); |
484 | } | 537 | } |
485 | 538 | ||
486 | /* | 539 | /* |
540 | * If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF | ||
541 | * bit. This bit will be lost everytime after a reset or power off. | ||
542 | */ | ||
543 | if (card->ext_csd.enhanced_area_en) { | ||
544 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
545 | EXT_CSD_ERASE_GROUP_DEF, 1); | ||
546 | |||
547 | if (err && err != -EBADMSG) | ||
548 | goto free_card; | ||
549 | |||
550 | if (err) { | ||
551 | err = 0; | ||
552 | /* | ||
553 | * Just disable enhanced area off & sz | ||
554 | * will try to enable ERASE_GROUP_DEF | ||
555 | * during next time reinit | ||
556 | */ | ||
557 | card->ext_csd.enhanced_area_offset = -EINVAL; | ||
558 | card->ext_csd.enhanced_area_size = -EINVAL; | ||
559 | } else { | ||
560 | card->ext_csd.erase_group_def = 1; | ||
561 | /* | ||
562 | * enable ERASE_GRP_DEF successfully. | ||
563 | * This will affect the erase size, so | ||
564 | * here need to reset erase size | ||
565 | */ | ||
566 | mmc_set_erase_size(card); | ||
567 | } | ||
568 | } | ||
569 | |||
570 | /* | ||
487 | * Activate high speed (if supported) | 571 | * Activate high speed (if supported) |
488 | */ | 572 | */ |
489 | if ((card->ext_csd.hs_max_dtr != 0) && | 573 | if ((card->ext_csd.hs_max_dtr != 0) && |
diff --git a/drivers/mmc/core/quirks.c b/drivers/mmc/core/quirks.c new file mode 100644 index 000000000000..11118b74eb20 --- /dev/null +++ b/drivers/mmc/core/quirks.c | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * This file contains work-arounds for many known sdio hardware | ||
3 | * bugs. | ||
4 | * | ||
5 | * Copyright (c) 2011 Pierre Tardy <tardyp@gmail.com> | ||
6 | * Inspired from pci fixup code: | ||
7 | * Copyright (c) 1999 Martin Mares <mj@ucw.cz> | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #include <linux/types.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/mmc/card.h> | ||
14 | #include <linux/mod_devicetable.h> | ||
15 | |||
16 | /* | ||
17 | * The world is not perfect and supplies us with broken mmc/sdio devices. | ||
18 | * For at least a part of these bugs we need a work-around | ||
19 | */ | ||
20 | |||
21 | struct mmc_fixup { | ||
22 | u16 vendor, device; /* You can use SDIO_ANY_ID here of course */ | ||
23 | void (*vendor_fixup)(struct mmc_card *card, int data); | ||
24 | int data; | ||
25 | }; | ||
26 | |||
27 | /* | ||
28 | * This hook just adds a quirk unconditionnally | ||
29 | */ | ||
30 | static void __maybe_unused add_quirk(struct mmc_card *card, int data) | ||
31 | { | ||
32 | card->quirks |= data; | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * This hook just removes a quirk unconditionnally | ||
37 | */ | ||
38 | static void __maybe_unused remove_quirk(struct mmc_card *card, int data) | ||
39 | { | ||
40 | card->quirks &= ~data; | ||
41 | } | ||
42 | |||
43 | /* | ||
44 | * This hook just adds a quirk for all sdio devices | ||
45 | */ | ||
46 | static void add_quirk_for_sdio_devices(struct mmc_card *card, int data) | ||
47 | { | ||
48 | if (mmc_card_sdio(card)) | ||
49 | card->quirks |= data; | ||
50 | } | ||
51 | |||
52 | #ifndef SDIO_VENDOR_ID_TI | ||
53 | #define SDIO_VENDOR_ID_TI 0x0097 | ||
54 | #endif | ||
55 | |||
56 | #ifndef SDIO_DEVICE_ID_TI_WL1271 | ||
57 | #define SDIO_DEVICE_ID_TI_WL1271 0x4076 | ||
58 | #endif | ||
59 | |||
60 | static const struct mmc_fixup mmc_fixup_methods[] = { | ||
61 | /* by default sdio devices are considered CLK_GATING broken */ | ||
62 | /* good cards will be whitelisted as they are tested */ | ||
63 | { SDIO_ANY_ID, SDIO_ANY_ID, | ||
64 | add_quirk_for_sdio_devices, MMC_QUIRK_BROKEN_CLK_GATING }, | ||
65 | { SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, | ||
66 | remove_quirk, MMC_QUIRK_BROKEN_CLK_GATING }, | ||
67 | { 0 } | ||
68 | }; | ||
69 | |||
70 | void mmc_fixup_device(struct mmc_card *card) | ||
71 | { | ||
72 | const struct mmc_fixup *f; | ||
73 | |||
74 | for (f = mmc_fixup_methods; f->vendor_fixup; f++) { | ||
75 | if ((f->vendor == card->cis.vendor | ||
76 | || f->vendor == (u16) SDIO_ANY_ID) && | ||
77 | (f->device == card->cis.device | ||
78 | || f->device == (u16) SDIO_ANY_ID)) { | ||
79 | dev_dbg(&card->dev, "calling %pF\n", f->vendor_fixup); | ||
80 | f->vendor_fixup(card, f->data); | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | EXPORT_SYMBOL(mmc_fixup_device); | ||
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index d18c32bca99b..6dac89fe0535 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "core.h" | 21 | #include "core.h" |
22 | #include "bus.h" | 22 | #include "bus.h" |
23 | #include "mmc_ops.h" | 23 | #include "mmc_ops.h" |
24 | #include "sd.h" | ||
24 | #include "sd_ops.h" | 25 | #include "sd_ops.h" |
25 | 26 | ||
26 | static const unsigned int tran_exp[] = { | 27 | static const unsigned int tran_exp[] = { |
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index ebc62ad4cc56..db0f0b44d684 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -395,6 +395,14 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
395 | if (err) | 395 | if (err) |
396 | goto remove; | 396 | goto remove; |
397 | 397 | ||
398 | /* | ||
399 | * Update oldcard with the new RCA received from the SDIO | ||
400 | * device -- we're doing this so that it's updated in the | ||
401 | * "card" struct when oldcard overwrites that later. | ||
402 | */ | ||
403 | if (oldcard) | ||
404 | oldcard->rca = card->rca; | ||
405 | |||
398 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); | 406 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); |
399 | } | 407 | } |
400 | 408 | ||
@@ -458,6 +466,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
458 | 466 | ||
459 | card = oldcard; | 467 | card = oldcard; |
460 | } | 468 | } |
469 | mmc_fixup_device(card); | ||
461 | 470 | ||
462 | if (card->type == MMC_TYPE_SD_COMBO) { | 471 | if (card->type == MMC_TYPE_SD_COMBO) { |
463 | err = mmc_sd_setup_card(host, card, oldcard != NULL); | 472 | err = mmc_sd_setup_card(host, card, oldcard != NULL); |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 54f91321749a..1a21c6427a19 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -311,7 +311,7 @@ config MMC_MSM | |||
311 | 311 | ||
312 | config MMC_MXC | 312 | config MMC_MXC |
313 | tristate "Freescale i.MX2/3 Multimedia Card Interface support" | 313 | tristate "Freescale i.MX2/3 Multimedia Card Interface support" |
314 | depends on ARCH_MXC | 314 | depends on MACH_MX21 || MACH_MX27 || ARCH_MX31 |
315 | help | 315 | help |
316 | This selects the Freescale i.MX2/3 Multimedia card Interface. | 316 | This selects the Freescale i.MX2/3 Multimedia card Interface. |
317 | If you have a i.MX platform with a Multimedia Card slot, | 317 | If you have a i.MX platform with a Multimedia Card slot, |
@@ -319,6 +319,15 @@ config MMC_MXC | |||
319 | 319 | ||
320 | If unsure, say N. | 320 | If unsure, say N. |
321 | 321 | ||
322 | config MMC_MXS | ||
323 | tristate "Freescale MXS Multimedia Card Interface support" | ||
324 | depends on ARCH_MXS && MXS_DMA | ||
325 | help | ||
326 | This selects the Freescale SSP MMC controller found on MXS based | ||
327 | platforms like mx23/28. | ||
328 | |||
329 | If unsure, say N. | ||
330 | |||
322 | config MMC_TIFM_SD | 331 | config MMC_TIFM_SD |
323 | tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)" | 332 | tristate "TI Flash Media MMC/SD Interface support (EXPERIMENTAL)" |
324 | depends on EXPERIMENTAL && PCI | 333 | depends on EXPERIMENTAL && PCI |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index e834fb223e9a..30aa6867745f 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -6,6 +6,7 @@ obj-$(CONFIG_MMC_ARMMMCI) += mmci.o | |||
6 | obj-$(CONFIG_MMC_PXA) += pxamci.o | 6 | obj-$(CONFIG_MMC_PXA) += pxamci.o |
7 | obj-$(CONFIG_MMC_IMX) += imxmmc.o | 7 | obj-$(CONFIG_MMC_IMX) += imxmmc.o |
8 | obj-$(CONFIG_MMC_MXC) += mxcmmc.o | 8 | obj-$(CONFIG_MMC_MXC) += mxcmmc.o |
9 | obj-$(CONFIG_MMC_MXS) += mxs-mmc.o | ||
9 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o | 10 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o |
10 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o | 11 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o |
11 | obj-$(CONFIG_MMC_SDHCI_PXA) += sdhci-pxa.o | 12 | obj-$(CONFIG_MMC_SDHCI_PXA) += sdhci-pxa.o |
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index ad2a7a032cdf..80bc9a5c25cc 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -578,7 +578,8 @@ static void atmci_dma_cleanup(struct atmel_mci *host) | |||
578 | struct mmc_data *data = host->data; | 578 | struct mmc_data *data = host->data; |
579 | 579 | ||
580 | if (data) | 580 | if (data) |
581 | dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, | 581 | dma_unmap_sg(host->dma.chan->device->dev, |
582 | data->sg, data->sg_len, | ||
582 | ((data->flags & MMC_DATA_WRITE) | 583 | ((data->flags & MMC_DATA_WRITE) |
583 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); | 584 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); |
584 | } | 585 | } |
@@ -588,7 +589,7 @@ static void atmci_stop_dma(struct atmel_mci *host) | |||
588 | struct dma_chan *chan = host->data_chan; | 589 | struct dma_chan *chan = host->data_chan; |
589 | 590 | ||
590 | if (chan) { | 591 | if (chan) { |
591 | chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); | 592 | dmaengine_terminate_all(chan); |
592 | atmci_dma_cleanup(host); | 593 | atmci_dma_cleanup(host); |
593 | } else { | 594 | } else { |
594 | /* Data transfer was stopped by the interrupt handler */ | 595 | /* Data transfer was stopped by the interrupt handler */ |
@@ -684,11 +685,11 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) | |||
684 | else | 685 | else |
685 | direction = DMA_TO_DEVICE; | 686 | direction = DMA_TO_DEVICE; |
686 | 687 | ||
687 | sglen = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, direction); | 688 | sglen = dma_map_sg(chan->device->dev, data->sg, |
688 | if (sglen != data->sg_len) | 689 | data->sg_len, direction); |
689 | goto unmap_exit; | 690 | |
690 | desc = chan->device->device_prep_slave_sg(chan, | 691 | desc = chan->device->device_prep_slave_sg(chan, |
691 | data->sg, data->sg_len, direction, | 692 | data->sg, sglen, direction, |
692 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 693 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
693 | if (!desc) | 694 | if (!desc) |
694 | goto unmap_exit; | 695 | goto unmap_exit; |
@@ -699,7 +700,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data) | |||
699 | 700 | ||
700 | return 0; | 701 | return 0; |
701 | unmap_exit: | 702 | unmap_exit: |
702 | dma_unmap_sg(&host->pdev->dev, data->sg, sglen, direction); | 703 | dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, direction); |
703 | return -ENOMEM; | 704 | return -ENOMEM; |
704 | } | 705 | } |
705 | 706 | ||
@@ -709,8 +710,8 @@ static void atmci_submit_data(struct atmel_mci *host) | |||
709 | struct dma_async_tx_descriptor *desc = host->dma.data_desc; | 710 | struct dma_async_tx_descriptor *desc = host->dma.data_desc; |
710 | 711 | ||
711 | if (chan) { | 712 | if (chan) { |
712 | desc->tx_submit(desc); | 713 | dmaengine_submit(desc); |
713 | chan->device->device_issue_pending(chan); | 714 | dma_async_issue_pending(chan); |
714 | } | 715 | } |
715 | } | 716 | } |
716 | 717 | ||
diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c index 66b4ce587f4b..ce2a47b71dd6 100644 --- a/drivers/mmc/host/cb710-mmc.c +++ b/drivers/mmc/host/cb710-mmc.c | |||
@@ -205,7 +205,7 @@ static int cb710_wait_while_busy(struct cb710_slot *slot, uint8_t mask) | |||
205 | "WAIT12: waited %d loops, mask %02X, entry val %08X, exit val %08X\n", | 205 | "WAIT12: waited %d loops, mask %02X, entry val %08X, exit val %08X\n", |
206 | limit, mask, e, x); | 206 | limit, mask, e, x); |
207 | #endif | 207 | #endif |
208 | return 0; | 208 | return err; |
209 | } | 209 | } |
210 | 210 | ||
211 | static void cb710_mmc_set_transfer_size(struct cb710_slot *slot, | 211 | static void cb710_mmc_set_transfer_size(struct cb710_slot *slot, |
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 2fcc82577c1b..5a614069cb00 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/mmc/mmc.h> | 32 | #include <linux/mmc/mmc.h> |
33 | #include <linux/mmc/dw_mmc.h> | 33 | #include <linux/mmc/dw_mmc.h> |
34 | #include <linux/bitops.h> | 34 | #include <linux/bitops.h> |
35 | #include <linux/regulator/consumer.h> | ||
35 | 36 | ||
36 | #include "dw_mmc.h" | 37 | #include "dw_mmc.h" |
37 | 38 | ||
@@ -562,7 +563,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) | |||
562 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); | 563 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); |
563 | 564 | ||
564 | /* enable clock */ | 565 | /* enable clock */ |
565 | mci_writel(host, CLKENA, SDMMC_CLKEN_ENABLE); | 566 | mci_writel(host, CLKENA, SDMMC_CLKEN_ENABLE | |
567 | SDMMC_CLKEN_LOW_PWR); | ||
566 | 568 | ||
567 | /* inform CIU */ | 569 | /* inform CIU */ |
568 | mci_send_cmd(slot, | 570 | mci_send_cmd(slot, |
@@ -661,6 +663,7 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
661 | static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 663 | static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
662 | { | 664 | { |
663 | struct dw_mci_slot *slot = mmc_priv(mmc); | 665 | struct dw_mci_slot *slot = mmc_priv(mmc); |
666 | u32 regs; | ||
664 | 667 | ||
665 | /* set default 1 bit mode */ | 668 | /* set default 1 bit mode */ |
666 | slot->ctype = SDMMC_CTYPE_1BIT; | 669 | slot->ctype = SDMMC_CTYPE_1BIT; |
@@ -672,6 +675,16 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
672 | case MMC_BUS_WIDTH_4: | 675 | case MMC_BUS_WIDTH_4: |
673 | slot->ctype = SDMMC_CTYPE_4BIT; | 676 | slot->ctype = SDMMC_CTYPE_4BIT; |
674 | break; | 677 | break; |
678 | case MMC_BUS_WIDTH_8: | ||
679 | slot->ctype = SDMMC_CTYPE_8BIT; | ||
680 | break; | ||
681 | } | ||
682 | |||
683 | /* DDR mode set */ | ||
684 | if (ios->ddr) { | ||
685 | regs = mci_readl(slot->host, UHS_REG); | ||
686 | regs |= (0x1 << slot->id) << 16; | ||
687 | mci_writel(slot->host, UHS_REG, regs); | ||
675 | } | 688 | } |
676 | 689 | ||
677 | if (ios->clock) { | 690 | if (ios->clock) { |
@@ -717,7 +730,9 @@ static int dw_mci_get_cd(struct mmc_host *mmc) | |||
717 | struct dw_mci_board *brd = slot->host->pdata; | 730 | struct dw_mci_board *brd = slot->host->pdata; |
718 | 731 | ||
719 | /* Use platform get_cd function, else try onboard card detect */ | 732 | /* Use platform get_cd function, else try onboard card detect */ |
720 | if (brd->get_cd) | 733 | if (brd->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION) |
734 | present = 1; | ||
735 | else if (brd->get_cd) | ||
721 | present = !brd->get_cd(slot->id); | 736 | present = !brd->get_cd(slot->id); |
722 | else | 737 | else |
723 | present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) | 738 | present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) |
@@ -1019,13 +1034,10 @@ static void dw_mci_read_data_pio(struct dw_mci *host) | |||
1019 | struct mmc_data *data = host->data; | 1034 | struct mmc_data *data = host->data; |
1020 | int shift = host->data_shift; | 1035 | int shift = host->data_shift; |
1021 | u32 status; | 1036 | u32 status; |
1022 | unsigned int nbytes = 0, len, old_len, count = 0; | 1037 | unsigned int nbytes = 0, len; |
1023 | 1038 | ||
1024 | do { | 1039 | do { |
1025 | len = SDMMC_GET_FCNT(mci_readl(host, STATUS)) << shift; | 1040 | len = SDMMC_GET_FCNT(mci_readl(host, STATUS)) << shift; |
1026 | if (count == 0) | ||
1027 | old_len = len; | ||
1028 | |||
1029 | if (offset + len <= sg->length) { | 1041 | if (offset + len <= sg->length) { |
1030 | host->pull_data(host, (void *)(buf + offset), len); | 1042 | host->pull_data(host, (void *)(buf + offset), len); |
1031 | 1043 | ||
@@ -1070,7 +1082,6 @@ static void dw_mci_read_data_pio(struct dw_mci *host) | |||
1070 | tasklet_schedule(&host->tasklet); | 1082 | tasklet_schedule(&host->tasklet); |
1071 | return; | 1083 | return; |
1072 | } | 1084 | } |
1073 | count++; | ||
1074 | } while (status & SDMMC_INT_RXDR); /*if the RXDR is ready read again*/ | 1085 | } while (status & SDMMC_INT_RXDR); /*if the RXDR is ready read again*/ |
1075 | len = SDMMC_GET_FCNT(mci_readl(host, STATUS)); | 1086 | len = SDMMC_GET_FCNT(mci_readl(host, STATUS)); |
1076 | host->pio_offset = offset; | 1087 | host->pio_offset = offset; |
@@ -1395,7 +1406,11 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1395 | if (host->pdata->setpower) | 1406 | if (host->pdata->setpower) |
1396 | host->pdata->setpower(id, 0); | 1407 | host->pdata->setpower(id, 0); |
1397 | 1408 | ||
1398 | mmc->caps = 0; | 1409 | if (host->pdata->caps) |
1410 | mmc->caps = host->pdata->caps; | ||
1411 | else | ||
1412 | mmc->caps = 0; | ||
1413 | |||
1399 | if (host->pdata->get_bus_wd) | 1414 | if (host->pdata->get_bus_wd) |
1400 | if (host->pdata->get_bus_wd(slot->id) >= 4) | 1415 | if (host->pdata->get_bus_wd(slot->id) >= 4) |
1401 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 1416 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
@@ -1426,6 +1441,13 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1426 | } | 1441 | } |
1427 | #endif /* CONFIG_MMC_DW_IDMAC */ | 1442 | #endif /* CONFIG_MMC_DW_IDMAC */ |
1428 | 1443 | ||
1444 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); | ||
1445 | if (IS_ERR(host->vmmc)) { | ||
1446 | printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc)); | ||
1447 | host->vmmc = NULL; | ||
1448 | } else | ||
1449 | regulator_enable(host->vmmc); | ||
1450 | |||
1429 | if (dw_mci_get_cd(mmc)) | 1451 | if (dw_mci_get_cd(mmc)) |
1430 | set_bit(DW_MMC_CARD_PRESENT, &slot->flags); | 1452 | set_bit(DW_MMC_CARD_PRESENT, &slot->flags); |
1431 | else | 1453 | else |
@@ -1441,6 +1463,12 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1441 | /* Card initially undetected */ | 1463 | /* Card initially undetected */ |
1442 | slot->last_detect_state = 0; | 1464 | slot->last_detect_state = 0; |
1443 | 1465 | ||
1466 | /* | ||
1467 | * Card may have been plugged in prior to boot so we | ||
1468 | * need to run the detect tasklet | ||
1469 | */ | ||
1470 | tasklet_schedule(&host->card_tasklet); | ||
1471 | |||
1444 | return 0; | 1472 | return 0; |
1445 | } | 1473 | } |
1446 | 1474 | ||
@@ -1619,8 +1647,9 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
1619 | */ | 1647 | */ |
1620 | fifo_size = mci_readl(host, FIFOTH); | 1648 | fifo_size = mci_readl(host, FIFOTH); |
1621 | fifo_size = (fifo_size >> 16) & 0x7ff; | 1649 | fifo_size = (fifo_size >> 16) & 0x7ff; |
1622 | mci_writel(host, FIFOTH, ((0x2 << 28) | ((fifo_size/2 - 1) << 16) | | 1650 | host->fifoth_val = ((0x2 << 28) | ((fifo_size/2 - 1) << 16) | |
1623 | ((fifo_size/2) << 0))); | 1651 | ((fifo_size/2) << 0)); |
1652 | mci_writel(host, FIFOTH, host->fifoth_val); | ||
1624 | 1653 | ||
1625 | /* disable clock to CIU */ | 1654 | /* disable clock to CIU */ |
1626 | mci_writel(host, CLKENA, 0); | 1655 | mci_writel(host, CLKENA, 0); |
@@ -1683,6 +1712,12 @@ err_dmaunmap: | |||
1683 | host->sg_cpu, host->sg_dma); | 1712 | host->sg_cpu, host->sg_dma); |
1684 | iounmap(host->regs); | 1713 | iounmap(host->regs); |
1685 | 1714 | ||
1715 | if (host->vmmc) { | ||
1716 | regulator_disable(host->vmmc); | ||
1717 | regulator_put(host->vmmc); | ||
1718 | } | ||
1719 | |||
1720 | |||
1686 | err_freehost: | 1721 | err_freehost: |
1687 | kfree(host); | 1722 | kfree(host); |
1688 | return ret; | 1723 | return ret; |
@@ -1714,6 +1749,11 @@ static int __exit dw_mci_remove(struct platform_device *pdev) | |||
1714 | if (host->use_dma && host->dma_ops->exit) | 1749 | if (host->use_dma && host->dma_ops->exit) |
1715 | host->dma_ops->exit(host); | 1750 | host->dma_ops->exit(host); |
1716 | 1751 | ||
1752 | if (host->vmmc) { | ||
1753 | regulator_disable(host->vmmc); | ||
1754 | regulator_put(host->vmmc); | ||
1755 | } | ||
1756 | |||
1717 | iounmap(host->regs); | 1757 | iounmap(host->regs); |
1718 | 1758 | ||
1719 | kfree(host); | 1759 | kfree(host); |
@@ -1729,6 +1769,9 @@ static int dw_mci_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1729 | int i, ret; | 1769 | int i, ret; |
1730 | struct dw_mci *host = platform_get_drvdata(pdev); | 1770 | struct dw_mci *host = platform_get_drvdata(pdev); |
1731 | 1771 | ||
1772 | if (host->vmmc) | ||
1773 | regulator_enable(host->vmmc); | ||
1774 | |||
1732 | for (i = 0; i < host->num_slots; i++) { | 1775 | for (i = 0; i < host->num_slots; i++) { |
1733 | struct dw_mci_slot *slot = host->slot[i]; | 1776 | struct dw_mci_slot *slot = host->slot[i]; |
1734 | if (!slot) | 1777 | if (!slot) |
@@ -1744,6 +1787,9 @@ static int dw_mci_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1744 | } | 1787 | } |
1745 | } | 1788 | } |
1746 | 1789 | ||
1790 | if (host->vmmc) | ||
1791 | regulator_disable(host->vmmc); | ||
1792 | |||
1747 | return 0; | 1793 | return 0; |
1748 | } | 1794 | } |
1749 | 1795 | ||
@@ -1752,6 +1798,23 @@ static int dw_mci_resume(struct platform_device *pdev) | |||
1752 | int i, ret; | 1798 | int i, ret; |
1753 | struct dw_mci *host = platform_get_drvdata(pdev); | 1799 | struct dw_mci *host = platform_get_drvdata(pdev); |
1754 | 1800 | ||
1801 | if (host->dma_ops->init) | ||
1802 | host->dma_ops->init(host); | ||
1803 | |||
1804 | if (!mci_wait_reset(&pdev->dev, host)) { | ||
1805 | ret = -ENODEV; | ||
1806 | return ret; | ||
1807 | } | ||
1808 | |||
1809 | /* Restore the old value at FIFOTH register */ | ||
1810 | mci_writel(host, FIFOTH, host->fifoth_val); | ||
1811 | |||
1812 | mci_writel(host, RINTSTS, 0xFFFFFFFF); | ||
1813 | mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER | | ||
1814 | SDMMC_INT_TXDR | SDMMC_INT_RXDR | | ||
1815 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); | ||
1816 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); | ||
1817 | |||
1755 | for (i = 0; i < host->num_slots; i++) { | 1818 | for (i = 0; i < host->num_slots; i++) { |
1756 | struct dw_mci_slot *slot = host->slot[i]; | 1819 | struct dw_mci_slot *slot = host->slot[i]; |
1757 | if (!slot) | 1820 | if (!slot) |
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index 5dd55a75233d..23c662af5616 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h | |||
@@ -43,6 +43,7 @@ | |||
43 | #define SDMMC_USRID 0x068 | 43 | #define SDMMC_USRID 0x068 |
44 | #define SDMMC_VERID 0x06c | 44 | #define SDMMC_VERID 0x06c |
45 | #define SDMMC_HCON 0x070 | 45 | #define SDMMC_HCON 0x070 |
46 | #define SDMMC_UHS_REG 0x074 | ||
46 | #define SDMMC_BMOD 0x080 | 47 | #define SDMMC_BMOD 0x080 |
47 | #define SDMMC_PLDMND 0x084 | 48 | #define SDMMC_PLDMND 0x084 |
48 | #define SDMMC_DBADDR 0x088 | 49 | #define SDMMC_DBADDR 0x088 |
@@ -51,7 +52,6 @@ | |||
51 | #define SDMMC_DSCADDR 0x094 | 52 | #define SDMMC_DSCADDR 0x094 |
52 | #define SDMMC_BUFADDR 0x098 | 53 | #define SDMMC_BUFADDR 0x098 |
53 | #define SDMMC_DATA 0x100 | 54 | #define SDMMC_DATA 0x100 |
54 | #define SDMMC_DATA_ADR 0x100 | ||
55 | 55 | ||
56 | /* shift bit field */ | 56 | /* shift bit field */ |
57 | #define _SBF(f, v) ((v) << (f)) | 57 | #define _SBF(f, v) ((v) << (f)) |
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c index 97c9b3638d57..a4c865a5286b 100644 --- a/drivers/mmc/host/msm_sdcc.c +++ b/drivers/mmc/host/msm_sdcc.c | |||
@@ -267,14 +267,6 @@ msmsdcc_dma_complete_tlet(unsigned long data) | |||
267 | dma_unmap_sg(mmc_dev(host->mmc), host->dma.sg, host->dma.num_ents, | 267 | dma_unmap_sg(mmc_dev(host->mmc), host->dma.sg, host->dma.num_ents, |
268 | host->dma.dir); | 268 | host->dma.dir); |
269 | 269 | ||
270 | if (host->curr.user_pages) { | ||
271 | struct scatterlist *sg = host->dma.sg; | ||
272 | int i; | ||
273 | |||
274 | for (i = 0; i < host->dma.num_ents; i++) | ||
275 | flush_dcache_page(sg_page(sg++)); | ||
276 | } | ||
277 | |||
278 | host->dma.sg = NULL; | 270 | host->dma.sg = NULL; |
279 | host->dma.busy = 0; | 271 | host->dma.busy = 0; |
280 | 272 | ||
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 4428594261c5..cc20e0259325 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -32,16 +32,14 @@ | |||
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <linux/regulator/consumer.h> | 34 | #include <linux/regulator/consumer.h> |
35 | #include <linux/dmaengine.h> | ||
35 | 36 | ||
36 | #include <asm/dma.h> | 37 | #include <asm/dma.h> |
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/sizes.h> | 39 | #include <asm/sizes.h> |
39 | #include <mach/mmc.h> | 40 | #include <mach/mmc.h> |
40 | 41 | ||
41 | #ifdef CONFIG_ARCH_MX2 | 42 | #include <mach/dma.h> |
42 | #include <mach/dma-mx1-mx2.h> | ||
43 | #define HAS_DMA | ||
44 | #endif | ||
45 | 43 | ||
46 | #define DRIVER_NAME "mxc-mmc" | 44 | #define DRIVER_NAME "mxc-mmc" |
47 | 45 | ||
@@ -118,7 +116,8 @@ struct mxcmci_host { | |||
118 | void __iomem *base; | 116 | void __iomem *base; |
119 | int irq; | 117 | int irq; |
120 | int detect_irq; | 118 | int detect_irq; |
121 | int dma; | 119 | struct dma_chan *dma; |
120 | struct dma_async_tx_descriptor *desc; | ||
122 | int do_dma; | 121 | int do_dma; |
123 | int default_irq_mask; | 122 | int default_irq_mask; |
124 | int use_sdio; | 123 | int use_sdio; |
@@ -129,7 +128,6 @@ struct mxcmci_host { | |||
129 | struct mmc_command *cmd; | 128 | struct mmc_command *cmd; |
130 | struct mmc_data *data; | 129 | struct mmc_data *data; |
131 | 130 | ||
132 | unsigned int dma_nents; | ||
133 | unsigned int datasize; | 131 | unsigned int datasize; |
134 | unsigned int dma_dir; | 132 | unsigned int dma_dir; |
135 | 133 | ||
@@ -144,6 +142,11 @@ struct mxcmci_host { | |||
144 | spinlock_t lock; | 142 | spinlock_t lock; |
145 | 143 | ||
146 | struct regulator *vcc; | 144 | struct regulator *vcc; |
145 | |||
146 | int burstlen; | ||
147 | int dmareq; | ||
148 | struct dma_slave_config dma_slave_config; | ||
149 | struct imx_dma_data dma_data; | ||
147 | }; | 150 | }; |
148 | 151 | ||
149 | static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios); | 152 | static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios); |
@@ -206,17 +209,16 @@ static void mxcmci_softreset(struct mxcmci_host *host) | |||
206 | 209 | ||
207 | writew(0xff, host->base + MMC_REG_RES_TO); | 210 | writew(0xff, host->base + MMC_REG_RES_TO); |
208 | } | 211 | } |
212 | static int mxcmci_setup_dma(struct mmc_host *mmc); | ||
209 | 213 | ||
210 | static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | 214 | static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) |
211 | { | 215 | { |
212 | unsigned int nob = data->blocks; | 216 | unsigned int nob = data->blocks; |
213 | unsigned int blksz = data->blksz; | 217 | unsigned int blksz = data->blksz; |
214 | unsigned int datasize = nob * blksz; | 218 | unsigned int datasize = nob * blksz; |
215 | #ifdef HAS_DMA | ||
216 | struct scatterlist *sg; | 219 | struct scatterlist *sg; |
217 | int i; | 220 | int i, nents; |
218 | int ret; | 221 | |
219 | #endif | ||
220 | if (data->flags & MMC_DATA_STREAM) | 222 | if (data->flags & MMC_DATA_STREAM) |
221 | nob = 0xffff; | 223 | nob = 0xffff; |
222 | 224 | ||
@@ -227,7 +229,9 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | |||
227 | writew(blksz, host->base + MMC_REG_BLK_LEN); | 229 | writew(blksz, host->base + MMC_REG_BLK_LEN); |
228 | host->datasize = datasize; | 230 | host->datasize = datasize; |
229 | 231 | ||
230 | #ifdef HAS_DMA | 232 | if (!mxcmci_use_dma(host)) |
233 | return 0; | ||
234 | |||
231 | for_each_sg(data->sg, sg, data->sg_len, i) { | 235 | for_each_sg(data->sg, sg, data->sg_len, i) { |
232 | if (sg->offset & 3 || sg->length & 3) { | 236 | if (sg->offset & 3 || sg->length & 3) { |
233 | host->do_dma = 0; | 237 | host->do_dma = 0; |
@@ -235,34 +239,30 @@ static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data) | |||
235 | } | 239 | } |
236 | } | 240 | } |
237 | 241 | ||
238 | if (data->flags & MMC_DATA_READ) { | 242 | if (data->flags & MMC_DATA_READ) |
239 | host->dma_dir = DMA_FROM_DEVICE; | 243 | host->dma_dir = DMA_FROM_DEVICE; |
240 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | 244 | else |
241 | data->sg_len, host->dma_dir); | ||
242 | |||
243 | ret = imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, | ||
244 | datasize, | ||
245 | host->res->start + MMC_REG_BUFFER_ACCESS, | ||
246 | DMA_MODE_READ); | ||
247 | } else { | ||
248 | host->dma_dir = DMA_TO_DEVICE; | 245 | host->dma_dir = DMA_TO_DEVICE; |
249 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | ||
250 | data->sg_len, host->dma_dir); | ||
251 | 246 | ||
252 | ret = imx_dma_setup_sg(host->dma, data->sg, host->dma_nents, | 247 | nents = dma_map_sg(host->dma->device->dev, data->sg, |
253 | datasize, | 248 | data->sg_len, host->dma_dir); |
254 | host->res->start + MMC_REG_BUFFER_ACCESS, | 249 | if (nents != data->sg_len) |
255 | DMA_MODE_WRITE); | 250 | return -EINVAL; |
256 | } | 251 | |
252 | host->desc = host->dma->device->device_prep_slave_sg(host->dma, | ||
253 | data->sg, data->sg_len, host->dma_dir, | ||
254 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
257 | 255 | ||
258 | if (ret) { | 256 | if (!host->desc) { |
259 | dev_err(mmc_dev(host->mmc), "failed to setup DMA : %d\n", ret); | 257 | dma_unmap_sg(host->dma->device->dev, data->sg, data->sg_len, |
260 | return ret; | 258 | host->dma_dir); |
259 | host->do_dma = 0; | ||
260 | return 0; /* Fall back to PIO */ | ||
261 | } | 261 | } |
262 | wmb(); | 262 | wmb(); |
263 | 263 | ||
264 | imx_dma_enable(host->dma); | 264 | dmaengine_submit(host->desc); |
265 | #endif /* HAS_DMA */ | 265 | |
266 | return 0; | 266 | return 0; |
267 | } | 267 | } |
268 | 268 | ||
@@ -337,13 +337,11 @@ static int mxcmci_finish_data(struct mxcmci_host *host, unsigned int stat) | |||
337 | struct mmc_data *data = host->data; | 337 | struct mmc_data *data = host->data; |
338 | int data_error; | 338 | int data_error; |
339 | 339 | ||
340 | #ifdef HAS_DMA | ||
341 | if (mxcmci_use_dma(host)) { | 340 | if (mxcmci_use_dma(host)) { |
342 | imx_dma_disable(host->dma); | 341 | dmaengine_terminate_all(host->dma); |
343 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents, | 342 | dma_unmap_sg(host->dma->device->dev, data->sg, data->sg_len, |
344 | host->dma_dir); | 343 | host->dma_dir); |
345 | } | 344 | } |
346 | #endif | ||
347 | 345 | ||
348 | if (stat & STATUS_ERR_MASK) { | 346 | if (stat & STATUS_ERR_MASK) { |
349 | dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n", | 347 | dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n", |
@@ -545,7 +543,6 @@ static void mxcmci_datawork(struct work_struct *work) | |||
545 | } | 543 | } |
546 | } | 544 | } |
547 | 545 | ||
548 | #ifdef HAS_DMA | ||
549 | static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat) | 546 | static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat) |
550 | { | 547 | { |
551 | struct mmc_data *data = host->data; | 548 | struct mmc_data *data = host->data; |
@@ -568,7 +565,6 @@ static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat) | |||
568 | mxcmci_finish_request(host, host->req); | 565 | mxcmci_finish_request(host, host->req); |
569 | } | 566 | } |
570 | } | 567 | } |
571 | #endif /* HAS_DMA */ | ||
572 | 568 | ||
573 | static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat) | 569 | static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat) |
574 | { | 570 | { |
@@ -606,12 +602,10 @@ static irqreturn_t mxcmci_irq(int irq, void *devid) | |||
606 | sdio_irq = (stat & STATUS_SDIO_INT_ACTIVE) && host->use_sdio; | 602 | sdio_irq = (stat & STATUS_SDIO_INT_ACTIVE) && host->use_sdio; |
607 | spin_unlock_irqrestore(&host->lock, flags); | 603 | spin_unlock_irqrestore(&host->lock, flags); |
608 | 604 | ||
609 | #ifdef HAS_DMA | ||
610 | if (mxcmci_use_dma(host) && | 605 | if (mxcmci_use_dma(host) && |
611 | (stat & (STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE))) | 606 | (stat & (STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE))) |
612 | writel(STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE, | 607 | writel(STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE, |
613 | host->base + MMC_REG_STATUS); | 608 | host->base + MMC_REG_STATUS); |
614 | #endif | ||
615 | 609 | ||
616 | if (sdio_irq) { | 610 | if (sdio_irq) { |
617 | writel(STATUS_SDIO_INT_ACTIVE, host->base + MMC_REG_STATUS); | 611 | writel(STATUS_SDIO_INT_ACTIVE, host->base + MMC_REG_STATUS); |
@@ -621,14 +615,14 @@ static irqreturn_t mxcmci_irq(int irq, void *devid) | |||
621 | if (stat & STATUS_END_CMD_RESP) | 615 | if (stat & STATUS_END_CMD_RESP) |
622 | mxcmci_cmd_done(host, stat); | 616 | mxcmci_cmd_done(host, stat); |
623 | 617 | ||
624 | #ifdef HAS_DMA | ||
625 | if (mxcmci_use_dma(host) && | 618 | if (mxcmci_use_dma(host) && |
626 | (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE))) | 619 | (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE))) |
627 | mxcmci_data_done(host, stat); | 620 | mxcmci_data_done(host, stat); |
628 | #endif | 621 | |
629 | if (host->default_irq_mask && | 622 | if (host->default_irq_mask && |
630 | (stat & (STATUS_CARD_INSERTION | STATUS_CARD_REMOVAL))) | 623 | (stat & (STATUS_CARD_INSERTION | STATUS_CARD_REMOVAL))) |
631 | mmc_detect_change(host->mmc, msecs_to_jiffies(200)); | 624 | mmc_detect_change(host->mmc, msecs_to_jiffies(200)); |
625 | |||
632 | return IRQ_HANDLED; | 626 | return IRQ_HANDLED; |
633 | } | 627 | } |
634 | 628 | ||
@@ -642,9 +636,10 @@ static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req) | |||
642 | 636 | ||
643 | host->req = req; | 637 | host->req = req; |
644 | host->cmdat &= ~CMD_DAT_CONT_INIT; | 638 | host->cmdat &= ~CMD_DAT_CONT_INIT; |
645 | #ifdef HAS_DMA | 639 | |
646 | host->do_dma = 1; | 640 | if (host->dma) |
647 | #endif | 641 | host->do_dma = 1; |
642 | |||
648 | if (req->data) { | 643 | if (req->data) { |
649 | error = mxcmci_setup_data(host, req->data); | 644 | error = mxcmci_setup_data(host, req->data); |
650 | if (error) { | 645 | if (error) { |
@@ -660,6 +655,7 @@ static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req) | |||
660 | } | 655 | } |
661 | 656 | ||
662 | error = mxcmci_start_cmd(host, req->cmd, cmdat); | 657 | error = mxcmci_start_cmd(host, req->cmd, cmdat); |
658 | |||
663 | out: | 659 | out: |
664 | if (error) | 660 | if (error) |
665 | mxcmci_finish_request(host, req); | 661 | mxcmci_finish_request(host, req); |
@@ -698,22 +694,46 @@ static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios) | |||
698 | prescaler, divider, clk_in, clk_ios); | 694 | prescaler, divider, clk_in, clk_ios); |
699 | } | 695 | } |
700 | 696 | ||
697 | static int mxcmci_setup_dma(struct mmc_host *mmc) | ||
698 | { | ||
699 | struct mxcmci_host *host = mmc_priv(mmc); | ||
700 | struct dma_slave_config *config = &host->dma_slave_config; | ||
701 | |||
702 | config->dst_addr = host->res->start + MMC_REG_BUFFER_ACCESS; | ||
703 | config->src_addr = host->res->start + MMC_REG_BUFFER_ACCESS; | ||
704 | config->dst_addr_width = 4; | ||
705 | config->src_addr_width = 4; | ||
706 | config->dst_maxburst = host->burstlen; | ||
707 | config->src_maxburst = host->burstlen; | ||
708 | |||
709 | return dmaengine_slave_config(host->dma, config); | ||
710 | } | ||
711 | |||
701 | static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 712 | static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
702 | { | 713 | { |
703 | struct mxcmci_host *host = mmc_priv(mmc); | 714 | struct mxcmci_host *host = mmc_priv(mmc); |
704 | #ifdef HAS_DMA | 715 | int burstlen, ret; |
705 | unsigned int blen; | 716 | |
706 | /* | 717 | /* |
707 | * use burstlen of 64 in 4 bit mode (--> reg value 0) | 718 | * use burstlen of 64 in 4 bit mode (--> reg value 0) |
708 | * use burstlen of 16 in 1 bit mode (--> reg value 16) | 719 | * use burstlen of 16 in 1 bit mode (--> reg value 16) |
709 | */ | 720 | */ |
710 | if (ios->bus_width == MMC_BUS_WIDTH_4) | 721 | if (ios->bus_width == MMC_BUS_WIDTH_4) |
711 | blen = 0; | 722 | burstlen = 64; |
712 | else | 723 | else |
713 | blen = 16; | 724 | burstlen = 16; |
725 | |||
726 | if (mxcmci_use_dma(host) && burstlen != host->burstlen) { | ||
727 | host->burstlen = burstlen; | ||
728 | ret = mxcmci_setup_dma(mmc); | ||
729 | if (ret) { | ||
730 | dev_err(mmc_dev(host->mmc), | ||
731 | "failed to config DMA channel. Falling back to PIO\n"); | ||
732 | dma_release_channel(host->dma); | ||
733 | host->do_dma = 0; | ||
734 | } | ||
735 | } | ||
714 | 736 | ||
715 | imx_dma_config_burstlen(host->dma, blen); | ||
716 | #endif | ||
717 | if (ios->bus_width == MMC_BUS_WIDTH_4) | 737 | if (ios->bus_width == MMC_BUS_WIDTH_4) |
718 | host->cmdat |= CMD_DAT_CONT_BUS_WIDTH_4; | 738 | host->cmdat |= CMD_DAT_CONT_BUS_WIDTH_4; |
719 | else | 739 | else |
@@ -794,6 +814,18 @@ static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card) | |||
794 | host->caps |= MMC_CAP_4_BIT_DATA; | 814 | host->caps |= MMC_CAP_4_BIT_DATA; |
795 | } | 815 | } |
796 | 816 | ||
817 | static bool filter(struct dma_chan *chan, void *param) | ||
818 | { | ||
819 | struct mxcmci_host *host = param; | ||
820 | |||
821 | if (!imx_dma_is_general_purpose(chan)) | ||
822 | return false; | ||
823 | |||
824 | chan->private = &host->dma_data; | ||
825 | |||
826 | return true; | ||
827 | } | ||
828 | |||
797 | static const struct mmc_host_ops mxcmci_ops = { | 829 | static const struct mmc_host_ops mxcmci_ops = { |
798 | .request = mxcmci_request, | 830 | .request = mxcmci_request, |
799 | .set_ios = mxcmci_set_ios, | 831 | .set_ios = mxcmci_set_ios, |
@@ -808,6 +840,7 @@ static int mxcmci_probe(struct platform_device *pdev) | |||
808 | struct mxcmci_host *host = NULL; | 840 | struct mxcmci_host *host = NULL; |
809 | struct resource *iores, *r; | 841 | struct resource *iores, *r; |
810 | int ret = 0, irq; | 842 | int ret = 0, irq; |
843 | dma_cap_mask_t mask; | ||
811 | 844 | ||
812 | printk(KERN_INFO "i.MX SDHC driver\n"); | 845 | printk(KERN_INFO "i.MX SDHC driver\n"); |
813 | 846 | ||
@@ -883,29 +916,23 @@ static int mxcmci_probe(struct platform_device *pdev) | |||
883 | 916 | ||
884 | writel(host->default_irq_mask, host->base + MMC_REG_INT_CNTR); | 917 | writel(host->default_irq_mask, host->base + MMC_REG_INT_CNTR); |
885 | 918 | ||
886 | #ifdef HAS_DMA | ||
887 | host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW); | ||
888 | if (host->dma < 0) { | ||
889 | dev_err(mmc_dev(host->mmc), "imx_dma_request_by_prio failed\n"); | ||
890 | ret = -EBUSY; | ||
891 | goto out_clk_put; | ||
892 | } | ||
893 | |||
894 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 919 | r = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
895 | if (!r) { | 920 | if (r) { |
896 | ret = -EINVAL; | 921 | host->dmareq = r->start; |
897 | goto out_free_dma; | 922 | host->dma_data.peripheral_type = IMX_DMATYPE_SDHC; |
923 | host->dma_data.priority = DMA_PRIO_LOW; | ||
924 | host->dma_data.dma_request = host->dmareq; | ||
925 | dma_cap_zero(mask); | ||
926 | dma_cap_set(DMA_SLAVE, mask); | ||
927 | host->dma = dma_request_channel(mask, filter, host); | ||
928 | if (host->dma) | ||
929 | mmc->max_seg_size = dma_get_max_seg_size( | ||
930 | host->dma->device->dev); | ||
898 | } | 931 | } |
899 | 932 | ||
900 | ret = imx_dma_config_channel(host->dma, | 933 | if (!host->dma) |
901 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_FIFO, | 934 | dev_info(mmc_dev(host->mmc), "dma not available. Using PIO\n"); |
902 | IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR, | 935 | |
903 | r->start, 0); | ||
904 | if (ret) { | ||
905 | dev_err(mmc_dev(host->mmc), "failed to config DMA channel\n"); | ||
906 | goto out_free_dma; | ||
907 | } | ||
908 | #endif | ||
909 | INIT_WORK(&host->datawork, mxcmci_datawork); | 936 | INIT_WORK(&host->datawork, mxcmci_datawork); |
910 | 937 | ||
911 | ret = request_irq(host->irq, mxcmci_irq, 0, DRIVER_NAME, host); | 938 | ret = request_irq(host->irq, mxcmci_irq, 0, DRIVER_NAME, host); |
@@ -928,9 +955,8 @@ static int mxcmci_probe(struct platform_device *pdev) | |||
928 | out_free_irq: | 955 | out_free_irq: |
929 | free_irq(host->irq, host); | 956 | free_irq(host->irq, host); |
930 | out_free_dma: | 957 | out_free_dma: |
931 | #ifdef HAS_DMA | 958 | if (host->dma) |
932 | imx_dma_free(host->dma); | 959 | dma_release_channel(host->dma); |
933 | #endif | ||
934 | out_clk_put: | 960 | out_clk_put: |
935 | clk_disable(host->clk); | 961 | clk_disable(host->clk); |
936 | clk_put(host->clk); | 962 | clk_put(host->clk); |
@@ -960,9 +986,10 @@ static int mxcmci_remove(struct platform_device *pdev) | |||
960 | 986 | ||
961 | free_irq(host->irq, host); | 987 | free_irq(host->irq, host); |
962 | iounmap(host->base); | 988 | iounmap(host->base); |
963 | #ifdef HAS_DMA | 989 | |
964 | imx_dma_free(host->dma); | 990 | if (host->dma) |
965 | #endif | 991 | dma_release_channel(host->dma); |
992 | |||
966 | clk_disable(host->clk); | 993 | clk_disable(host->clk); |
967 | clk_put(host->clk); | 994 | clk_put(host->clk); |
968 | 995 | ||
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c new file mode 100644 index 000000000000..99d39a6a1032 --- /dev/null +++ b/drivers/mmc/host/mxs-mmc.c | |||
@@ -0,0 +1,874 @@ | |||
1 | /* | ||
2 | * Portions copyright (C) 2003 Russell King, PXA MMCI Driver | ||
3 | * Portions copyright (C) 2004-2005 Pierre Ossman, W83L51xD SD/MMC driver | ||
4 | * | ||
5 | * Copyright 2008 Embedded Alley Solutions, Inc. | ||
6 | * Copyright 2009-2011 Freescale Semiconductor, Inc. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/ioport.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/delay.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/dma-mapping.h> | ||
30 | #include <linux/dmaengine.h> | ||
31 | #include <linux/highmem.h> | ||
32 | #include <linux/clk.h> | ||
33 | #include <linux/err.h> | ||
34 | #include <linux/completion.h> | ||
35 | #include <linux/mmc/host.h> | ||
36 | #include <linux/mmc/mmc.h> | ||
37 | #include <linux/mmc/sdio.h> | ||
38 | #include <linux/gpio.h> | ||
39 | #include <linux/regulator/consumer.h> | ||
40 | |||
41 | #include <mach/mxs.h> | ||
42 | #include <mach/common.h> | ||
43 | #include <mach/dma.h> | ||
44 | #include <mach/mmc.h> | ||
45 | |||
46 | #define DRIVER_NAME "mxs-mmc" | ||
47 | |||
48 | /* card detect polling timeout */ | ||
49 | #define MXS_MMC_DETECT_TIMEOUT (HZ/2) | ||
50 | |||
51 | #define SSP_VERSION_LATEST 4 | ||
52 | #define ssp_is_old() (host->version < SSP_VERSION_LATEST) | ||
53 | |||
54 | /* SSP registers */ | ||
55 | #define HW_SSP_CTRL0 0x000 | ||
56 | #define BM_SSP_CTRL0_RUN (1 << 29) | ||
57 | #define BM_SSP_CTRL0_SDIO_IRQ_CHECK (1 << 28) | ||
58 | #define BM_SSP_CTRL0_IGNORE_CRC (1 << 26) | ||
59 | #define BM_SSP_CTRL0_READ (1 << 25) | ||
60 | #define BM_SSP_CTRL0_DATA_XFER (1 << 24) | ||
61 | #define BP_SSP_CTRL0_BUS_WIDTH (22) | ||
62 | #define BM_SSP_CTRL0_BUS_WIDTH (0x3 << 22) | ||
63 | #define BM_SSP_CTRL0_WAIT_FOR_IRQ (1 << 21) | ||
64 | #define BM_SSP_CTRL0_LONG_RESP (1 << 19) | ||
65 | #define BM_SSP_CTRL0_GET_RESP (1 << 17) | ||
66 | #define BM_SSP_CTRL0_ENABLE (1 << 16) | ||
67 | #define BP_SSP_CTRL0_XFER_COUNT (0) | ||
68 | #define BM_SSP_CTRL0_XFER_COUNT (0xffff) | ||
69 | #define HW_SSP_CMD0 0x010 | ||
70 | #define BM_SSP_CMD0_DBL_DATA_RATE_EN (1 << 25) | ||
71 | #define BM_SSP_CMD0_SLOW_CLKING_EN (1 << 22) | ||
72 | #define BM_SSP_CMD0_CONT_CLKING_EN (1 << 21) | ||
73 | #define BM_SSP_CMD0_APPEND_8CYC (1 << 20) | ||
74 | #define BP_SSP_CMD0_BLOCK_SIZE (16) | ||
75 | #define BM_SSP_CMD0_BLOCK_SIZE (0xf << 16) | ||
76 | #define BP_SSP_CMD0_BLOCK_COUNT (8) | ||
77 | #define BM_SSP_CMD0_BLOCK_COUNT (0xff << 8) | ||
78 | #define BP_SSP_CMD0_CMD (0) | ||
79 | #define BM_SSP_CMD0_CMD (0xff) | ||
80 | #define HW_SSP_CMD1 0x020 | ||
81 | #define HW_SSP_XFER_SIZE 0x030 | ||
82 | #define HW_SSP_BLOCK_SIZE 0x040 | ||
83 | #define BP_SSP_BLOCK_SIZE_BLOCK_COUNT (4) | ||
84 | #define BM_SSP_BLOCK_SIZE_BLOCK_COUNT (0xffffff << 4) | ||
85 | #define BP_SSP_BLOCK_SIZE_BLOCK_SIZE (0) | ||
86 | #define BM_SSP_BLOCK_SIZE_BLOCK_SIZE (0xf) | ||
87 | #define HW_SSP_TIMING (ssp_is_old() ? 0x050 : 0x070) | ||
88 | #define BP_SSP_TIMING_TIMEOUT (16) | ||
89 | #define BM_SSP_TIMING_TIMEOUT (0xffff << 16) | ||
90 | #define BP_SSP_TIMING_CLOCK_DIVIDE (8) | ||
91 | #define BM_SSP_TIMING_CLOCK_DIVIDE (0xff << 8) | ||
92 | #define BP_SSP_TIMING_CLOCK_RATE (0) | ||
93 | #define BM_SSP_TIMING_CLOCK_RATE (0xff) | ||
94 | #define HW_SSP_CTRL1 (ssp_is_old() ? 0x060 : 0x080) | ||
95 | #define BM_SSP_CTRL1_SDIO_IRQ (1 << 31) | ||
96 | #define BM_SSP_CTRL1_SDIO_IRQ_EN (1 << 30) | ||
97 | #define BM_SSP_CTRL1_RESP_ERR_IRQ (1 << 29) | ||
98 | #define BM_SSP_CTRL1_RESP_ERR_IRQ_EN (1 << 28) | ||
99 | #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ (1 << 27) | ||
100 | #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN (1 << 26) | ||
101 | #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ (1 << 25) | ||
102 | #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN (1 << 24) | ||
103 | #define BM_SSP_CTRL1_DATA_CRC_IRQ (1 << 23) | ||
104 | #define BM_SSP_CTRL1_DATA_CRC_IRQ_EN (1 << 22) | ||
105 | #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ (1 << 21) | ||
106 | #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN (1 << 20) | ||
107 | #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ (1 << 17) | ||
108 | #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN (1 << 16) | ||
109 | #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ (1 << 15) | ||
110 | #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN (1 << 14) | ||
111 | #define BM_SSP_CTRL1_DMA_ENABLE (1 << 13) | ||
112 | #define BM_SSP_CTRL1_POLARITY (1 << 9) | ||
113 | #define BP_SSP_CTRL1_WORD_LENGTH (4) | ||
114 | #define BM_SSP_CTRL1_WORD_LENGTH (0xf << 4) | ||
115 | #define BP_SSP_CTRL1_SSP_MODE (0) | ||
116 | #define BM_SSP_CTRL1_SSP_MODE (0xf) | ||
117 | #define HW_SSP_SDRESP0 (ssp_is_old() ? 0x080 : 0x0a0) | ||
118 | #define HW_SSP_SDRESP1 (ssp_is_old() ? 0x090 : 0x0b0) | ||
119 | #define HW_SSP_SDRESP2 (ssp_is_old() ? 0x0a0 : 0x0c0) | ||
120 | #define HW_SSP_SDRESP3 (ssp_is_old() ? 0x0b0 : 0x0d0) | ||
121 | #define HW_SSP_STATUS (ssp_is_old() ? 0x0c0 : 0x100) | ||
122 | #define BM_SSP_STATUS_CARD_DETECT (1 << 28) | ||
123 | #define BM_SSP_STATUS_SDIO_IRQ (1 << 17) | ||
124 | #define HW_SSP_VERSION (cpu_is_mx23() ? 0x110 : 0x130) | ||
125 | #define BP_SSP_VERSION_MAJOR (24) | ||
126 | |||
127 | #define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field) | ||
128 | |||
129 | #define MXS_MMC_IRQ_BITS (BM_SSP_CTRL1_SDIO_IRQ | \ | ||
130 | BM_SSP_CTRL1_RESP_ERR_IRQ | \ | ||
131 | BM_SSP_CTRL1_RESP_TIMEOUT_IRQ | \ | ||
132 | BM_SSP_CTRL1_DATA_TIMEOUT_IRQ | \ | ||
133 | BM_SSP_CTRL1_DATA_CRC_IRQ | \ | ||
134 | BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ | \ | ||
135 | BM_SSP_CTRL1_RECV_TIMEOUT_IRQ | \ | ||
136 | BM_SSP_CTRL1_FIFO_OVERRUN_IRQ) | ||
137 | |||
138 | #define SSP_PIO_NUM 3 | ||
139 | |||
140 | struct mxs_mmc_host { | ||
141 | struct mmc_host *mmc; | ||
142 | struct mmc_request *mrq; | ||
143 | struct mmc_command *cmd; | ||
144 | struct mmc_data *data; | ||
145 | |||
146 | void __iomem *base; | ||
147 | int irq; | ||
148 | struct resource *res; | ||
149 | struct resource *dma_res; | ||
150 | struct clk *clk; | ||
151 | unsigned int clk_rate; | ||
152 | |||
153 | struct dma_chan *dmach; | ||
154 | struct mxs_dma_data dma_data; | ||
155 | unsigned int dma_dir; | ||
156 | u32 ssp_pio_words[SSP_PIO_NUM]; | ||
157 | |||
158 | unsigned int version; | ||
159 | unsigned char bus_width; | ||
160 | spinlock_t lock; | ||
161 | int sdio_irq_en; | ||
162 | }; | ||
163 | |||
164 | static int mxs_mmc_get_ro(struct mmc_host *mmc) | ||
165 | { | ||
166 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
167 | struct mxs_mmc_platform_data *pdata = | ||
168 | mmc_dev(host->mmc)->platform_data; | ||
169 | |||
170 | if (!pdata) | ||
171 | return -EFAULT; | ||
172 | |||
173 | if (!gpio_is_valid(pdata->wp_gpio)) | ||
174 | return -EINVAL; | ||
175 | |||
176 | return gpio_get_value(pdata->wp_gpio); | ||
177 | } | ||
178 | |||
179 | static int mxs_mmc_get_cd(struct mmc_host *mmc) | ||
180 | { | ||
181 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
182 | |||
183 | return !(readl(host->base + HW_SSP_STATUS) & | ||
184 | BM_SSP_STATUS_CARD_DETECT); | ||
185 | } | ||
186 | |||
187 | static void mxs_mmc_reset(struct mxs_mmc_host *host) | ||
188 | { | ||
189 | u32 ctrl0, ctrl1; | ||
190 | |||
191 | mxs_reset_block(host->base); | ||
192 | |||
193 | ctrl0 = BM_SSP_CTRL0_IGNORE_CRC; | ||
194 | ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) | | ||
195 | BF_SSP(0x7, CTRL1_WORD_LENGTH) | | ||
196 | BM_SSP_CTRL1_DMA_ENABLE | | ||
197 | BM_SSP_CTRL1_POLARITY | | ||
198 | BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN | | ||
199 | BM_SSP_CTRL1_DATA_CRC_IRQ_EN | | ||
200 | BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN | | ||
201 | BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN | | ||
202 | BM_SSP_CTRL1_RESP_ERR_IRQ_EN; | ||
203 | |||
204 | writel(BF_SSP(0xffff, TIMING_TIMEOUT) | | ||
205 | BF_SSP(2, TIMING_CLOCK_DIVIDE) | | ||
206 | BF_SSP(0, TIMING_CLOCK_RATE), | ||
207 | host->base + HW_SSP_TIMING); | ||
208 | |||
209 | if (host->sdio_irq_en) { | ||
210 | ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK; | ||
211 | ctrl1 |= BM_SSP_CTRL1_SDIO_IRQ_EN; | ||
212 | } | ||
213 | |||
214 | writel(ctrl0, host->base + HW_SSP_CTRL0); | ||
215 | writel(ctrl1, host->base + HW_SSP_CTRL1); | ||
216 | } | ||
217 | |||
218 | static void mxs_mmc_start_cmd(struct mxs_mmc_host *host, | ||
219 | struct mmc_command *cmd); | ||
220 | |||
221 | static void mxs_mmc_request_done(struct mxs_mmc_host *host) | ||
222 | { | ||
223 | struct mmc_command *cmd = host->cmd; | ||
224 | struct mmc_data *data = host->data; | ||
225 | struct mmc_request *mrq = host->mrq; | ||
226 | |||
227 | if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) { | ||
228 | if (mmc_resp_type(cmd) & MMC_RSP_136) { | ||
229 | cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0); | ||
230 | cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1); | ||
231 | cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2); | ||
232 | cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3); | ||
233 | } else { | ||
234 | cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | if (data) { | ||
239 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, | ||
240 | data->sg_len, host->dma_dir); | ||
241 | /* | ||
242 | * If there was an error on any block, we mark all | ||
243 | * data blocks as being in error. | ||
244 | */ | ||
245 | if (!data->error) | ||
246 | data->bytes_xfered = data->blocks * data->blksz; | ||
247 | else | ||
248 | data->bytes_xfered = 0; | ||
249 | |||
250 | host->data = NULL; | ||
251 | if (mrq->stop) { | ||
252 | mxs_mmc_start_cmd(host, mrq->stop); | ||
253 | return; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | host->mrq = NULL; | ||
258 | mmc_request_done(host->mmc, mrq); | ||
259 | } | ||
260 | |||
261 | static void mxs_mmc_dma_irq_callback(void *param) | ||
262 | { | ||
263 | struct mxs_mmc_host *host = param; | ||
264 | |||
265 | mxs_mmc_request_done(host); | ||
266 | } | ||
267 | |||
268 | static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id) | ||
269 | { | ||
270 | struct mxs_mmc_host *host = dev_id; | ||
271 | struct mmc_command *cmd = host->cmd; | ||
272 | struct mmc_data *data = host->data; | ||
273 | u32 stat; | ||
274 | |||
275 | spin_lock(&host->lock); | ||
276 | |||
277 | stat = readl(host->base + HW_SSP_CTRL1); | ||
278 | writel(stat & MXS_MMC_IRQ_BITS, | ||
279 | host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR); | ||
280 | |||
281 | if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN)) | ||
282 | mmc_signal_sdio_irq(host->mmc); | ||
283 | |||
284 | spin_unlock(&host->lock); | ||
285 | |||
286 | if (stat & BM_SSP_CTRL1_RESP_TIMEOUT_IRQ) | ||
287 | cmd->error = -ETIMEDOUT; | ||
288 | else if (stat & BM_SSP_CTRL1_RESP_ERR_IRQ) | ||
289 | cmd->error = -EIO; | ||
290 | |||
291 | if (data) { | ||
292 | if (stat & (BM_SSP_CTRL1_DATA_TIMEOUT_IRQ | | ||
293 | BM_SSP_CTRL1_RECV_TIMEOUT_IRQ)) | ||
294 | data->error = -ETIMEDOUT; | ||
295 | else if (stat & BM_SSP_CTRL1_DATA_CRC_IRQ) | ||
296 | data->error = -EILSEQ; | ||
297 | else if (stat & (BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ | | ||
298 | BM_SSP_CTRL1_FIFO_OVERRUN_IRQ)) | ||
299 | data->error = -EIO; | ||
300 | } | ||
301 | |||
302 | return IRQ_HANDLED; | ||
303 | } | ||
304 | |||
305 | static struct dma_async_tx_descriptor *mxs_mmc_prep_dma( | ||
306 | struct mxs_mmc_host *host, unsigned int append) | ||
307 | { | ||
308 | struct dma_async_tx_descriptor *desc; | ||
309 | struct mmc_data *data = host->data; | ||
310 | struct scatterlist * sgl; | ||
311 | unsigned int sg_len; | ||
312 | |||
313 | if (data) { | ||
314 | /* data */ | ||
315 | dma_map_sg(mmc_dev(host->mmc), data->sg, | ||
316 | data->sg_len, host->dma_dir); | ||
317 | sgl = data->sg; | ||
318 | sg_len = data->sg_len; | ||
319 | } else { | ||
320 | /* pio */ | ||
321 | sgl = (struct scatterlist *) host->ssp_pio_words; | ||
322 | sg_len = SSP_PIO_NUM; | ||
323 | } | ||
324 | |||
325 | desc = host->dmach->device->device_prep_slave_sg(host->dmach, | ||
326 | sgl, sg_len, host->dma_dir, append); | ||
327 | if (desc) { | ||
328 | desc->callback = mxs_mmc_dma_irq_callback; | ||
329 | desc->callback_param = host; | ||
330 | } else { | ||
331 | if (data) | ||
332 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, | ||
333 | data->sg_len, host->dma_dir); | ||
334 | } | ||
335 | |||
336 | return desc; | ||
337 | } | ||
338 | |||
339 | static void mxs_mmc_bc(struct mxs_mmc_host *host) | ||
340 | { | ||
341 | struct mmc_command *cmd = host->cmd; | ||
342 | struct dma_async_tx_descriptor *desc; | ||
343 | u32 ctrl0, cmd0, cmd1; | ||
344 | |||
345 | ctrl0 = BM_SSP_CTRL0_ENABLE | BM_SSP_CTRL0_IGNORE_CRC; | ||
346 | cmd0 = BF_SSP(cmd->opcode, CMD0_CMD) | BM_SSP_CMD0_APPEND_8CYC; | ||
347 | cmd1 = cmd->arg; | ||
348 | |||
349 | if (host->sdio_irq_en) { | ||
350 | ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK; | ||
351 | cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN; | ||
352 | } | ||
353 | |||
354 | host->ssp_pio_words[0] = ctrl0; | ||
355 | host->ssp_pio_words[1] = cmd0; | ||
356 | host->ssp_pio_words[2] = cmd1; | ||
357 | host->dma_dir = DMA_NONE; | ||
358 | desc = mxs_mmc_prep_dma(host, 0); | ||
359 | if (!desc) | ||
360 | goto out; | ||
361 | |||
362 | dmaengine_submit(desc); | ||
363 | return; | ||
364 | |||
365 | out: | ||
366 | dev_warn(mmc_dev(host->mmc), | ||
367 | "%s: failed to prep dma\n", __func__); | ||
368 | } | ||
369 | |||
370 | static void mxs_mmc_ac(struct mxs_mmc_host *host) | ||
371 | { | ||
372 | struct mmc_command *cmd = host->cmd; | ||
373 | struct dma_async_tx_descriptor *desc; | ||
374 | u32 ignore_crc, get_resp, long_resp; | ||
375 | u32 ctrl0, cmd0, cmd1; | ||
376 | |||
377 | ignore_crc = (mmc_resp_type(cmd) & MMC_RSP_CRC) ? | ||
378 | 0 : BM_SSP_CTRL0_IGNORE_CRC; | ||
379 | get_resp = (mmc_resp_type(cmd) & MMC_RSP_PRESENT) ? | ||
380 | BM_SSP_CTRL0_GET_RESP : 0; | ||
381 | long_resp = (mmc_resp_type(cmd) & MMC_RSP_136) ? | ||
382 | BM_SSP_CTRL0_LONG_RESP : 0; | ||
383 | |||
384 | ctrl0 = BM_SSP_CTRL0_ENABLE | ignore_crc | get_resp | long_resp; | ||
385 | cmd0 = BF_SSP(cmd->opcode, CMD0_CMD); | ||
386 | cmd1 = cmd->arg; | ||
387 | |||
388 | if (host->sdio_irq_en) { | ||
389 | ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK; | ||
390 | cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN; | ||
391 | } | ||
392 | |||
393 | host->ssp_pio_words[0] = ctrl0; | ||
394 | host->ssp_pio_words[1] = cmd0; | ||
395 | host->ssp_pio_words[2] = cmd1; | ||
396 | host->dma_dir = DMA_NONE; | ||
397 | desc = mxs_mmc_prep_dma(host, 0); | ||
398 | if (!desc) | ||
399 | goto out; | ||
400 | |||
401 | dmaengine_submit(desc); | ||
402 | return; | ||
403 | |||
404 | out: | ||
405 | dev_warn(mmc_dev(host->mmc), | ||
406 | "%s: failed to prep dma\n", __func__); | ||
407 | } | ||
408 | |||
409 | static unsigned short mxs_ns_to_ssp_ticks(unsigned clock_rate, unsigned ns) | ||
410 | { | ||
411 | const unsigned int ssp_timeout_mul = 4096; | ||
412 | /* | ||
413 | * Calculate ticks in ms since ns are large numbers | ||
414 | * and might overflow | ||
415 | */ | ||
416 | const unsigned int clock_per_ms = clock_rate / 1000; | ||
417 | const unsigned int ms = ns / 1000; | ||
418 | const unsigned int ticks = ms * clock_per_ms; | ||
419 | const unsigned int ssp_ticks = ticks / ssp_timeout_mul; | ||
420 | |||
421 | WARN_ON(ssp_ticks == 0); | ||
422 | return ssp_ticks; | ||
423 | } | ||
424 | |||
425 | static void mxs_mmc_adtc(struct mxs_mmc_host *host) | ||
426 | { | ||
427 | struct mmc_command *cmd = host->cmd; | ||
428 | struct mmc_data *data = cmd->data; | ||
429 | struct dma_async_tx_descriptor *desc; | ||
430 | struct scatterlist *sgl = data->sg, *sg; | ||
431 | unsigned int sg_len = data->sg_len; | ||
432 | int i; | ||
433 | |||
434 | unsigned short dma_data_dir, timeout; | ||
435 | unsigned int data_size = 0, log2_blksz; | ||
436 | unsigned int blocks = data->blocks; | ||
437 | |||
438 | u32 ignore_crc, get_resp, long_resp, read; | ||
439 | u32 ctrl0, cmd0, cmd1, val; | ||
440 | |||
441 | ignore_crc = (mmc_resp_type(cmd) & MMC_RSP_CRC) ? | ||
442 | 0 : BM_SSP_CTRL0_IGNORE_CRC; | ||
443 | get_resp = (mmc_resp_type(cmd) & MMC_RSP_PRESENT) ? | ||
444 | BM_SSP_CTRL0_GET_RESP : 0; | ||
445 | long_resp = (mmc_resp_type(cmd) & MMC_RSP_136) ? | ||
446 | BM_SSP_CTRL0_LONG_RESP : 0; | ||
447 | |||
448 | if (data->flags & MMC_DATA_WRITE) { | ||
449 | dma_data_dir = DMA_TO_DEVICE; | ||
450 | read = 0; | ||
451 | } else { | ||
452 | dma_data_dir = DMA_FROM_DEVICE; | ||
453 | read = BM_SSP_CTRL0_READ; | ||
454 | } | ||
455 | |||
456 | ctrl0 = BF_SSP(host->bus_width, CTRL0_BUS_WIDTH) | | ||
457 | ignore_crc | get_resp | long_resp | | ||
458 | BM_SSP_CTRL0_DATA_XFER | read | | ||
459 | BM_SSP_CTRL0_WAIT_FOR_IRQ | | ||
460 | BM_SSP_CTRL0_ENABLE; | ||
461 | |||
462 | cmd0 = BF_SSP(cmd->opcode, CMD0_CMD); | ||
463 | |||
464 | /* get logarithm to base 2 of block size for setting register */ | ||
465 | log2_blksz = ilog2(data->blksz); | ||
466 | |||
467 | /* | ||
468 | * take special care of the case that data size from data->sg | ||
469 | * is not equal to blocks x blksz | ||
470 | */ | ||
471 | for_each_sg(sgl, sg, sg_len, i) | ||
472 | data_size += sg->length; | ||
473 | |||
474 | if (data_size != data->blocks * data->blksz) | ||
475 | blocks = 1; | ||
476 | |||
477 | /* xfer count, block size and count need to be set differently */ | ||
478 | if (ssp_is_old()) { | ||
479 | ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT); | ||
480 | cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) | | ||
481 | BF_SSP(blocks - 1, CMD0_BLOCK_COUNT); | ||
482 | } else { | ||
483 | writel(data_size, host->base + HW_SSP_XFER_SIZE); | ||
484 | writel(BF_SSP(log2_blksz, BLOCK_SIZE_BLOCK_SIZE) | | ||
485 | BF_SSP(blocks - 1, BLOCK_SIZE_BLOCK_COUNT), | ||
486 | host->base + HW_SSP_BLOCK_SIZE); | ||
487 | } | ||
488 | |||
489 | if ((cmd->opcode == MMC_STOP_TRANSMISSION) || | ||
490 | (cmd->opcode == SD_IO_RW_EXTENDED)) | ||
491 | cmd0 |= BM_SSP_CMD0_APPEND_8CYC; | ||
492 | |||
493 | cmd1 = cmd->arg; | ||
494 | |||
495 | if (host->sdio_irq_en) { | ||
496 | ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK; | ||
497 | cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN; | ||
498 | } | ||
499 | |||
500 | /* set the timeout count */ | ||
501 | timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns); | ||
502 | val = readl(host->base + HW_SSP_TIMING); | ||
503 | val &= ~(BM_SSP_TIMING_TIMEOUT); | ||
504 | val |= BF_SSP(timeout, TIMING_TIMEOUT); | ||
505 | writel(val, host->base + HW_SSP_TIMING); | ||
506 | |||
507 | /* pio */ | ||
508 | host->ssp_pio_words[0] = ctrl0; | ||
509 | host->ssp_pio_words[1] = cmd0; | ||
510 | host->ssp_pio_words[2] = cmd1; | ||
511 | host->dma_dir = DMA_NONE; | ||
512 | desc = mxs_mmc_prep_dma(host, 0); | ||
513 | if (!desc) | ||
514 | goto out; | ||
515 | |||
516 | /* append data sg */ | ||
517 | WARN_ON(host->data != NULL); | ||
518 | host->data = data; | ||
519 | host->dma_dir = dma_data_dir; | ||
520 | desc = mxs_mmc_prep_dma(host, 1); | ||
521 | if (!desc) | ||
522 | goto out; | ||
523 | |||
524 | dmaengine_submit(desc); | ||
525 | return; | ||
526 | out: | ||
527 | dev_warn(mmc_dev(host->mmc), | ||
528 | "%s: failed to prep dma\n", __func__); | ||
529 | } | ||
530 | |||
531 | static void mxs_mmc_start_cmd(struct mxs_mmc_host *host, | ||
532 | struct mmc_command *cmd) | ||
533 | { | ||
534 | host->cmd = cmd; | ||
535 | |||
536 | switch (mmc_cmd_type(cmd)) { | ||
537 | case MMC_CMD_BC: | ||
538 | mxs_mmc_bc(host); | ||
539 | break; | ||
540 | case MMC_CMD_BCR: | ||
541 | mxs_mmc_ac(host); | ||
542 | break; | ||
543 | case MMC_CMD_AC: | ||
544 | mxs_mmc_ac(host); | ||
545 | break; | ||
546 | case MMC_CMD_ADTC: | ||
547 | mxs_mmc_adtc(host); | ||
548 | break; | ||
549 | default: | ||
550 | dev_warn(mmc_dev(host->mmc), | ||
551 | "%s: unknown MMC command\n", __func__); | ||
552 | break; | ||
553 | } | ||
554 | } | ||
555 | |||
556 | static void mxs_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) | ||
557 | { | ||
558 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
559 | |||
560 | WARN_ON(host->mrq != NULL); | ||
561 | host->mrq = mrq; | ||
562 | mxs_mmc_start_cmd(host, mrq->cmd); | ||
563 | } | ||
564 | |||
565 | static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate) | ||
566 | { | ||
567 | unsigned int ssp_rate, bit_rate; | ||
568 | u32 div1, div2; | ||
569 | u32 val; | ||
570 | |||
571 | ssp_rate = clk_get_rate(host->clk); | ||
572 | |||
573 | for (div1 = 2; div1 < 254; div1 += 2) { | ||
574 | div2 = ssp_rate / rate / div1; | ||
575 | if (div2 < 0x100) | ||
576 | break; | ||
577 | } | ||
578 | |||
579 | if (div1 >= 254) { | ||
580 | dev_err(mmc_dev(host->mmc), | ||
581 | "%s: cannot set clock to %d\n", __func__, rate); | ||
582 | return; | ||
583 | } | ||
584 | |||
585 | if (div2 == 0) | ||
586 | bit_rate = ssp_rate / div1; | ||
587 | else | ||
588 | bit_rate = ssp_rate / div1 / div2; | ||
589 | |||
590 | val = readl(host->base + HW_SSP_TIMING); | ||
591 | val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE); | ||
592 | val |= BF_SSP(div1, TIMING_CLOCK_DIVIDE); | ||
593 | val |= BF_SSP(div2 - 1, TIMING_CLOCK_RATE); | ||
594 | writel(val, host->base + HW_SSP_TIMING); | ||
595 | |||
596 | host->clk_rate = bit_rate; | ||
597 | |||
598 | dev_dbg(mmc_dev(host->mmc), | ||
599 | "%s: div1 %d, div2 %d, ssp %d, bit %d, rate %d\n", | ||
600 | __func__, div1, div2, ssp_rate, bit_rate, rate); | ||
601 | } | ||
602 | |||
603 | static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | ||
604 | { | ||
605 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
606 | |||
607 | if (ios->bus_width == MMC_BUS_WIDTH_8) | ||
608 | host->bus_width = 2; | ||
609 | else if (ios->bus_width == MMC_BUS_WIDTH_4) | ||
610 | host->bus_width = 1; | ||
611 | else | ||
612 | host->bus_width = 0; | ||
613 | |||
614 | if (ios->clock) | ||
615 | mxs_mmc_set_clk_rate(host, ios->clock); | ||
616 | } | ||
617 | |||
618 | static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) | ||
619 | { | ||
620 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
621 | unsigned long flags; | ||
622 | |||
623 | spin_lock_irqsave(&host->lock, flags); | ||
624 | |||
625 | host->sdio_irq_en = enable; | ||
626 | |||
627 | if (enable) { | ||
628 | writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK, | ||
629 | host->base + HW_SSP_CTRL0 + MXS_SET_ADDR); | ||
630 | writel(BM_SSP_CTRL1_SDIO_IRQ_EN, | ||
631 | host->base + HW_SSP_CTRL1 + MXS_SET_ADDR); | ||
632 | |||
633 | if (readl(host->base + HW_SSP_STATUS) & BM_SSP_STATUS_SDIO_IRQ) | ||
634 | mmc_signal_sdio_irq(host->mmc); | ||
635 | |||
636 | } else { | ||
637 | writel(BM_SSP_CTRL0_SDIO_IRQ_CHECK, | ||
638 | host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR); | ||
639 | writel(BM_SSP_CTRL1_SDIO_IRQ_EN, | ||
640 | host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR); | ||
641 | } | ||
642 | |||
643 | spin_unlock_irqrestore(&host->lock, flags); | ||
644 | } | ||
645 | |||
646 | static const struct mmc_host_ops mxs_mmc_ops = { | ||
647 | .request = mxs_mmc_request, | ||
648 | .get_ro = mxs_mmc_get_ro, | ||
649 | .get_cd = mxs_mmc_get_cd, | ||
650 | .set_ios = mxs_mmc_set_ios, | ||
651 | .enable_sdio_irq = mxs_mmc_enable_sdio_irq, | ||
652 | }; | ||
653 | |||
654 | static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param) | ||
655 | { | ||
656 | struct mxs_mmc_host *host = param; | ||
657 | |||
658 | if (!mxs_dma_is_apbh(chan)) | ||
659 | return false; | ||
660 | |||
661 | if (chan->chan_id != host->dma_res->start) | ||
662 | return false; | ||
663 | |||
664 | chan->private = &host->dma_data; | ||
665 | |||
666 | return true; | ||
667 | } | ||
668 | |||
669 | static int mxs_mmc_probe(struct platform_device *pdev) | ||
670 | { | ||
671 | struct mxs_mmc_host *host; | ||
672 | struct mmc_host *mmc; | ||
673 | struct resource *iores, *dmares, *r; | ||
674 | struct mxs_mmc_platform_data *pdata; | ||
675 | int ret = 0, irq_err, irq_dma; | ||
676 | dma_cap_mask_t mask; | ||
677 | |||
678 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
679 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
680 | irq_err = platform_get_irq(pdev, 0); | ||
681 | irq_dma = platform_get_irq(pdev, 1); | ||
682 | if (!iores || !dmares || irq_err < 0 || irq_dma < 0) | ||
683 | return -EINVAL; | ||
684 | |||
685 | r = request_mem_region(iores->start, resource_size(iores), pdev->name); | ||
686 | if (!r) | ||
687 | return -EBUSY; | ||
688 | |||
689 | mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev); | ||
690 | if (!mmc) { | ||
691 | ret = -ENOMEM; | ||
692 | goto out_release_mem; | ||
693 | } | ||
694 | |||
695 | host = mmc_priv(mmc); | ||
696 | host->base = ioremap(r->start, resource_size(r)); | ||
697 | if (!host->base) { | ||
698 | ret = -ENOMEM; | ||
699 | goto out_mmc_free; | ||
700 | } | ||
701 | |||
702 | /* only major verion does matter */ | ||
703 | host->version = readl(host->base + HW_SSP_VERSION) >> | ||
704 | BP_SSP_VERSION_MAJOR; | ||
705 | |||
706 | host->mmc = mmc; | ||
707 | host->res = r; | ||
708 | host->dma_res = dmares; | ||
709 | host->irq = irq_err; | ||
710 | host->sdio_irq_en = 0; | ||
711 | |||
712 | host->clk = clk_get(&pdev->dev, NULL); | ||
713 | if (IS_ERR(host->clk)) { | ||
714 | ret = PTR_ERR(host->clk); | ||
715 | goto out_iounmap; | ||
716 | } | ||
717 | clk_enable(host->clk); | ||
718 | |||
719 | mxs_mmc_reset(host); | ||
720 | |||
721 | dma_cap_zero(mask); | ||
722 | dma_cap_set(DMA_SLAVE, mask); | ||
723 | host->dma_data.chan_irq = irq_dma; | ||
724 | host->dmach = dma_request_channel(mask, mxs_mmc_dma_filter, host); | ||
725 | if (!host->dmach) { | ||
726 | dev_err(mmc_dev(host->mmc), | ||
727 | "%s: failed to request dma\n", __func__); | ||
728 | goto out_clk_put; | ||
729 | } | ||
730 | |||
731 | /* set mmc core parameters */ | ||
732 | mmc->ops = &mxs_mmc_ops; | ||
733 | mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | | ||
734 | MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; | ||
735 | |||
736 | pdata = mmc_dev(host->mmc)->platform_data; | ||
737 | if (pdata) { | ||
738 | if (pdata->flags & SLOTF_8_BIT_CAPABLE) | ||
739 | mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA; | ||
740 | if (pdata->flags & SLOTF_4_BIT_CAPABLE) | ||
741 | mmc->caps |= MMC_CAP_4_BIT_DATA; | ||
742 | } | ||
743 | |||
744 | mmc->f_min = 400000; | ||
745 | mmc->f_max = 288000000; | ||
746 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | ||
747 | |||
748 | mmc->max_segs = 52; | ||
749 | mmc->max_blk_size = 1 << 0xf; | ||
750 | mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff; | ||
751 | mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff; | ||
752 | mmc->max_seg_size = dma_get_max_seg_size(host->dmach->device->dev); | ||
753 | |||
754 | platform_set_drvdata(pdev, mmc); | ||
755 | |||
756 | ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host); | ||
757 | if (ret) | ||
758 | goto out_free_dma; | ||
759 | |||
760 | spin_lock_init(&host->lock); | ||
761 | |||
762 | ret = mmc_add_host(mmc); | ||
763 | if (ret) | ||
764 | goto out_free_irq; | ||
765 | |||
766 | dev_info(mmc_dev(host->mmc), "initialized\n"); | ||
767 | |||
768 | return 0; | ||
769 | |||
770 | out_free_irq: | ||
771 | free_irq(host->irq, host); | ||
772 | out_free_dma: | ||
773 | if (host->dmach) | ||
774 | dma_release_channel(host->dmach); | ||
775 | out_clk_put: | ||
776 | clk_disable(host->clk); | ||
777 | clk_put(host->clk); | ||
778 | out_iounmap: | ||
779 | iounmap(host->base); | ||
780 | out_mmc_free: | ||
781 | mmc_free_host(mmc); | ||
782 | out_release_mem: | ||
783 | release_mem_region(iores->start, resource_size(iores)); | ||
784 | return ret; | ||
785 | } | ||
786 | |||
787 | static int mxs_mmc_remove(struct platform_device *pdev) | ||
788 | { | ||
789 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
790 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
791 | struct resource *res = host->res; | ||
792 | |||
793 | mmc_remove_host(mmc); | ||
794 | |||
795 | free_irq(host->irq, host); | ||
796 | |||
797 | platform_set_drvdata(pdev, NULL); | ||
798 | |||
799 | if (host->dmach) | ||
800 | dma_release_channel(host->dmach); | ||
801 | |||
802 | clk_disable(host->clk); | ||
803 | clk_put(host->clk); | ||
804 | |||
805 | iounmap(host->base); | ||
806 | |||
807 | mmc_free_host(mmc); | ||
808 | |||
809 | release_mem_region(res->start, resource_size(res)); | ||
810 | |||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | #ifdef CONFIG_PM | ||
815 | static int mxs_mmc_suspend(struct device *dev) | ||
816 | { | ||
817 | struct mmc_host *mmc = dev_get_drvdata(dev); | ||
818 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
819 | int ret = 0; | ||
820 | |||
821 | ret = mmc_suspend_host(mmc); | ||
822 | |||
823 | clk_disable(host->clk); | ||
824 | |||
825 | return ret; | ||
826 | } | ||
827 | |||
828 | static int mxs_mmc_resume(struct device *dev) | ||
829 | { | ||
830 | struct mmc_host *mmc = dev_get_drvdata(dev); | ||
831 | struct mxs_mmc_host *host = mmc_priv(mmc); | ||
832 | int ret = 0; | ||
833 | |||
834 | clk_enable(host->clk); | ||
835 | |||
836 | ret = mmc_resume_host(mmc); | ||
837 | |||
838 | return ret; | ||
839 | } | ||
840 | |||
841 | static const struct dev_pm_ops mxs_mmc_pm_ops = { | ||
842 | .suspend = mxs_mmc_suspend, | ||
843 | .resume = mxs_mmc_resume, | ||
844 | }; | ||
845 | #endif | ||
846 | |||
847 | static struct platform_driver mxs_mmc_driver = { | ||
848 | .probe = mxs_mmc_probe, | ||
849 | .remove = mxs_mmc_remove, | ||
850 | .driver = { | ||
851 | .name = DRIVER_NAME, | ||
852 | .owner = THIS_MODULE, | ||
853 | #ifdef CONFIG_PM | ||
854 | .pm = &mxs_mmc_pm_ops, | ||
855 | #endif | ||
856 | }, | ||
857 | }; | ||
858 | |||
859 | static int __init mxs_mmc_init(void) | ||
860 | { | ||
861 | return platform_driver_register(&mxs_mmc_driver); | ||
862 | } | ||
863 | |||
864 | static void __exit mxs_mmc_exit(void) | ||
865 | { | ||
866 | platform_driver_unregister(&mxs_mmc_driver); | ||
867 | } | ||
868 | |||
869 | module_init(mxs_mmc_init); | ||
870 | module_exit(mxs_mmc_exit); | ||
871 | |||
872 | MODULE_DESCRIPTION("FREESCALE MXS MMC peripheral"); | ||
873 | MODULE_AUTHOR("Freescale Semiconductor"); | ||
874 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 9b82910b9dbb..3b5248567973 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -15,9 +15,11 @@ | |||
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #include <linux/gpio.h> | ||
18 | #include <linux/mmc/host.h> | 19 | #include <linux/mmc/host.h> |
19 | #include <linux/mmc/sdhci-pltfm.h> | 20 | #include <linux/mmc/sdhci-pltfm.h> |
20 | #include <mach/hardware.h> | 21 | #include <mach/hardware.h> |
22 | #include <mach/esdhc.h> | ||
21 | #include "sdhci.h" | 23 | #include "sdhci.h" |
22 | #include "sdhci-pltfm.h" | 24 | #include "sdhci-pltfm.h" |
23 | #include "sdhci-esdhc.h" | 25 | #include "sdhci-esdhc.h" |
@@ -30,6 +32,39 @@ static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, i | |||
30 | writel(((readl(base) & ~(mask << shift)) | (val << shift)), base); | 32 | writel(((readl(base) & ~(mask << shift)) | (val << shift)), base); |
31 | } | 33 | } |
32 | 34 | ||
35 | static u32 esdhc_readl_le(struct sdhci_host *host, int reg) | ||
36 | { | ||
37 | /* fake CARD_PRESENT flag on mx25/35 */ | ||
38 | u32 val = readl(host->ioaddr + reg); | ||
39 | |||
40 | if (unlikely(reg == SDHCI_PRESENT_STATE)) { | ||
41 | struct esdhc_platform_data *boarddata = | ||
42 | host->mmc->parent->platform_data; | ||
43 | |||
44 | if (boarddata && gpio_is_valid(boarddata->cd_gpio) | ||
45 | && gpio_get_value(boarddata->cd_gpio)) | ||
46 | /* no card, if a valid gpio says so... */ | ||
47 | val &= SDHCI_CARD_PRESENT; | ||
48 | else | ||
49 | /* ... in all other cases assume card is present */ | ||
50 | val |= SDHCI_CARD_PRESENT; | ||
51 | } | ||
52 | |||
53 | return val; | ||
54 | } | ||
55 | |||
56 | static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) | ||
57 | { | ||
58 | if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) | ||
59 | /* | ||
60 | * these interrupts won't work with a custom card_detect gpio | ||
61 | * (only applied to mx25/35) | ||
62 | */ | ||
63 | val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT); | ||
64 | |||
65 | writel(val, host->ioaddr + reg); | ||
66 | } | ||
67 | |||
33 | static u16 esdhc_readw_le(struct sdhci_host *host, int reg) | 68 | static u16 esdhc_readw_le(struct sdhci_host *host, int reg) |
34 | { | 69 | { |
35 | if (unlikely(reg == SDHCI_HOST_VERSION)) | 70 | if (unlikely(reg == SDHCI_HOST_VERSION)) |
@@ -100,10 +135,39 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) | |||
100 | return clk_get_rate(pltfm_host->clk) / 256 / 16; | 135 | return clk_get_rate(pltfm_host->clk) / 256 / 16; |
101 | } | 136 | } |
102 | 137 | ||
138 | static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host) | ||
139 | { | ||
140 | struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data; | ||
141 | |||
142 | if (boarddata && gpio_is_valid(boarddata->wp_gpio)) | ||
143 | return gpio_get_value(boarddata->wp_gpio); | ||
144 | else | ||
145 | return -ENOSYS; | ||
146 | } | ||
147 | |||
148 | static struct sdhci_ops sdhci_esdhc_ops = { | ||
149 | .read_w = esdhc_readw_le, | ||
150 | .write_w = esdhc_writew_le, | ||
151 | .write_b = esdhc_writeb_le, | ||
152 | .set_clock = esdhc_set_clock, | ||
153 | .get_max_clock = esdhc_pltfm_get_max_clock, | ||
154 | .get_min_clock = esdhc_pltfm_get_min_clock, | ||
155 | }; | ||
156 | |||
157 | static irqreturn_t cd_irq(int irq, void *data) | ||
158 | { | ||
159 | struct sdhci_host *sdhost = (struct sdhci_host *)data; | ||
160 | |||
161 | tasklet_schedule(&sdhost->card_tasklet); | ||
162 | return IRQ_HANDLED; | ||
163 | }; | ||
164 | |||
103 | static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata) | 165 | static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata) |
104 | { | 166 | { |
105 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 167 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
168 | struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data; | ||
106 | struct clk *clk; | 169 | struct clk *clk; |
170 | int err; | ||
107 | 171 | ||
108 | clk = clk_get(mmc_dev(host->mmc), NULL); | 172 | clk = clk_get(mmc_dev(host->mmc), NULL); |
109 | if (IS_ERR(clk)) { | 173 | if (IS_ERR(clk)) { |
@@ -116,32 +180,78 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd | |||
116 | if (cpu_is_mx35() || cpu_is_mx51()) | 180 | if (cpu_is_mx35() || cpu_is_mx51()) |
117 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; | 181 | host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; |
118 | 182 | ||
119 | /* Fix errata ENGcm07207 which is present on i.MX25 and i.MX35 */ | 183 | if (cpu_is_mx25() || cpu_is_mx35()) { |
120 | if (cpu_is_mx25() || cpu_is_mx35()) | 184 | /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */ |
121 | host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK; | 185 | host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK; |
186 | /* write_protect can't be routed to controller, use gpio */ | ||
187 | sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro; | ||
188 | } | ||
189 | |||
190 | if (boarddata) { | ||
191 | err = gpio_request_one(boarddata->wp_gpio, GPIOF_IN, "ESDHC_WP"); | ||
192 | if (err) { | ||
193 | dev_warn(mmc_dev(host->mmc), | ||
194 | "no write-protect pin available!\n"); | ||
195 | boarddata->wp_gpio = err; | ||
196 | } | ||
197 | |||
198 | err = gpio_request_one(boarddata->cd_gpio, GPIOF_IN, "ESDHC_CD"); | ||
199 | if (err) { | ||
200 | dev_warn(mmc_dev(host->mmc), | ||
201 | "no card-detect pin available!\n"); | ||
202 | goto no_card_detect_pin; | ||
203 | } | ||
204 | |||
205 | /* i.MX5x has issues to be researched */ | ||
206 | if (!cpu_is_mx25() && !cpu_is_mx35()) | ||
207 | goto not_supported; | ||
208 | |||
209 | err = request_irq(gpio_to_irq(boarddata->cd_gpio), cd_irq, | ||
210 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | ||
211 | mmc_hostname(host->mmc), host); | ||
212 | if (err) { | ||
213 | dev_warn(mmc_dev(host->mmc), "request irq error\n"); | ||
214 | goto no_card_detect_irq; | ||
215 | } | ||
216 | |||
217 | sdhci_esdhc_ops.write_l = esdhc_writel_le; | ||
218 | sdhci_esdhc_ops.read_l = esdhc_readl_le; | ||
219 | /* Now we have a working card_detect again */ | ||
220 | host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; | ||
221 | } | ||
222 | |||
223 | return 0; | ||
122 | 224 | ||
225 | no_card_detect_irq: | ||
226 | gpio_free(boarddata->cd_gpio); | ||
227 | no_card_detect_pin: | ||
228 | boarddata->cd_gpio = err; | ||
229 | not_supported: | ||
123 | return 0; | 230 | return 0; |
124 | } | 231 | } |
125 | 232 | ||
126 | static void esdhc_pltfm_exit(struct sdhci_host *host) | 233 | static void esdhc_pltfm_exit(struct sdhci_host *host) |
127 | { | 234 | { |
128 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 235 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
236 | struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data; | ||
237 | |||
238 | if (boarddata && gpio_is_valid(boarddata->wp_gpio)) | ||
239 | gpio_free(boarddata->wp_gpio); | ||
240 | |||
241 | if (boarddata && gpio_is_valid(boarddata->cd_gpio)) { | ||
242 | gpio_free(boarddata->cd_gpio); | ||
243 | |||
244 | if (!(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)) | ||
245 | free_irq(gpio_to_irq(boarddata->cd_gpio), host); | ||
246 | } | ||
129 | 247 | ||
130 | clk_disable(pltfm_host->clk); | 248 | clk_disable(pltfm_host->clk); |
131 | clk_put(pltfm_host->clk); | 249 | clk_put(pltfm_host->clk); |
132 | } | 250 | } |
133 | 251 | ||
134 | static struct sdhci_ops sdhci_esdhc_ops = { | ||
135 | .read_w = esdhc_readw_le, | ||
136 | .write_w = esdhc_writew_le, | ||
137 | .write_b = esdhc_writeb_le, | ||
138 | .set_clock = esdhc_set_clock, | ||
139 | .get_max_clock = esdhc_pltfm_get_max_clock, | ||
140 | .get_min_clock = esdhc_pltfm_get_min_clock, | ||
141 | }; | ||
142 | |||
143 | struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { | 252 | struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { |
144 | .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA, | 253 | .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_ADMA |
254 | | SDHCI_QUIRK_BROKEN_CARD_DETECTION, | ||
145 | /* ADMA has issues. Might be fixable */ | 255 | /* ADMA has issues. Might be fixable */ |
146 | .ops = &sdhci_esdhc_ops, | 256 | .ops = &sdhci_esdhc_ops, |
147 | .init = esdhc_pltfm_init, | 257 | .init = esdhc_pltfm_init, |
diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h index afaf1bc4913a..c55aae828aac 100644 --- a/drivers/mmc/host/sdhci-esdhc.h +++ b/drivers/mmc/host/sdhci-esdhc.h | |||
@@ -19,7 +19,6 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define ESDHC_DEFAULT_QUIRKS (SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \ | 21 | #define ESDHC_DEFAULT_QUIRKS (SDHCI_QUIRK_FORCE_BLK_SZ_2048 | \ |
22 | SDHCI_QUIRK_BROKEN_CARD_DETECTION | \ | ||
23 | SDHCI_QUIRK_NO_BUSY_IRQ | \ | 22 | SDHCI_QUIRK_NO_BUSY_IRQ | \ |
24 | SDHCI_QUIRK_NONSTANDARD_CLOCK | \ | 23 | SDHCI_QUIRK_NONSTANDARD_CLOCK | \ |
25 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \ | 24 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | \ |
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index fcd0e1fcba44..08161f690ae8 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c | |||
@@ -73,7 +73,8 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | struct sdhci_of_data sdhci_esdhc = { | 75 | struct sdhci_of_data sdhci_esdhc = { |
76 | .quirks = ESDHC_DEFAULT_QUIRKS, | 76 | /* card detection could be handled via GPIO */ |
77 | .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION, | ||
77 | .ops = { | 78 | .ops = { |
78 | .read_l = sdhci_be32bs_readl, | 79 | .read_l = sdhci_be32bs_readl, |
79 | .read_w = esdhc_readw, | 80 | .read_w = esdhc_readw, |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 0dc905b20eee..2f8d46854acd 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -547,6 +547,14 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
547 | }, | 547 | }, |
548 | 548 | ||
549 | { | 549 | { |
550 | .vendor = PCI_VENDOR_ID_RICOH, | ||
551 | .device = 0xe823, | ||
552 | .subvendor = PCI_ANY_ID, | ||
553 | .subdevice = PCI_ANY_ID, | ||
554 | .driver_data = (kernel_ulong_t)&sdhci_ricoh_mmc, | ||
555 | }, | ||
556 | |||
557 | { | ||
550 | .vendor = PCI_VENDOR_ID_ENE, | 558 | .vendor = PCI_VENDOR_ID_ENE, |
551 | .device = PCI_DEVICE_ID_ENE_CB712_SD, | 559 | .device = PCI_DEVICE_ID_ENE_CB712_SD, |
552 | .subvendor = PCI_ANY_ID, | 560 | .subvendor = PCI_ANY_ID, |
@@ -900,9 +908,6 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
900 | { | 908 | { |
901 | struct sdhci_pci_slot *slot; | 909 | struct sdhci_pci_slot *slot; |
902 | struct sdhci_host *host; | 910 | struct sdhci_host *host; |
903 | |||
904 | resource_size_t addr; | ||
905 | |||
906 | int ret; | 911 | int ret; |
907 | 912 | ||
908 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { | 913 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { |
@@ -949,7 +954,6 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
949 | goto free; | 954 | goto free; |
950 | } | 955 | } |
951 | 956 | ||
952 | addr = pci_resource_start(pdev, bar); | ||
953 | host->ioaddr = pci_ioremap_bar(pdev, bar); | 957 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
954 | if (!host->ioaddr) { | 958 | if (!host->ioaddr) { |
955 | dev_err(&pdev->dev, "failed to remap registers\n"); | 959 | dev_err(&pdev->dev, "failed to remap registers\n"); |
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 5309ab95aada..69e3ee321eb5 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c | |||
@@ -499,6 +499,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
499 | * SDHCI block, or a missing configuration that needs to be set. */ | 499 | * SDHCI block, or a missing configuration that needs to be set. */ |
500 | host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ; | 500 | host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ; |
501 | 501 | ||
502 | /* This host supports the Auto CMD12 */ | ||
503 | host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; | ||
504 | |||
502 | if (pdata->cd_type == S3C_SDHCI_CD_NONE || | 505 | if (pdata->cd_type == S3C_SDHCI_CD_NONE || |
503 | pdata->cd_type == S3C_SDHCI_CD_PERMANENT) | 506 | pdata->cd_type == S3C_SDHCI_CD_PERMANENT) |
504 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; | 507 | host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; |
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 4823ee94a63f..f7e1f964395f 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c | |||
@@ -169,7 +169,7 @@ static int tegra_sdhci_pltfm_init(struct sdhci_host *host, | |||
169 | if (rc) { | 169 | if (rc) { |
170 | dev_err(mmc_dev(host->mmc), | 170 | dev_err(mmc_dev(host->mmc), |
171 | "failed to allocate wp gpio\n"); | 171 | "failed to allocate wp gpio\n"); |
172 | goto out_cd; | 172 | goto out_irq; |
173 | } | 173 | } |
174 | tegra_gpio_enable(plat->wp_gpio); | 174 | tegra_gpio_enable(plat->wp_gpio); |
175 | gpio_direction_input(plat->wp_gpio); | 175 | gpio_direction_input(plat->wp_gpio); |
@@ -195,6 +195,9 @@ out_wp: | |||
195 | gpio_free(plat->wp_gpio); | 195 | gpio_free(plat->wp_gpio); |
196 | } | 196 | } |
197 | 197 | ||
198 | out_irq: | ||
199 | if (gpio_is_valid(plat->cd_gpio)) | ||
200 | free_irq(gpio_to_irq(plat->cd_gpio), host); | ||
198 | out_cd: | 201 | out_cd: |
199 | if (gpio_is_valid(plat->cd_gpio)) { | 202 | if (gpio_is_valid(plat->cd_gpio)) { |
200 | tegra_gpio_disable(plat->cd_gpio); | 203 | tegra_gpio_disable(plat->cd_gpio); |
@@ -225,6 +228,7 @@ static void tegra_sdhci_pltfm_exit(struct sdhci_host *host) | |||
225 | } | 228 | } |
226 | 229 | ||
227 | if (gpio_is_valid(plat->cd_gpio)) { | 230 | if (gpio_is_valid(plat->cd_gpio)) { |
231 | free_irq(gpio_to_irq(plat->cd_gpio), host); | ||
228 | tegra_gpio_disable(plat->cd_gpio); | 232 | tegra_gpio_disable(plat->cd_gpio); |
229 | gpio_free(plat->cd_gpio); | 233 | gpio_free(plat->cd_gpio); |
230 | } | 234 | } |
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 12884c270171..af97015a2fc7 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c | |||
@@ -169,7 +169,7 @@ struct sh_mmcif_host { | |||
169 | struct dma_chan *chan_rx; | 169 | struct dma_chan *chan_rx; |
170 | struct dma_chan *chan_tx; | 170 | struct dma_chan *chan_tx; |
171 | struct completion dma_complete; | 171 | struct completion dma_complete; |
172 | unsigned int dma_sglen; | 172 | bool dma_active; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | static inline void sh_mmcif_bitset(struct sh_mmcif_host *host, | 175 | static inline void sh_mmcif_bitset(struct sh_mmcif_host *host, |
@@ -194,10 +194,12 @@ static void mmcif_dma_complete(void *arg) | |||
194 | return; | 194 | return; |
195 | 195 | ||
196 | if (host->data->flags & MMC_DATA_READ) | 196 | if (host->data->flags & MMC_DATA_READ) |
197 | dma_unmap_sg(&host->pd->dev, host->data->sg, host->dma_sglen, | 197 | dma_unmap_sg(host->chan_rx->device->dev, |
198 | host->data->sg, host->data->sg_len, | ||
198 | DMA_FROM_DEVICE); | 199 | DMA_FROM_DEVICE); |
199 | else | 200 | else |
200 | dma_unmap_sg(&host->pd->dev, host->data->sg, host->dma_sglen, | 201 | dma_unmap_sg(host->chan_tx->device->dev, |
202 | host->data->sg, host->data->sg_len, | ||
201 | DMA_TO_DEVICE); | 203 | DMA_TO_DEVICE); |
202 | 204 | ||
203 | complete(&host->dma_complete); | 205 | complete(&host->dma_complete); |
@@ -211,9 +213,10 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) | |||
211 | dma_cookie_t cookie = -EINVAL; | 213 | dma_cookie_t cookie = -EINVAL; |
212 | int ret; | 214 | int ret; |
213 | 215 | ||
214 | ret = dma_map_sg(&host->pd->dev, sg, host->data->sg_len, DMA_FROM_DEVICE); | 216 | ret = dma_map_sg(chan->device->dev, sg, host->data->sg_len, |
217 | DMA_FROM_DEVICE); | ||
215 | if (ret > 0) { | 218 | if (ret > 0) { |
216 | host->dma_sglen = ret; | 219 | host->dma_active = true; |
217 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 220 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, |
218 | DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 221 | DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
219 | } | 222 | } |
@@ -221,14 +224,9 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) | |||
221 | if (desc) { | 224 | if (desc) { |
222 | desc->callback = mmcif_dma_complete; | 225 | desc->callback = mmcif_dma_complete; |
223 | desc->callback_param = host; | 226 | desc->callback_param = host; |
224 | cookie = desc->tx_submit(desc); | 227 | cookie = dmaengine_submit(desc); |
225 | if (cookie < 0) { | 228 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN); |
226 | desc = NULL; | 229 | dma_async_issue_pending(chan); |
227 | ret = cookie; | ||
228 | } else { | ||
229 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAREN); | ||
230 | chan->device->device_issue_pending(chan); | ||
231 | } | ||
232 | } | 230 | } |
233 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", | 231 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", |
234 | __func__, host->data->sg_len, ret, cookie); | 232 | __func__, host->data->sg_len, ret, cookie); |
@@ -238,7 +236,7 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) | |||
238 | if (ret >= 0) | 236 | if (ret >= 0) |
239 | ret = -EIO; | 237 | ret = -EIO; |
240 | host->chan_rx = NULL; | 238 | host->chan_rx = NULL; |
241 | host->dma_sglen = 0; | 239 | host->dma_active = false; |
242 | dma_release_channel(chan); | 240 | dma_release_channel(chan); |
243 | /* Free the Tx channel too */ | 241 | /* Free the Tx channel too */ |
244 | chan = host->chan_tx; | 242 | chan = host->chan_tx; |
@@ -263,9 +261,10 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) | |||
263 | dma_cookie_t cookie = -EINVAL; | 261 | dma_cookie_t cookie = -EINVAL; |
264 | int ret; | 262 | int ret; |
265 | 263 | ||
266 | ret = dma_map_sg(&host->pd->dev, sg, host->data->sg_len, DMA_TO_DEVICE); | 264 | ret = dma_map_sg(chan->device->dev, sg, host->data->sg_len, |
265 | DMA_TO_DEVICE); | ||
267 | if (ret > 0) { | 266 | if (ret > 0) { |
268 | host->dma_sglen = ret; | 267 | host->dma_active = true; |
269 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 268 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, |
270 | DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 269 | DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
271 | } | 270 | } |
@@ -273,14 +272,9 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) | |||
273 | if (desc) { | 272 | if (desc) { |
274 | desc->callback = mmcif_dma_complete; | 273 | desc->callback = mmcif_dma_complete; |
275 | desc->callback_param = host; | 274 | desc->callback_param = host; |
276 | cookie = desc->tx_submit(desc); | 275 | cookie = dmaengine_submit(desc); |
277 | if (cookie < 0) { | 276 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAWEN); |
278 | desc = NULL; | 277 | dma_async_issue_pending(chan); |
279 | ret = cookie; | ||
280 | } else { | ||
281 | sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_DMAWEN); | ||
282 | chan->device->device_issue_pending(chan); | ||
283 | } | ||
284 | } | 278 | } |
285 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", | 279 | dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", |
286 | __func__, host->data->sg_len, ret, cookie); | 280 | __func__, host->data->sg_len, ret, cookie); |
@@ -290,7 +284,7 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) | |||
290 | if (ret >= 0) | 284 | if (ret >= 0) |
291 | ret = -EIO; | 285 | ret = -EIO; |
292 | host->chan_tx = NULL; | 286 | host->chan_tx = NULL; |
293 | host->dma_sglen = 0; | 287 | host->dma_active = false; |
294 | dma_release_channel(chan); | 288 | dma_release_channel(chan); |
295 | /* Free the Rx channel too */ | 289 | /* Free the Rx channel too */ |
296 | chan = host->chan_rx; | 290 | chan = host->chan_rx; |
@@ -317,7 +311,7 @@ static bool sh_mmcif_filter(struct dma_chan *chan, void *arg) | |||
317 | static void sh_mmcif_request_dma(struct sh_mmcif_host *host, | 311 | static void sh_mmcif_request_dma(struct sh_mmcif_host *host, |
318 | struct sh_mmcif_plat_data *pdata) | 312 | struct sh_mmcif_plat_data *pdata) |
319 | { | 313 | { |
320 | host->dma_sglen = 0; | 314 | host->dma_active = false; |
321 | 315 | ||
322 | /* We can only either use DMA for both Tx and Rx or not use it at all */ | 316 | /* We can only either use DMA for both Tx and Rx or not use it at all */ |
323 | if (pdata->dma) { | 317 | if (pdata->dma) { |
@@ -364,7 +358,7 @@ static void sh_mmcif_release_dma(struct sh_mmcif_host *host) | |||
364 | dma_release_channel(chan); | 358 | dma_release_channel(chan); |
365 | } | 359 | } |
366 | 360 | ||
367 | host->dma_sglen = 0; | 361 | host->dma_active = false; |
368 | } | 362 | } |
369 | 363 | ||
370 | static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) | 364 | static void sh_mmcif_clock_control(struct sh_mmcif_host *host, unsigned int clk) |
@@ -753,7 +747,7 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
753 | } | 747 | } |
754 | sh_mmcif_get_response(host, cmd); | 748 | sh_mmcif_get_response(host, cmd); |
755 | if (host->data) { | 749 | if (host->data) { |
756 | if (!host->dma_sglen) { | 750 | if (!host->dma_active) { |
757 | ret = sh_mmcif_data_trans(host, mrq, cmd->opcode); | 751 | ret = sh_mmcif_data_trans(host, mrq, cmd->opcode); |
758 | } else { | 752 | } else { |
759 | long time = | 753 | long time = |
@@ -765,7 +759,7 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
765 | ret = time; | 759 | ret = time; |
766 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, | 760 | sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, |
767 | BUF_ACC_DMAREN | BUF_ACC_DMAWEN); | 761 | BUF_ACC_DMAREN | BUF_ACC_DMAWEN); |
768 | host->dma_sglen = 0; | 762 | host->dma_active = false; |
769 | } | 763 | } |
770 | if (ret < 0) | 764 | if (ret < 0) |
771 | mrq->data->bytes_xfered = 0; | 765 | mrq->data->bytes_xfered = 0; |
@@ -850,15 +844,15 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
850 | struct sh_mmcif_host *host = mmc_priv(mmc); | 844 | struct sh_mmcif_host *host = mmc_priv(mmc); |
851 | struct sh_mmcif_plat_data *p = host->pd->dev.platform_data; | 845 | struct sh_mmcif_plat_data *p = host->pd->dev.platform_data; |
852 | 846 | ||
853 | if (ios->power_mode == MMC_POWER_OFF) { | 847 | if (ios->power_mode == MMC_POWER_UP) { |
848 | if (p->set_pwr) | ||
849 | p->set_pwr(host->pd, ios->power_mode); | ||
850 | } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { | ||
854 | /* clock stop */ | 851 | /* clock stop */ |
855 | sh_mmcif_clock_control(host, 0); | 852 | sh_mmcif_clock_control(host, 0); |
856 | if (p->down_pwr) | 853 | if (ios->power_mode == MMC_POWER_OFF && p->down_pwr) |
857 | p->down_pwr(host->pd); | 854 | p->down_pwr(host->pd); |
858 | return; | 855 | return; |
859 | } else if (ios->power_mode == MMC_POWER_UP) { | ||
860 | if (p->set_pwr) | ||
861 | p->set_pwr(host->pd, ios->power_mode); | ||
862 | } | 856 | } |
863 | 857 | ||
864 | if (ios->clock) | 858 | if (ios->clock) |
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index e3c6ef208391..ac52eb65395e 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c | |||
@@ -152,7 +152,6 @@ struct tmio_mmc_host { | |||
152 | struct tasklet_struct dma_complete; | 152 | struct tasklet_struct dma_complete; |
153 | struct tasklet_struct dma_issue; | 153 | struct tasklet_struct dma_issue; |
154 | #ifdef CONFIG_TMIO_MMC_DMA | 154 | #ifdef CONFIG_TMIO_MMC_DMA |
155 | unsigned int dma_sglen; | ||
156 | u8 bounce_buf[PAGE_CACHE_SIZE] __attribute__((aligned(MAX_ALIGN))); | 155 | u8 bounce_buf[PAGE_CACHE_SIZE] __attribute__((aligned(MAX_ALIGN))); |
157 | struct scatterlist bounce_sg; | 156 | struct scatterlist bounce_sg; |
158 | #endif | 157 | #endif |
@@ -220,44 +219,48 @@ static char *tmio_mmc_kmap_atomic(struct scatterlist *sg, unsigned long *flags) | |||
220 | return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; | 219 | return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; |
221 | } | 220 | } |
222 | 221 | ||
223 | static void tmio_mmc_kunmap_atomic(void *virt, unsigned long *flags) | 222 | static void tmio_mmc_kunmap_atomic(struct scatterlist *sg, unsigned long *flags, void *virt) |
224 | { | 223 | { |
225 | kunmap_atomic(virt, KM_BIO_SRC_IRQ); | 224 | kunmap_atomic(virt - sg->offset, KM_BIO_SRC_IRQ); |
226 | local_irq_restore(*flags); | 225 | local_irq_restore(*flags); |
227 | } | 226 | } |
228 | 227 | ||
229 | #ifdef CONFIG_MMC_DEBUG | 228 | #ifdef CONFIG_MMC_DEBUG |
230 | 229 | ||
231 | #define STATUS_TO_TEXT(a) \ | 230 | #define STATUS_TO_TEXT(a, status, i) \ |
232 | do { \ | 231 | do { \ |
233 | if (status & TMIO_STAT_##a) \ | 232 | if (status & TMIO_STAT_##a) { \ |
233 | if (i++) \ | ||
234 | printk(" | "); \ | ||
234 | printk(#a); \ | 235 | printk(#a); \ |
236 | } \ | ||
235 | } while (0) | 237 | } while (0) |
236 | 238 | ||
237 | void pr_debug_status(u32 status) | 239 | void pr_debug_status(u32 status) |
238 | { | 240 | { |
241 | int i = 0; | ||
239 | printk(KERN_DEBUG "status: %08x = ", status); | 242 | printk(KERN_DEBUG "status: %08x = ", status); |
240 | STATUS_TO_TEXT(CARD_REMOVE); | 243 | STATUS_TO_TEXT(CARD_REMOVE, status, i); |
241 | STATUS_TO_TEXT(CARD_INSERT); | 244 | STATUS_TO_TEXT(CARD_INSERT, status, i); |
242 | STATUS_TO_TEXT(SIGSTATE); | 245 | STATUS_TO_TEXT(SIGSTATE, status, i); |
243 | STATUS_TO_TEXT(WRPROTECT); | 246 | STATUS_TO_TEXT(WRPROTECT, status, i); |
244 | STATUS_TO_TEXT(CARD_REMOVE_A); | 247 | STATUS_TO_TEXT(CARD_REMOVE_A, status, i); |
245 | STATUS_TO_TEXT(CARD_INSERT_A); | 248 | STATUS_TO_TEXT(CARD_INSERT_A, status, i); |
246 | STATUS_TO_TEXT(SIGSTATE_A); | 249 | STATUS_TO_TEXT(SIGSTATE_A, status, i); |
247 | STATUS_TO_TEXT(CMD_IDX_ERR); | 250 | STATUS_TO_TEXT(CMD_IDX_ERR, status, i); |
248 | STATUS_TO_TEXT(STOPBIT_ERR); | 251 | STATUS_TO_TEXT(STOPBIT_ERR, status, i); |
249 | STATUS_TO_TEXT(ILL_FUNC); | 252 | STATUS_TO_TEXT(ILL_FUNC, status, i); |
250 | STATUS_TO_TEXT(CMD_BUSY); | 253 | STATUS_TO_TEXT(CMD_BUSY, status, i); |
251 | STATUS_TO_TEXT(CMDRESPEND); | 254 | STATUS_TO_TEXT(CMDRESPEND, status, i); |
252 | STATUS_TO_TEXT(DATAEND); | 255 | STATUS_TO_TEXT(DATAEND, status, i); |
253 | STATUS_TO_TEXT(CRCFAIL); | 256 | STATUS_TO_TEXT(CRCFAIL, status, i); |
254 | STATUS_TO_TEXT(DATATIMEOUT); | 257 | STATUS_TO_TEXT(DATATIMEOUT, status, i); |
255 | STATUS_TO_TEXT(CMDTIMEOUT); | 258 | STATUS_TO_TEXT(CMDTIMEOUT, status, i); |
256 | STATUS_TO_TEXT(RXOVERFLOW); | 259 | STATUS_TO_TEXT(RXOVERFLOW, status, i); |
257 | STATUS_TO_TEXT(TXUNDERRUN); | 260 | STATUS_TO_TEXT(TXUNDERRUN, status, i); |
258 | STATUS_TO_TEXT(RXRDY); | 261 | STATUS_TO_TEXT(RXRDY, status, i); |
259 | STATUS_TO_TEXT(TXRQ); | 262 | STATUS_TO_TEXT(TXRQ, status, i); |
260 | STATUS_TO_TEXT(ILL_ACCESS); | 263 | STATUS_TO_TEXT(ILL_ACCESS, status, i); |
261 | printk("\n"); | 264 | printk("\n"); |
262 | } | 265 | } |
263 | 266 | ||
@@ -507,7 +510,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) | |||
507 | 510 | ||
508 | host->sg_off += count; | 511 | host->sg_off += count; |
509 | 512 | ||
510 | tmio_mmc_kunmap_atomic(sg_virt, &flags); | 513 | tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt); |
511 | 514 | ||
512 | if (host->sg_off == host->sg_ptr->length) | 515 | if (host->sg_off == host->sg_ptr->length) |
513 | tmio_mmc_next_sg(host); | 516 | tmio_mmc_next_sg(host); |
@@ -767,7 +770,7 @@ static void tmio_check_bounce_buffer(struct tmio_mmc_host *host) | |||
767 | unsigned long flags; | 770 | unsigned long flags; |
768 | void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig, &flags); | 771 | void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig, &flags); |
769 | memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length); | 772 | memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length); |
770 | tmio_mmc_kunmap_atomic(sg_vaddr, &flags); | 773 | tmio_mmc_kunmap_atomic(host->sg_orig, &flags, sg_vaddr); |
771 | } | 774 | } |
772 | } | 775 | } |
773 | 776 | ||
@@ -825,23 +828,16 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) | |||
825 | sg = host->sg_ptr; | 828 | sg = host->sg_ptr; |
826 | } | 829 | } |
827 | 830 | ||
828 | ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, DMA_FROM_DEVICE); | 831 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE); |
829 | if (ret > 0) { | 832 | if (ret > 0) |
830 | host->dma_sglen = ret; | ||
831 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 833 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, |
832 | DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 834 | DMA_FROM_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
833 | } | ||
834 | 835 | ||
835 | if (desc) { | 836 | if (desc) { |
836 | desc->callback = tmio_dma_complete; | 837 | desc->callback = tmio_dma_complete; |
837 | desc->callback_param = host; | 838 | desc->callback_param = host; |
838 | cookie = desc->tx_submit(desc); | 839 | cookie = dmaengine_submit(desc); |
839 | if (cookie < 0) { | 840 | dma_async_issue_pending(chan); |
840 | desc = NULL; | ||
841 | ret = cookie; | ||
842 | } else { | ||
843 | chan->device->device_issue_pending(chan); | ||
844 | } | ||
845 | } | 841 | } |
846 | dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", | 842 | dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", |
847 | __func__, host->sg_len, ret, cookie, host->mrq); | 843 | __func__, host->sg_len, ret, cookie, host->mrq); |
@@ -901,26 +897,20 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host) | |||
901 | void *sg_vaddr = tmio_mmc_kmap_atomic(sg, &flags); | 897 | void *sg_vaddr = tmio_mmc_kmap_atomic(sg, &flags); |
902 | sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); | 898 | sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); |
903 | memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length); | 899 | memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length); |
904 | tmio_mmc_kunmap_atomic(sg_vaddr, &flags); | 900 | tmio_mmc_kunmap_atomic(sg, &flags, sg_vaddr); |
905 | host->sg_ptr = &host->bounce_sg; | 901 | host->sg_ptr = &host->bounce_sg; |
906 | sg = host->sg_ptr; | 902 | sg = host->sg_ptr; |
907 | } | 903 | } |
908 | 904 | ||
909 | ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, DMA_TO_DEVICE); | 905 | ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); |
910 | if (ret > 0) { | 906 | if (ret > 0) |
911 | host->dma_sglen = ret; | ||
912 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, | 907 | desc = chan->device->device_prep_slave_sg(chan, sg, ret, |
913 | DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | 908 | DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
914 | } | ||
915 | 909 | ||
916 | if (desc) { | 910 | if (desc) { |
917 | desc->callback = tmio_dma_complete; | 911 | desc->callback = tmio_dma_complete; |
918 | desc->callback_param = host; | 912 | desc->callback_param = host; |
919 | cookie = desc->tx_submit(desc); | 913 | cookie = dmaengine_submit(desc); |
920 | if (cookie < 0) { | ||
921 | desc = NULL; | ||
922 | ret = cookie; | ||
923 | } | ||
924 | } | 914 | } |
925 | dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", | 915 | dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", |
926 | __func__, host->sg_len, ret, cookie, host->mrq); | 916 | __func__, host->sg_len, ret, cookie, host->mrq); |
@@ -964,7 +954,7 @@ static void tmio_issue_tasklet_fn(unsigned long priv) | |||
964 | struct tmio_mmc_host *host = (struct tmio_mmc_host *)priv; | 954 | struct tmio_mmc_host *host = (struct tmio_mmc_host *)priv; |
965 | struct dma_chan *chan = host->chan_tx; | 955 | struct dma_chan *chan = host->chan_tx; |
966 | 956 | ||
967 | chan->device->device_issue_pending(chan); | 957 | dma_async_issue_pending(chan); |
968 | } | 958 | } |
969 | 959 | ||
970 | static void tmio_tasklet_fn(unsigned long arg) | 960 | static void tmio_tasklet_fn(unsigned long arg) |
@@ -978,10 +968,12 @@ static void tmio_tasklet_fn(unsigned long arg) | |||
978 | goto out; | 968 | goto out; |
979 | 969 | ||
980 | if (host->data->flags & MMC_DATA_READ) | 970 | if (host->data->flags & MMC_DATA_READ) |
981 | dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->dma_sglen, | 971 | dma_unmap_sg(host->chan_rx->device->dev, |
972 | host->sg_ptr, host->sg_len, | ||
982 | DMA_FROM_DEVICE); | 973 | DMA_FROM_DEVICE); |
983 | else | 974 | else |
984 | dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->dma_sglen, | 975 | dma_unmap_sg(host->chan_tx->device->dev, |
976 | host->sg_ptr, host->sg_len, | ||
985 | DMA_TO_DEVICE); | 977 | DMA_TO_DEVICE); |
986 | 978 | ||
987 | tmio_mmc_do_data_irq(host); | 979 | tmio_mmc_do_data_irq(host); |
diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c index 9ed84ddb4780..8c5b4881ccd6 100644 --- a/drivers/mmc/host/via-sdmmc.c +++ b/drivers/mmc/host/via-sdmmc.c | |||
@@ -802,12 +802,9 @@ static const struct mmc_host_ops via_sdc_ops = { | |||
802 | 802 | ||
803 | static void via_reset_pcictrl(struct via_crdr_mmc_host *host) | 803 | static void via_reset_pcictrl(struct via_crdr_mmc_host *host) |
804 | { | 804 | { |
805 | void __iomem *addrbase; | ||
806 | unsigned long flags; | 805 | unsigned long flags; |
807 | u8 gatt; | 806 | u8 gatt; |
808 | 807 | ||
809 | addrbase = host->pcictrl_mmiobase; | ||
810 | |||
811 | spin_lock_irqsave(&host->lock, flags); | 808 | spin_lock_irqsave(&host->lock, flags); |
812 | 809 | ||
813 | via_save_pcictrlreg(host); | 810 | via_save_pcictrlreg(host); |
diff --git a/drivers/net/caif/Makefile b/drivers/net/caif/Makefile index b38d987da67d..9560b9d624bd 100644 --- a/drivers/net/caif/Makefile +++ b/drivers/net/caif/Makefile | |||
@@ -1,6 +1,4 @@ | |||
1 | ifeq ($(CONFIG_CAIF_DEBUG),y) | 1 | ccflags-$(CONFIG_CAIF_DEBUG) := -DDEBUG |
2 | EXTRA_CFLAGS += -DDEBUG | ||
3 | endif | ||
4 | 2 | ||
5 | # Serial interface | 3 | # Serial interface |
6 | obj-$(CONFIG_CAIF_TTY) += caif_serial.o | 4 | obj-$(CONFIG_CAIF_TTY) += caif_serial.o |
diff --git a/drivers/net/skfp/Makefile b/drivers/net/skfp/Makefile index cb23580fcffa..b0be0234abf6 100644 --- a/drivers/net/skfp/Makefile +++ b/drivers/net/skfp/Makefile | |||
@@ -17,4 +17,4 @@ skfp-objs := skfddi.o hwmtm.o fplustm.o smt.o cfm.o \ | |||
17 | # projects. To keep the source common for all those drivers (and | 17 | # projects. To keep the source common for all those drivers (and |
18 | # thus simplify fixes to it), please do not clean it up! | 18 | # thus simplify fixes to it), please do not clean it up! |
19 | 19 | ||
20 | EXTRA_CFLAGS += -Idrivers/net/skfp -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes | 20 | ccflags-y := -Idrivers/net/skfp -DPCI -DMEM_MAPPED_IO -Wno-strict-prototypes |
diff --git a/drivers/net/wan/lmc/Makefile b/drivers/net/wan/lmc/Makefile index dabdcfed4efd..609710d64eb5 100644 --- a/drivers/net/wan/lmc/Makefile +++ b/drivers/net/wan/lmc/Makefile | |||
@@ -14,4 +14,4 @@ lmc-objs := lmc_debug.o lmc_media.o lmc_main.o lmc_proto.o | |||
14 | # -DDEBUG \ | 14 | # -DDEBUG \ |
15 | # -DLMC_PACKET_LOG | 15 | # -DLMC_PACKET_LOG |
16 | 16 | ||
17 | EXTRA_CFLAGS += -I. $(DBGDEF) | 17 | ccflags-y := -I. $(DBGDEF) |
diff --git a/drivers/net/wireless/hostap/hostap_config.h b/drivers/net/wireless/hostap/hostap_config.h index 30acd39d76a2..2c8f71f0ed45 100644 --- a/drivers/net/wireless/hostap/hostap_config.h +++ b/drivers/net/wireless/hostap/hostap_config.h | |||
@@ -30,9 +30,9 @@ | |||
30 | 30 | ||
31 | /* Following defines can be used to remove unneeded parts of the driver, e.g., | 31 | /* Following defines can be used to remove unneeded parts of the driver, e.g., |
32 | * to limit the size of the kernel module. Definitions can be added here in | 32 | * to limit the size of the kernel module. Definitions can be added here in |
33 | * hostap_config.h or they can be added to make command with EXTRA_CFLAGS, | 33 | * hostap_config.h or they can be added to make command with ccflags-y, |
34 | * e.g., | 34 | * e.g., |
35 | * 'make pccard EXTRA_CFLAGS="-DPRISM2_NO_DEBUG -DPRISM2_NO_PROCFS_DEBUG"' | 35 | * 'make pccard ccflags-y="-DPRISM2_NO_DEBUG -DPRISM2_NO_PROCFS_DEBUG"' |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* Do not include debug messages into the driver */ | 38 | /* Do not include debug messages into the driver */ |
diff --git a/drivers/net/wireless/zd1211rw/Makefile b/drivers/net/wireless/zd1211rw/Makefile index 1907eafb9b16..5728a918e508 100644 --- a/drivers/net/wireless/zd1211rw/Makefile +++ b/drivers/net/wireless/zd1211rw/Makefile | |||
@@ -5,7 +5,5 @@ zd1211rw-objs := zd_chip.o zd_mac.o \ | |||
5 | zd_rf_al7230b.o zd_rf_uw2453.o \ | 5 | zd_rf_al7230b.o zd_rf_uw2453.o \ |
6 | zd_rf.o zd_usb.o | 6 | zd_rf.o zd_usb.o |
7 | 7 | ||
8 | ifeq ($(CONFIG_ZD1211RW_DEBUG),y) | 8 | ccflags-$(CONFIG_ZD1211RW_DEBUG) := -DDEBUG |
9 | EXTRA_CFLAGS += -DDEBUG | ||
10 | endif | ||
11 | 9 | ||
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 9383063d2b16..bcd5d54b7d4d 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c | |||
@@ -296,25 +296,25 @@ static struct pci_port_ops dino_port_ops = { | |||
296 | .outl = dino_out32 | 296 | .outl = dino_out32 |
297 | }; | 297 | }; |
298 | 298 | ||
299 | static void dino_mask_irq(unsigned int irq) | 299 | static void dino_mask_irq(struct irq_data *d) |
300 | { | 300 | { |
301 | struct dino_device *dino_dev = get_irq_chip_data(irq); | 301 | struct dino_device *dino_dev = irq_data_get_irq_chip_data(d); |
302 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); | 302 | int local_irq = gsc_find_local_irq(d->irq, dino_dev->global_irq, DINO_LOCAL_IRQS); |
303 | 303 | ||
304 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, irq); | 304 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, d->irq); |
305 | 305 | ||
306 | /* Clear the matching bit in the IMR register */ | 306 | /* Clear the matching bit in the IMR register */ |
307 | dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); | 307 | dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); |
308 | __raw_writel(dino_dev->imr, dino_dev->hba.base_addr+DINO_IMR); | 308 | __raw_writel(dino_dev->imr, dino_dev->hba.base_addr+DINO_IMR); |
309 | } | 309 | } |
310 | 310 | ||
311 | static void dino_unmask_irq(unsigned int irq) | 311 | static void dino_unmask_irq(struct irq_data *d) |
312 | { | 312 | { |
313 | struct dino_device *dino_dev = get_irq_chip_data(irq); | 313 | struct dino_device *dino_dev = irq_data_get_irq_chip_data(d); |
314 | int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, DINO_LOCAL_IRQS); | 314 | int local_irq = gsc_find_local_irq(d->irq, dino_dev->global_irq, DINO_LOCAL_IRQS); |
315 | u32 tmp; | 315 | u32 tmp; |
316 | 316 | ||
317 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, irq); | 317 | DBG(KERN_WARNING "%s(0x%p, %d)\n", __func__, dino_dev, d->irq); |
318 | 318 | ||
319 | /* | 319 | /* |
320 | ** clear pending IRQ bits | 320 | ** clear pending IRQ bits |
@@ -346,9 +346,9 @@ static void dino_unmask_irq(unsigned int irq) | |||
346 | } | 346 | } |
347 | 347 | ||
348 | static struct irq_chip dino_interrupt_type = { | 348 | static struct irq_chip dino_interrupt_type = { |
349 | .name = "GSC-PCI", | 349 | .name = "GSC-PCI", |
350 | .unmask = dino_unmask_irq, | 350 | .irq_unmask = dino_unmask_irq, |
351 | .mask = dino_mask_irq, | 351 | .irq_mask = dino_mask_irq, |
352 | }; | 352 | }; |
353 | 353 | ||
354 | 354 | ||
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c index e860038b0b84..deeec32a5803 100644 --- a/drivers/parisc/eisa.c +++ b/drivers/parisc/eisa.c | |||
@@ -144,8 +144,9 @@ static unsigned int eisa_irq_level __read_mostly; /* default to edge triggered * | |||
144 | 144 | ||
145 | 145 | ||
146 | /* called by free irq */ | 146 | /* called by free irq */ |
147 | static void eisa_mask_irq(unsigned int irq) | 147 | static void eisa_mask_irq(struct irq_data *d) |
148 | { | 148 | { |
149 | unsigned int irq = d->irq; | ||
149 | unsigned long flags; | 150 | unsigned long flags; |
150 | 151 | ||
151 | EISA_DBG("disable irq %d\n", irq); | 152 | EISA_DBG("disable irq %d\n", irq); |
@@ -164,8 +165,9 @@ static void eisa_mask_irq(unsigned int irq) | |||
164 | } | 165 | } |
165 | 166 | ||
166 | /* called by request irq */ | 167 | /* called by request irq */ |
167 | static void eisa_unmask_irq(unsigned int irq) | 168 | static void eisa_unmask_irq(struct irq_data *d) |
168 | { | 169 | { |
170 | unsigned int irq = d->irq; | ||
169 | unsigned long flags; | 171 | unsigned long flags; |
170 | EISA_DBG("enable irq %d\n", irq); | 172 | EISA_DBG("enable irq %d\n", irq); |
171 | 173 | ||
@@ -183,9 +185,9 @@ static void eisa_unmask_irq(unsigned int irq) | |||
183 | } | 185 | } |
184 | 186 | ||
185 | static struct irq_chip eisa_interrupt_type = { | 187 | static struct irq_chip eisa_interrupt_type = { |
186 | .name = "EISA", | 188 | .name = "EISA", |
187 | .unmask = eisa_unmask_irq, | 189 | .irq_unmask = eisa_unmask_irq, |
188 | .mask = eisa_mask_irq, | 190 | .irq_mask = eisa_mask_irq, |
189 | }; | 191 | }; |
190 | 192 | ||
191 | static irqreturn_t eisa_irq(int wax_irq, void *intr_dev) | 193 | static irqreturn_t eisa_irq(int wax_irq, void *intr_dev) |
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c index 772b1939ac21..ef31080cf591 100644 --- a/drivers/parisc/gsc.c +++ b/drivers/parisc/gsc.c | |||
@@ -105,13 +105,13 @@ int gsc_find_local_irq(unsigned int irq, int *global_irqs, int limit) | |||
105 | return NO_IRQ; | 105 | return NO_IRQ; |
106 | } | 106 | } |
107 | 107 | ||
108 | static void gsc_asic_mask_irq(unsigned int irq) | 108 | static void gsc_asic_mask_irq(struct irq_data *d) |
109 | { | 109 | { |
110 | struct gsc_asic *irq_dev = get_irq_chip_data(irq); | 110 | struct gsc_asic *irq_dev = irq_data_get_irq_chip_data(d); |
111 | int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); | 111 | int local_irq = gsc_find_local_irq(d->irq, irq_dev->global_irq, 32); |
112 | u32 imr; | 112 | u32 imr; |
113 | 113 | ||
114 | DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq, | 114 | DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, d->irq, |
115 | irq_dev->name, imr); | 115 | irq_dev->name, imr); |
116 | 116 | ||
117 | /* Disable the IRQ line by clearing the bit in the IMR */ | 117 | /* Disable the IRQ line by clearing the bit in the IMR */ |
@@ -120,13 +120,13 @@ static void gsc_asic_mask_irq(unsigned int irq) | |||
120 | gsc_writel(imr, irq_dev->hpa + OFFSET_IMR); | 120 | gsc_writel(imr, irq_dev->hpa + OFFSET_IMR); |
121 | } | 121 | } |
122 | 122 | ||
123 | static void gsc_asic_unmask_irq(unsigned int irq) | 123 | static void gsc_asic_unmask_irq(struct irq_data *d) |
124 | { | 124 | { |
125 | struct gsc_asic *irq_dev = get_irq_chip_data(irq); | 125 | struct gsc_asic *irq_dev = irq_data_get_irq_chip_data(d); |
126 | int local_irq = gsc_find_local_irq(irq, irq_dev->global_irq, 32); | 126 | int local_irq = gsc_find_local_irq(d->irq, irq_dev->global_irq, 32); |
127 | u32 imr; | 127 | u32 imr; |
128 | 128 | ||
129 | DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, irq, | 129 | DEBPRINTK(KERN_DEBUG "%s(%d) %s: IMR 0x%x\n", __func__, d->irq, |
130 | irq_dev->name, imr); | 130 | irq_dev->name, imr); |
131 | 131 | ||
132 | /* Enable the IRQ line by setting the bit in the IMR */ | 132 | /* Enable the IRQ line by setting the bit in the IMR */ |
@@ -140,9 +140,9 @@ static void gsc_asic_unmask_irq(unsigned int irq) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | static struct irq_chip gsc_asic_interrupt_type = { | 142 | static struct irq_chip gsc_asic_interrupt_type = { |
143 | .name = "GSC-ASIC", | 143 | .name = "GSC-ASIC", |
144 | .unmask = gsc_asic_unmask_irq, | 144 | .irq_unmask = gsc_asic_unmask_irq, |
145 | .mask = gsc_asic_mask_irq, | 145 | .irq_mask = gsc_asic_mask_irq, |
146 | }; | 146 | }; |
147 | 147 | ||
148 | int gsc_assign_irq(struct irq_chip *type, void *data) | 148 | int gsc_assign_irq(struct irq_chip *type, void *data) |
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 0327894bf235..95930d016235 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c | |||
@@ -615,10 +615,10 @@ iosapic_set_irt_data( struct vector_info *vi, u32 *dp0, u32 *dp1) | |||
615 | } | 615 | } |
616 | 616 | ||
617 | 617 | ||
618 | static void iosapic_mask_irq(unsigned int irq) | 618 | static void iosapic_mask_irq(struct irq_data *d) |
619 | { | 619 | { |
620 | unsigned long flags; | 620 | unsigned long flags; |
621 | struct vector_info *vi = get_irq_chip_data(irq); | 621 | struct vector_info *vi = irq_data_get_irq_chip_data(d); |
622 | u32 d0, d1; | 622 | u32 d0, d1; |
623 | 623 | ||
624 | spin_lock_irqsave(&iosapic_lock, flags); | 624 | spin_lock_irqsave(&iosapic_lock, flags); |
@@ -628,9 +628,9 @@ static void iosapic_mask_irq(unsigned int irq) | |||
628 | spin_unlock_irqrestore(&iosapic_lock, flags); | 628 | spin_unlock_irqrestore(&iosapic_lock, flags); |
629 | } | 629 | } |
630 | 630 | ||
631 | static void iosapic_unmask_irq(unsigned int irq) | 631 | static void iosapic_unmask_irq(struct irq_data *d) |
632 | { | 632 | { |
633 | struct vector_info *vi = get_irq_chip_data(irq); | 633 | struct vector_info *vi = irq_data_get_irq_chip_data(d); |
634 | u32 d0, d1; | 634 | u32 d0, d1; |
635 | 635 | ||
636 | /* data is initialized by fixup_irq */ | 636 | /* data is initialized by fixup_irq */ |
@@ -666,34 +666,34 @@ printk("\n"); | |||
666 | * enables their IRQ. It can lead to "interesting" race conditions | 666 | * enables their IRQ. It can lead to "interesting" race conditions |
667 | * in the driver initialization sequence. | 667 | * in the driver initialization sequence. |
668 | */ | 668 | */ |
669 | DBG(KERN_DEBUG "enable_irq(%d): eoi(%p, 0x%x)\n", irq, | 669 | DBG(KERN_DEBUG "enable_irq(%d): eoi(%p, 0x%x)\n", d->irq, |
670 | vi->eoi_addr, vi->eoi_data); | 670 | vi->eoi_addr, vi->eoi_data); |
671 | iosapic_eoi(vi->eoi_addr, vi->eoi_data); | 671 | iosapic_eoi(vi->eoi_addr, vi->eoi_data); |
672 | } | 672 | } |
673 | 673 | ||
674 | static void iosapic_eoi_irq(unsigned int irq) | 674 | static void iosapic_eoi_irq(struct irq_data *d) |
675 | { | 675 | { |
676 | struct vector_info *vi = get_irq_chip_data(irq); | 676 | struct vector_info *vi = irq_data_get_irq_chip_data(d); |
677 | 677 | ||
678 | iosapic_eoi(vi->eoi_addr, vi->eoi_data); | 678 | iosapic_eoi(vi->eoi_addr, vi->eoi_data); |
679 | cpu_eoi_irq(irq); | 679 | cpu_eoi_irq(d); |
680 | } | 680 | } |
681 | 681 | ||
682 | #ifdef CONFIG_SMP | 682 | #ifdef CONFIG_SMP |
683 | static int iosapic_set_affinity_irq(unsigned int irq, | 683 | static int iosapic_set_affinity_irq(struct irq_data *d, |
684 | const struct cpumask *dest) | 684 | const struct cpumask *dest, bool force) |
685 | { | 685 | { |
686 | struct vector_info *vi = get_irq_chip_data(irq); | 686 | struct vector_info *vi = irq_data_get_irq_chip_data(d); |
687 | u32 d0, d1, dummy_d0; | 687 | u32 d0, d1, dummy_d0; |
688 | unsigned long flags; | 688 | unsigned long flags; |
689 | int dest_cpu; | 689 | int dest_cpu; |
690 | 690 | ||
691 | dest_cpu = cpu_check_affinity(irq, dest); | 691 | dest_cpu = cpu_check_affinity(d, dest); |
692 | if (dest_cpu < 0) | 692 | if (dest_cpu < 0) |
693 | return -1; | 693 | return -1; |
694 | 694 | ||
695 | cpumask_copy(irq_desc[irq].affinity, cpumask_of(dest_cpu)); | 695 | cpumask_copy(d->affinity, cpumask_of(dest_cpu)); |
696 | vi->txn_addr = txn_affinity_addr(irq, dest_cpu); | 696 | vi->txn_addr = txn_affinity_addr(d->irq, dest_cpu); |
697 | 697 | ||
698 | spin_lock_irqsave(&iosapic_lock, flags); | 698 | spin_lock_irqsave(&iosapic_lock, flags); |
699 | /* d1 contains the destination CPU, so only want to set that | 699 | /* d1 contains the destination CPU, so only want to set that |
@@ -708,13 +708,13 @@ static int iosapic_set_affinity_irq(unsigned int irq, | |||
708 | #endif | 708 | #endif |
709 | 709 | ||
710 | static struct irq_chip iosapic_interrupt_type = { | 710 | static struct irq_chip iosapic_interrupt_type = { |
711 | .name = "IO-SAPIC-level", | 711 | .name = "IO-SAPIC-level", |
712 | .unmask = iosapic_unmask_irq, | 712 | .irq_unmask = iosapic_unmask_irq, |
713 | .mask = iosapic_mask_irq, | 713 | .irq_mask = iosapic_mask_irq, |
714 | .ack = cpu_ack_irq, | 714 | .irq_ack = cpu_ack_irq, |
715 | .eoi = iosapic_eoi_irq, | 715 | .irq_eoi = iosapic_eoi_irq, |
716 | #ifdef CONFIG_SMP | 716 | #ifdef CONFIG_SMP |
717 | .set_affinity = iosapic_set_affinity_irq, | 717 | .irq_set_affinity = iosapic_set_affinity_irq, |
718 | #endif | 718 | #endif |
719 | }; | 719 | }; |
720 | 720 | ||
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c index 28241532c0fd..a4d8ff66a639 100644 --- a/drivers/parisc/superio.c +++ b/drivers/parisc/superio.c | |||
@@ -286,8 +286,9 @@ superio_init(struct pci_dev *pcidev) | |||
286 | } | 286 | } |
287 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO, superio_init); | 287 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO, superio_init); |
288 | 288 | ||
289 | static void superio_mask_irq(unsigned int irq) | 289 | static void superio_mask_irq(struct irq_data *d) |
290 | { | 290 | { |
291 | unsigned int irq = d->irq; | ||
291 | u8 r8; | 292 | u8 r8; |
292 | 293 | ||
293 | if ((irq < 1) || (irq == 2) || (irq > 7)) { | 294 | if ((irq < 1) || (irq == 2) || (irq > 7)) { |
@@ -303,8 +304,9 @@ static void superio_mask_irq(unsigned int irq) | |||
303 | outb (r8,IC_PIC1+1); | 304 | outb (r8,IC_PIC1+1); |
304 | } | 305 | } |
305 | 306 | ||
306 | static void superio_unmask_irq(unsigned int irq) | 307 | static void superio_unmask_irq(struct irq_data *d) |
307 | { | 308 | { |
309 | unsigned int irq = d->irq; | ||
308 | u8 r8; | 310 | u8 r8; |
309 | 311 | ||
310 | if ((irq < 1) || (irq == 2) || (irq > 7)) { | 312 | if ((irq < 1) || (irq == 2) || (irq > 7)) { |
@@ -320,9 +322,9 @@ static void superio_unmask_irq(unsigned int irq) | |||
320 | } | 322 | } |
321 | 323 | ||
322 | static struct irq_chip superio_interrupt_type = { | 324 | static struct irq_chip superio_interrupt_type = { |
323 | .name = SUPERIO, | 325 | .name = SUPERIO, |
324 | .unmask = superio_unmask_irq, | 326 | .irq_unmask = superio_unmask_irq, |
325 | .mask = superio_mask_irq, | 327 | .irq_mask = superio_mask_irq, |
326 | }; | 328 | }; |
327 | 329 | ||
328 | #ifdef DEBUG_SUPERIO_INIT | 330 | #ifdef DEBUG_SUPERIO_INIT |
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index a59af5b24f0a..222dfb737b11 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -138,6 +138,24 @@ config TC1100_WMI | |||
138 | This is a driver for the WMI extensions (wireless and bluetooth power | 138 | This is a driver for the WMI extensions (wireless and bluetooth power |
139 | control) of the HP Compaq TC1100 tablet. | 139 | control) of the HP Compaq TC1100 tablet. |
140 | 140 | ||
141 | config HP_ACCEL | ||
142 | tristate "HP laptop accelerometer" | ||
143 | depends on INPUT && ACPI | ||
144 | select SENSORS_LIS3LV02D | ||
145 | select NEW_LEDS | ||
146 | select LEDS_CLASS | ||
147 | help | ||
148 | This driver provides support for the "Mobile Data Protection System 3D" | ||
149 | or "3D DriveGuard" feature of HP laptops. On such systems the driver | ||
150 | should load automatically (via ACPI alias). | ||
151 | |||
152 | Support for a led indicating disk protection will be provided as | ||
153 | hp::hddprotect. For more information on the feature, refer to | ||
154 | Documentation/hwmon/lis3lv02d. | ||
155 | |||
156 | To compile this driver as a module, choose M here: the module will | ||
157 | be called hp_accel. | ||
158 | |||
141 | config HP_WMI | 159 | config HP_WMI |
142 | tristate "HP WMI extras" | 160 | tristate "HP WMI extras" |
143 | depends on ACPI_WMI | 161 | depends on ACPI_WMI |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 4ec4ff8f9182..299aefb3e74c 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
@@ -12,6 +12,7 @@ obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o | |||
12 | obj-$(CONFIG_DELL_WMI) += dell-wmi.o | 12 | obj-$(CONFIG_DELL_WMI) += dell-wmi.o |
13 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o | 13 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o |
14 | obj-$(CONFIG_ACERHDF) += acerhdf.o | 14 | obj-$(CONFIG_ACERHDF) += acerhdf.o |
15 | obj-$(CONFIG_HP_ACCEL) += hp_accel.o | ||
15 | obj-$(CONFIG_HP_WMI) += hp-wmi.o | 16 | obj-$(CONFIG_HP_WMI) += hp-wmi.o |
16 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o | 17 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o |
17 | obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o | 18 | obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o |
diff --git a/drivers/hwmon/hp_accel.c b/drivers/platform/x86/hp_accel.c index 3d21fa2b97cd..1b52d00e2f90 100644 --- a/drivers/hwmon/hp_accel.c +++ b/drivers/platform/x86/hp_accel.c | |||
@@ -35,11 +35,11 @@ | |||
35 | #include <linux/freezer.h> | 35 | #include <linux/freezer.h> |
36 | #include <linux/uaccess.h> | 36 | #include <linux/uaccess.h> |
37 | #include <linux/leds.h> | 37 | #include <linux/leds.h> |
38 | #include <linux/atomic.h> | ||
38 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
39 | #include <asm/atomic.h> | 40 | #include "../../misc/lis3lv02d/lis3lv02d.h" |
40 | #include "lis3lv02d.h" | ||
41 | 41 | ||
42 | #define DRIVER_NAME "lis3lv02d" | 42 | #define DRIVER_NAME "hp_accel" |
43 | #define ACPI_MDPS_CLASS "accelerometer" | 43 | #define ACPI_MDPS_CLASS "accelerometer" |
44 | 44 | ||
45 | /* Delayed LEDs infrastructure ------------------------------------ */ | 45 | /* Delayed LEDs infrastructure ------------------------------------ */ |
@@ -402,4 +402,3 @@ MODULE_LICENSE("GPL"); | |||
402 | 402 | ||
403 | module_init(lis3lv02d_init_module); | 403 | module_init(lis3lv02d_init_module); |
404 | module_exit(lis3lv02d_exit_module); | 404 | module_exit(lis3lv02d_exit_module); |
405 | |||
diff --git a/drivers/pps/clients/Makefile b/drivers/pps/clients/Makefile index 42517da07049..4feb7e9e71ee 100644 --- a/drivers/pps/clients/Makefile +++ b/drivers/pps/clients/Makefile | |||
@@ -6,6 +6,4 @@ obj-$(CONFIG_PPS_CLIENT_KTIMER) += pps-ktimer.o | |||
6 | obj-$(CONFIG_PPS_CLIENT_LDISC) += pps-ldisc.o | 6 | obj-$(CONFIG_PPS_CLIENT_LDISC) += pps-ldisc.o |
7 | obj-$(CONFIG_PPS_CLIENT_PARPORT) += pps_parport.o | 7 | obj-$(CONFIG_PPS_CLIENT_PARPORT) += pps_parport.o |
8 | 8 | ||
9 | ifeq ($(CONFIG_PPS_DEBUG),y) | 9 | ccflags-$(CONFIG_PPS_DEBUG) := -DDEBUG |
10 | EXTRA_CFLAGS += -DDEBUG | ||
11 | endif | ||
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile index b6139fe187bf..89b8eca825b5 100644 --- a/drivers/rapidio/Makefile +++ b/drivers/rapidio/Makefile | |||
@@ -5,6 +5,4 @@ obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o | |||
5 | 5 | ||
6 | obj-$(CONFIG_RAPIDIO) += switches/ | 6 | obj-$(CONFIG_RAPIDIO) += switches/ |
7 | 7 | ||
8 | ifeq ($(CONFIG_RAPIDIO_DEBUG),y) | 8 | subdir-ccflags-$(CONFIG_RAPIDIO_DEBUG) := -DDEBUG |
9 | EXTRA_CFLAGS += -DDEBUG | ||
10 | endif | ||
diff --git a/drivers/rapidio/switches/Makefile b/drivers/rapidio/switches/Makefile index 48d67a6b98c8..c4d3acc3c715 100644 --- a/drivers/rapidio/switches/Makefile +++ b/drivers/rapidio/switches/Makefile | |||
@@ -7,7 +7,3 @@ obj-$(CONFIG_RAPIDIO_CPS_XX) += idtcps.o | |||
7 | obj-$(CONFIG_RAPIDIO_TSI568) += tsi568.o | 7 | obj-$(CONFIG_RAPIDIO_TSI568) += tsi568.o |
8 | obj-$(CONFIG_RAPIDIO_TSI500) += tsi500.o | 8 | obj-$(CONFIG_RAPIDIO_TSI500) += tsi500.o |
9 | obj-$(CONFIG_RAPIDIO_CPS_GEN2) += idt_gen2.o | 9 | obj-$(CONFIG_RAPIDIO_CPS_GEN2) += idt_gen2.o |
10 | |||
11 | ifeq ($(CONFIG_RAPIDIO_DEBUG),y) | ||
12 | EXTRA_CFLAGS += -DDEBUG | ||
13 | endif | ||
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2afdaf3ff986..5f6c3838dcf6 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -2,9 +2,7 @@ | |||
2 | # Makefile for RTC class/drivers. | 2 | # Makefile for RTC class/drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_RTC_DEBUG),y) | 5 | ccflags-$(CONFIG_RTC_DEBUG) := -DDEBUG |
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | 6 | ||
9 | obj-$(CONFIG_RTC_LIB) += rtc-lib.o | 7 | obj-$(CONFIG_RTC_LIB) += rtc-lib.o |
10 | obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o | 8 | obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o |
diff --git a/drivers/scsi/aacraid/Makefile b/drivers/scsi/aacraid/Makefile index f1cca4ee5410..92df4d6b6147 100644 --- a/drivers/scsi/aacraid/Makefile +++ b/drivers/scsi/aacraid/Makefile | |||
@@ -5,4 +5,4 @@ obj-$(CONFIG_SCSI_AACRAID) := aacraid.o | |||
5 | aacraid-objs := linit.o aachba.o commctrl.o comminit.o commsup.o \ | 5 | aacraid-objs := linit.o aachba.o commctrl.o comminit.o commsup.o \ |
6 | dpcsup.o rx.o sa.o rkt.o nark.o | 6 | dpcsup.o rx.o sa.o rkt.o nark.o |
7 | 7 | ||
8 | EXTRA_CFLAGS := -Idrivers/scsi | 8 | ccflags-y := -Idrivers/scsi |
diff --git a/drivers/scsi/aic94xx/Makefile b/drivers/scsi/aic94xx/Makefile index e78ce0fa44d2..c0a15c754585 100644 --- a/drivers/scsi/aic94xx/Makefile +++ b/drivers/scsi/aic94xx/Makefile | |||
@@ -22,9 +22,7 @@ | |||
22 | # along with the aic94xx driver; if not, write to the Free Software | 22 | # along with the aic94xx driver; if not, write to the Free Software |
23 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 23 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
24 | 24 | ||
25 | ifeq ($(CONFIG_AIC94XX_DEBUG),y) | 25 | ccflags-$(CONFIG_AIC94XX_DEBUG) := -DASD_DEBUG -DASD_ENTER_EXIT |
26 | EXTRA_CFLAGS += -DASD_DEBUG -DASD_ENTER_EXIT | ||
27 | endif | ||
28 | 26 | ||
29 | obj-$(CONFIG_SCSI_AIC94XX) += aic94xx.o | 27 | obj-$(CONFIG_SCSI_AIC94XX) += aic94xx.o |
30 | aic94xx-y += aic94xx_init.o \ | 28 | aic94xx-y += aic94xx_init.o \ |
diff --git a/drivers/scsi/libsas/Makefile b/drivers/scsi/libsas/Makefile index 566a10024598..2e70140f70c3 100644 --- a/drivers/scsi/libsas/Makefile +++ b/drivers/scsi/libsas/Makefile | |||
@@ -32,4 +32,4 @@ libsas-y += sas_init.o \ | |||
32 | sas_scsi_host.o \ | 32 | sas_scsi_host.o \ |
33 | sas_task.o | 33 | sas_task.o |
34 | libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o | 34 | libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o |
35 | libsas-$(CONFIG_SCSI_SAS_HOST_SMP) += sas_host_smp.o \ No newline at end of file | 35 | libsas-$(CONFIG_SCSI_SAS_HOST_SMP) += sas_host_smp.o |
diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile index ad05d6edb8f6..14de249917f8 100644 --- a/drivers/scsi/lpfc/Makefile +++ b/drivers/scsi/lpfc/Makefile | |||
@@ -19,10 +19,8 @@ | |||
19 | # *******************************************************************/ | 19 | # *******************************************************************/ |
20 | ###################################################################### | 20 | ###################################################################### |
21 | 21 | ||
22 | ifneq ($(GCOV),) | 22 | ccflags-$(GCOV) := -fprofile-arcs -ftest-coverage |
23 | EXTRA_CFLAGS += -fprofile-arcs -ftest-coverage | 23 | ccflags-$(GCOV) += -O0 |
24 | EXTRA_CFLAGS += -O0 | ||
25 | endif | ||
26 | 24 | ||
27 | obj-$(CONFIG_SCSI_LPFC) := lpfc.o | 25 | obj-$(CONFIG_SCSI_LPFC) := lpfc.o |
28 | 26 | ||
diff --git a/drivers/scsi/mvsas/Makefile b/drivers/scsi/mvsas/Makefile index 52ac4264677d..ffbf759e46f1 100644 --- a/drivers/scsi/mvsas/Makefile +++ b/drivers/scsi/mvsas/Makefile | |||
@@ -21,9 +21,7 @@ | |||
21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
22 | # USA | 22 | # USA |
23 | 23 | ||
24 | ifeq ($(CONFIG_SCSI_MVSAS_DEBUG),y) | 24 | ccflags-$(CONFIG_SCSI_MVSAS_DEBUG) := -DMV_DEBUG |
25 | EXTRA_CFLAGS += -DMV_DEBUG | ||
26 | endif | ||
27 | 25 | ||
28 | obj-$(CONFIG_SCSI_MVSAS) += mvsas.o | 26 | obj-$(CONFIG_SCSI_MVSAS) += mvsas.o |
29 | mvsas-y += mv_init.o \ | 27 | mvsas-y += mv_init.o \ |
diff --git a/drivers/scsi/pcmcia/Makefile b/drivers/scsi/pcmcia/Makefile index eca379059db6..683bf148b5b7 100644 --- a/drivers/scsi/pcmcia/Makefile +++ b/drivers/scsi/pcmcia/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | EXTRA_CFLAGS += -Idrivers/scsi | 2 | ccflags-y := -Idrivers/scsi |
3 | 3 | ||
4 | # 16-bit client drivers | 4 | # 16-bit client drivers |
5 | obj-$(CONFIG_PCMCIA_QLOGIC) += qlogic_cs.o | 5 | obj-$(CONFIG_PCMCIA_QLOGIC) += qlogic_cs.o |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 991de3c15cfc..633c2395a92a 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -3,14 +3,14 @@ | |||
3 | * | 3 | * |
4 | * SCSI error/timeout handling | 4 | * SCSI error/timeout handling |
5 | * Initial versions: Eric Youngdale. Based upon conversations with | 5 | * Initial versions: Eric Youngdale. Based upon conversations with |
6 | * Leonard Zubkoff and David Miller at Linux Expo, | 6 | * Leonard Zubkoff and David Miller at Linux Expo, |
7 | * ideas originating from all over the place. | 7 | * ideas originating from all over the place. |
8 | * | 8 | * |
9 | * Restructured scsi_unjam_host and associated functions. | 9 | * Restructured scsi_unjam_host and associated functions. |
10 | * September 04, 2002 Mike Anderson (andmike@us.ibm.com) | 10 | * September 04, 2002 Mike Anderson (andmike@us.ibm.com) |
11 | * | 11 | * |
12 | * Forward port of Russell King's (rmk@arm.linux.org.uk) changes and | 12 | * Forward port of Russell King's (rmk@arm.linux.org.uk) changes and |
13 | * minor cleanups. | 13 | * minor cleanups. |
14 | * September 30, 2002 Mike Anderson (andmike@us.ibm.com) | 14 | * September 30, 2002 Mike Anderson (andmike@us.ibm.com) |
15 | */ | 15 | */ |
16 | 16 | ||
@@ -129,14 +129,15 @@ enum blk_eh_timer_return scsi_times_out(struct request *req) | |||
129 | { | 129 | { |
130 | struct scsi_cmnd *scmd = req->special; | 130 | struct scsi_cmnd *scmd = req->special; |
131 | enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; | 131 | enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; |
132 | struct Scsi_Host *host = scmd->device->host; | ||
132 | 133 | ||
133 | trace_scsi_dispatch_cmd_timeout(scmd); | 134 | trace_scsi_dispatch_cmd_timeout(scmd); |
134 | scsi_log_completion(scmd, TIMEOUT_ERROR); | 135 | scsi_log_completion(scmd, TIMEOUT_ERROR); |
135 | 136 | ||
136 | if (scmd->device->host->transportt->eh_timed_out) | 137 | if (host->transportt->eh_timed_out) |
137 | rtn = scmd->device->host->transportt->eh_timed_out(scmd); | 138 | rtn = host->transportt->eh_timed_out(scmd); |
138 | else if (scmd->device->host->hostt->eh_timed_out) | 139 | else if (host->hostt->eh_timed_out) |
139 | rtn = scmd->device->host->hostt->eh_timed_out(scmd); | 140 | rtn = host->hostt->eh_timed_out(scmd); |
140 | 141 | ||
141 | if (unlikely(rtn == BLK_EH_NOT_HANDLED && | 142 | if (unlikely(rtn == BLK_EH_NOT_HANDLED && |
142 | !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { | 143 | !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { |
@@ -195,7 +196,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost, | |||
195 | ++total_failures; | 196 | ++total_failures; |
196 | if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) | 197 | if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) |
197 | ++cmd_cancel; | 198 | ++cmd_cancel; |
198 | else | 199 | else |
199 | ++cmd_failed; | 200 | ++cmd_failed; |
200 | } | 201 | } |
201 | } | 202 | } |
@@ -214,7 +215,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost, | |||
214 | 215 | ||
215 | SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d commands on %d" | 216 | SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d commands on %d" |
216 | " devices require eh work\n", | 217 | " devices require eh work\n", |
217 | total_failures, devices_failed)); | 218 | total_failures, devices_failed)); |
218 | } | 219 | } |
219 | #endif | 220 | #endif |
220 | 221 | ||
@@ -294,7 +295,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd) | |||
294 | return NEEDS_RETRY; | 295 | return NEEDS_RETRY; |
295 | } | 296 | } |
296 | /* | 297 | /* |
297 | * if the device is in the process of becoming ready, we | 298 | * if the device is in the process of becoming ready, we |
298 | * should retry. | 299 | * should retry. |
299 | */ | 300 | */ |
300 | if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01)) | 301 | if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01)) |
@@ -488,7 +489,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd) | |||
488 | */ | 489 | */ |
489 | static void scsi_eh_done(struct scsi_cmnd *scmd) | 490 | static void scsi_eh_done(struct scsi_cmnd *scmd) |
490 | { | 491 | { |
491 | struct completion *eh_action; | 492 | struct completion *eh_action; |
492 | 493 | ||
493 | SCSI_LOG_ERROR_RECOVERY(3, | 494 | SCSI_LOG_ERROR_RECOVERY(3, |
494 | printk("%s scmd: %p result: %x\n", | 495 | printk("%s scmd: %p result: %x\n", |
@@ -507,22 +508,23 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd) | |||
507 | { | 508 | { |
508 | unsigned long flags; | 509 | unsigned long flags; |
509 | int rtn; | 510 | int rtn; |
511 | struct Scsi_Host *host = scmd->device->host; | ||
512 | struct scsi_host_template *hostt = host->hostt; | ||
510 | 513 | ||
511 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", | 514 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Host RST\n", |
512 | __func__)); | 515 | __func__)); |
513 | 516 | ||
514 | if (!scmd->device->host->hostt->eh_host_reset_handler) | 517 | if (!hostt->eh_host_reset_handler) |
515 | return FAILED; | 518 | return FAILED; |
516 | 519 | ||
517 | rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd); | 520 | rtn = hostt->eh_host_reset_handler(scmd); |
518 | 521 | ||
519 | if (rtn == SUCCESS) { | 522 | if (rtn == SUCCESS) { |
520 | if (!scmd->device->host->hostt->skip_settle_delay) | 523 | if (!hostt->skip_settle_delay) |
521 | ssleep(HOST_RESET_SETTLE_TIME); | 524 | ssleep(HOST_RESET_SETTLE_TIME); |
522 | spin_lock_irqsave(scmd->device->host->host_lock, flags); | 525 | spin_lock_irqsave(host->host_lock, flags); |
523 | scsi_report_bus_reset(scmd->device->host, | 526 | scsi_report_bus_reset(host, scmd_channel(scmd)); |
524 | scmd_channel(scmd)); | 527 | spin_unlock_irqrestore(host->host_lock, flags); |
525 | spin_unlock_irqrestore(scmd->device->host->host_lock, flags); | ||
526 | } | 528 | } |
527 | 529 | ||
528 | return rtn; | 530 | return rtn; |
@@ -536,22 +538,23 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd) | |||
536 | { | 538 | { |
537 | unsigned long flags; | 539 | unsigned long flags; |
538 | int rtn; | 540 | int rtn; |
541 | struct Scsi_Host *host = scmd->device->host; | ||
542 | struct scsi_host_template *hostt = host->hostt; | ||
539 | 543 | ||
540 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n", | 544 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Snd Bus RST\n", |
541 | __func__)); | 545 | __func__)); |
542 | 546 | ||
543 | if (!scmd->device->host->hostt->eh_bus_reset_handler) | 547 | if (!hostt->eh_bus_reset_handler) |
544 | return FAILED; | 548 | return FAILED; |
545 | 549 | ||
546 | rtn = scmd->device->host->hostt->eh_bus_reset_handler(scmd); | 550 | rtn = hostt->eh_bus_reset_handler(scmd); |
547 | 551 | ||
548 | if (rtn == SUCCESS) { | 552 | if (rtn == SUCCESS) { |
549 | if (!scmd->device->host->hostt->skip_settle_delay) | 553 | if (!hostt->skip_settle_delay) |
550 | ssleep(BUS_RESET_SETTLE_TIME); | 554 | ssleep(BUS_RESET_SETTLE_TIME); |
551 | spin_lock_irqsave(scmd->device->host->host_lock, flags); | 555 | spin_lock_irqsave(host->host_lock, flags); |
552 | scsi_report_bus_reset(scmd->device->host, | 556 | scsi_report_bus_reset(host, scmd_channel(scmd)); |
553 | scmd_channel(scmd)); | 557 | spin_unlock_irqrestore(host->host_lock, flags); |
554 | spin_unlock_irqrestore(scmd->device->host->host_lock, flags); | ||
555 | } | 558 | } |
556 | 559 | ||
557 | return rtn; | 560 | return rtn; |
@@ -577,16 +580,18 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd) | |||
577 | { | 580 | { |
578 | unsigned long flags; | 581 | unsigned long flags; |
579 | int rtn; | 582 | int rtn; |
583 | struct Scsi_Host *host = scmd->device->host; | ||
584 | struct scsi_host_template *hostt = host->hostt; | ||
580 | 585 | ||
581 | if (!scmd->device->host->hostt->eh_target_reset_handler) | 586 | if (!hostt->eh_target_reset_handler) |
582 | return FAILED; | 587 | return FAILED; |
583 | 588 | ||
584 | rtn = scmd->device->host->hostt->eh_target_reset_handler(scmd); | 589 | rtn = hostt->eh_target_reset_handler(scmd); |
585 | if (rtn == SUCCESS) { | 590 | if (rtn == SUCCESS) { |
586 | spin_lock_irqsave(scmd->device->host->host_lock, flags); | 591 | spin_lock_irqsave(host->host_lock, flags); |
587 | __starget_for_each_device(scsi_target(scmd->device), NULL, | 592 | __starget_for_each_device(scsi_target(scmd->device), NULL, |
588 | __scsi_report_device_reset); | 593 | __scsi_report_device_reset); |
589 | spin_unlock_irqrestore(scmd->device->host->host_lock, flags); | 594 | spin_unlock_irqrestore(host->host_lock, flags); |
590 | } | 595 | } |
591 | 596 | ||
592 | return rtn; | 597 | return rtn; |
@@ -605,27 +610,28 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd) | |||
605 | static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd) | 610 | static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd) |
606 | { | 611 | { |
607 | int rtn; | 612 | int rtn; |
613 | struct scsi_host_template *hostt = scmd->device->host->hostt; | ||
608 | 614 | ||
609 | if (!scmd->device->host->hostt->eh_device_reset_handler) | 615 | if (!hostt->eh_device_reset_handler) |
610 | return FAILED; | 616 | return FAILED; |
611 | 617 | ||
612 | rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd); | 618 | rtn = hostt->eh_device_reset_handler(scmd); |
613 | if (rtn == SUCCESS) | 619 | if (rtn == SUCCESS) |
614 | __scsi_report_device_reset(scmd->device, NULL); | 620 | __scsi_report_device_reset(scmd->device, NULL); |
615 | return rtn; | 621 | return rtn; |
616 | } | 622 | } |
617 | 623 | ||
618 | static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd) | 624 | static int scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd) |
619 | { | 625 | { |
620 | if (!scmd->device->host->hostt->eh_abort_handler) | 626 | if (!hostt->eh_abort_handler) |
621 | return FAILED; | 627 | return FAILED; |
622 | 628 | ||
623 | return scmd->device->host->hostt->eh_abort_handler(scmd); | 629 | return hostt->eh_abort_handler(scmd); |
624 | } | 630 | } |
625 | 631 | ||
626 | static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) | 632 | static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) |
627 | { | 633 | { |
628 | if (scsi_try_to_abort_cmd(scmd) != SUCCESS) | 634 | if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS) |
629 | if (scsi_try_bus_device_reset(scmd) != SUCCESS) | 635 | if (scsi_try_bus_device_reset(scmd) != SUCCESS) |
630 | if (scsi_try_target_reset(scmd) != SUCCESS) | 636 | if (scsi_try_target_reset(scmd) != SUCCESS) |
631 | if (scsi_try_bus_reset(scmd) != SUCCESS) | 637 | if (scsi_try_bus_reset(scmd) != SUCCESS) |
@@ -846,7 +852,7 @@ EXPORT_SYMBOL(scsi_eh_finish_cmd); | |||
846 | * | 852 | * |
847 | * Description: | 853 | * Description: |
848 | * See if we need to request sense information. if so, then get it | 854 | * See if we need to request sense information. if so, then get it |
849 | * now, so we have a better idea of what to do. | 855 | * now, so we have a better idea of what to do. |
850 | * | 856 | * |
851 | * Notes: | 857 | * Notes: |
852 | * This has the unfortunate side effect that if a shost adapter does | 858 | * This has the unfortunate side effect that if a shost adapter does |
@@ -958,7 +964,7 @@ static int scsi_eh_abort_cmds(struct list_head *work_q, | |||
958 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:" | 964 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting cmd:" |
959 | "0x%p\n", current->comm, | 965 | "0x%p\n", current->comm, |
960 | scmd)); | 966 | scmd)); |
961 | rtn = scsi_try_to_abort_cmd(scmd); | 967 | rtn = scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd); |
962 | if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { | 968 | if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { |
963 | scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD; | 969 | scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD; |
964 | if (!scsi_device_online(scmd->device) || | 970 | if (!scsi_device_online(scmd->device) || |
@@ -966,7 +972,6 @@ static int scsi_eh_abort_cmds(struct list_head *work_q, | |||
966 | !scsi_eh_tur(scmd)) { | 972 | !scsi_eh_tur(scmd)) { |
967 | scsi_eh_finish_cmd(scmd, done_q); | 973 | scsi_eh_finish_cmd(scmd, done_q); |
968 | } | 974 | } |
969 | |||
970 | } else | 975 | } else |
971 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting" | 976 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: aborting" |
972 | " cmd failed:" | 977 | " cmd failed:" |
@@ -1010,7 +1015,7 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd) | |||
1010 | * | 1015 | * |
1011 | * Notes: | 1016 | * Notes: |
1012 | * If commands are failing due to not ready, initializing command required, | 1017 | * If commands are failing due to not ready, initializing command required, |
1013 | * try revalidating the device, which will end up sending a start unit. | 1018 | * try revalidating the device, which will end up sending a start unit. |
1014 | */ | 1019 | */ |
1015 | static int scsi_eh_stu(struct Scsi_Host *shost, | 1020 | static int scsi_eh_stu(struct Scsi_Host *shost, |
1016 | struct list_head *work_q, | 1021 | struct list_head *work_q, |
@@ -1064,7 +1069,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost, | |||
1064 | * Try a bus device reset. Still, look to see whether we have multiple | 1069 | * Try a bus device reset. Still, look to see whether we have multiple |
1065 | * devices that are jammed or not - if we have multiple devices, it | 1070 | * devices that are jammed or not - if we have multiple devices, it |
1066 | * makes no sense to try bus_device_reset - we really would need to try | 1071 | * makes no sense to try bus_device_reset - we really would need to try |
1067 | * a bus_reset instead. | 1072 | * a bus_reset instead. |
1068 | */ | 1073 | */ |
1069 | static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, | 1074 | static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, |
1070 | struct list_head *work_q, | 1075 | struct list_head *work_q, |
@@ -1164,7 +1169,7 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost, | |||
1164 | } | 1169 | } |
1165 | 1170 | ||
1166 | /** | 1171 | /** |
1167 | * scsi_eh_bus_reset - send a bus reset | 1172 | * scsi_eh_bus_reset - send a bus reset |
1168 | * @shost: &scsi host being recovered. | 1173 | * @shost: &scsi host being recovered. |
1169 | * @work_q: &list_head for pending commands. | 1174 | * @work_q: &list_head for pending commands. |
1170 | * @done_q: &list_head for processed commands. | 1175 | * @done_q: &list_head for processed commands. |
@@ -1181,7 +1186,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost, | |||
1181 | * we really want to loop over the various channels, and do this on | 1186 | * we really want to loop over the various channels, and do this on |
1182 | * a channel by channel basis. we should also check to see if any | 1187 | * a channel by channel basis. we should also check to see if any |
1183 | * of the failed commands are on soft_reset devices, and if so, skip | 1188 | * of the failed commands are on soft_reset devices, and if so, skip |
1184 | * the reset. | 1189 | * the reset. |
1185 | */ | 1190 | */ |
1186 | 1191 | ||
1187 | for (channel = 0; channel <= shost->max_channel; channel++) { | 1192 | for (channel = 0; channel <= shost->max_channel; channel++) { |
@@ -1223,7 +1228,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost, | |||
1223 | } | 1228 | } |
1224 | 1229 | ||
1225 | /** | 1230 | /** |
1226 | * scsi_eh_host_reset - send a host reset | 1231 | * scsi_eh_host_reset - send a host reset |
1227 | * @work_q: list_head for processed commands. | 1232 | * @work_q: list_head for processed commands. |
1228 | * @done_q: list_head for processed commands. | 1233 | * @done_q: list_head for processed commands. |
1229 | */ | 1234 | */ |
@@ -1376,7 +1381,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) | |||
1376 | return SUCCESS; | 1381 | return SUCCESS; |
1377 | /* | 1382 | /* |
1378 | * when the low level driver returns did_soft_error, | 1383 | * when the low level driver returns did_soft_error, |
1379 | * it is responsible for keeping an internal retry counter | 1384 | * it is responsible for keeping an internal retry counter |
1380 | * in order to avoid endless loops (db) | 1385 | * in order to avoid endless loops (db) |
1381 | * | 1386 | * |
1382 | * actually this is a bug in this function here. we should | 1387 | * actually this is a bug in this function here. we should |
@@ -1414,7 +1419,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) | |||
1414 | */ | 1419 | */ |
1415 | break; | 1420 | break; |
1416 | /* fallthrough */ | 1421 | /* fallthrough */ |
1417 | |||
1418 | case DID_BUS_BUSY: | 1422 | case DID_BUS_BUSY: |
1419 | case DID_PARITY: | 1423 | case DID_PARITY: |
1420 | goto maybe_retry; | 1424 | goto maybe_retry; |
@@ -1982,7 +1986,7 @@ int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, | |||
1982 | if (sb_len > 7) | 1986 | if (sb_len > 7) |
1983 | sshdr->additional_length = sense_buffer[7]; | 1987 | sshdr->additional_length = sense_buffer[7]; |
1984 | } else { | 1988 | } else { |
1985 | /* | 1989 | /* |
1986 | * fixed format | 1990 | * fixed format |
1987 | */ | 1991 | */ |
1988 | if (sb_len > 2) | 1992 | if (sb_len > 2) |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 38072e4e74bd..e35a17687c05 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -1646,7 +1646,7 @@ static int autosuspend_check(struct usb_device *udev) | |||
1646 | return 0; | 1646 | return 0; |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | static int usb_runtime_suspend(struct device *dev) | 1649 | int usb_runtime_suspend(struct device *dev) |
1650 | { | 1650 | { |
1651 | struct usb_device *udev = to_usb_device(dev); | 1651 | struct usb_device *udev = to_usb_device(dev); |
1652 | int status; | 1652 | int status; |
@@ -1667,7 +1667,7 @@ static int usb_runtime_suspend(struct device *dev) | |||
1667 | return status; | 1667 | return status; |
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | static int usb_runtime_resume(struct device *dev) | 1670 | int usb_runtime_resume(struct device *dev) |
1671 | { | 1671 | { |
1672 | struct usb_device *udev = to_usb_device(dev); | 1672 | struct usb_device *udev = to_usb_device(dev); |
1673 | int status; | 1673 | int status; |
@@ -1679,7 +1679,7 @@ static int usb_runtime_resume(struct device *dev) | |||
1679 | return status; | 1679 | return status; |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | static int usb_runtime_idle(struct device *dev) | 1682 | int usb_runtime_idle(struct device *dev) |
1683 | { | 1683 | { |
1684 | struct usb_device *udev = to_usb_device(dev); | 1684 | struct usb_device *udev = to_usb_device(dev); |
1685 | 1685 | ||
@@ -1691,19 +1691,10 @@ static int usb_runtime_idle(struct device *dev) | |||
1691 | return 0; | 1691 | return 0; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | static const struct dev_pm_ops usb_bus_pm_ops = { | ||
1695 | .runtime_suspend = usb_runtime_suspend, | ||
1696 | .runtime_resume = usb_runtime_resume, | ||
1697 | .runtime_idle = usb_runtime_idle, | ||
1698 | }; | ||
1699 | |||
1700 | #endif /* CONFIG_USB_SUSPEND */ | 1694 | #endif /* CONFIG_USB_SUSPEND */ |
1701 | 1695 | ||
1702 | struct bus_type usb_bus_type = { | 1696 | struct bus_type usb_bus_type = { |
1703 | .name = "usb", | 1697 | .name = "usb", |
1704 | .match = usb_device_match, | 1698 | .match = usb_device_match, |
1705 | .uevent = usb_uevent, | 1699 | .uevent = usb_uevent, |
1706 | #ifdef CONFIG_USB_SUSPEND | ||
1707 | .pm = &usb_bus_pm_ops, | ||
1708 | #endif | ||
1709 | }; | 1700 | }; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 079cb57bab4f..d9d4b169404f 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -315,6 +315,11 @@ static const struct dev_pm_ops usb_device_pm_ops = { | |||
315 | .thaw = usb_dev_thaw, | 315 | .thaw = usb_dev_thaw, |
316 | .poweroff = usb_dev_poweroff, | 316 | .poweroff = usb_dev_poweroff, |
317 | .restore = usb_dev_restore, | 317 | .restore = usb_dev_restore, |
318 | #ifdef CONFIG_USB_SUSPEND | ||
319 | .runtime_suspend = usb_runtime_suspend, | ||
320 | .runtime_resume = usb_runtime_resume, | ||
321 | .runtime_idle = usb_runtime_idle, | ||
322 | #endif | ||
318 | }; | 323 | }; |
319 | 324 | ||
320 | #endif /* CONFIG_PM */ | 325 | #endif /* CONFIG_PM */ |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index a9cf484ecae4..d450b742137e 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -77,6 +77,9 @@ static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg) | |||
77 | extern void usb_autosuspend_device(struct usb_device *udev); | 77 | extern void usb_autosuspend_device(struct usb_device *udev); |
78 | extern int usb_autoresume_device(struct usb_device *udev); | 78 | extern int usb_autoresume_device(struct usb_device *udev); |
79 | extern int usb_remote_wakeup(struct usb_device *dev); | 79 | extern int usb_remote_wakeup(struct usb_device *dev); |
80 | extern int usb_runtime_suspend(struct device *dev); | ||
81 | extern int usb_runtime_resume(struct device *dev); | ||
82 | extern int usb_runtime_idle(struct device *dev); | ||
80 | 83 | ||
81 | #else | 84 | #else |
82 | 85 | ||
diff --git a/drivers/video/intelfb/Makefile b/drivers/video/intelfb/Makefile index 6c782d3ae1be..f7d631ebee8e 100644 --- a/drivers/video/intelfb/Makefile +++ b/drivers/video/intelfb/Makefile | |||
@@ -4,7 +4,4 @@ intelfb-y := intelfbdrv.o intelfbhw.o | |||
4 | intelfb-$(CONFIG_FB_INTEL_I2C) += intelfb_i2c.o | 4 | intelfb-$(CONFIG_FB_INTEL_I2C) += intelfb_i2c.o |
5 | intelfb-objs := $(intelfb-y) | 5 | intelfb-objs := $(intelfb-y) |
6 | 6 | ||
7 | ifdef CONFIG_FB_INTEL_DEBUG | 7 | ccflags-$(CONFIG_FB_INTEL_DEBUG) := -DDEBUG -DREGDUMP |
8 | #EXTRA_CFLAGS += -DDEBUG -DVERBOSE -DREGDUMP | ||
9 | EXTRA_CFLAGS += -DDEBUG -DREGDUMP | ||
10 | endif | ||
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c index a082debe824b..a74439affce9 100644 --- a/drivers/video/matrox/matroxfb_base.c +++ b/drivers/video/matrox/matroxfb_base.c | |||
@@ -1461,13 +1461,6 @@ static struct board { | |||
1461 | MGA_G100, | 1461 | MGA_G100, |
1462 | &vbG100, | 1462 | &vbG100, |
1463 | "MGA-G100 (AGP)"}, | 1463 | "MGA-G100 (AGP)"}, |
1464 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI, 0xFF, | ||
1465 | 0, 0, | ||
1466 | DEVF_G200, | ||
1467 | 230000, | ||
1468 | MGA_G200, | ||
1469 | &vbG200, | ||
1470 | "MGA-G200eV (PCI)"}, | ||
1471 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 0xFF, | 1464 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, 0xFF, |
1472 | 0, 0, | 1465 | 0, 0, |
1473 | DEVF_G200, | 1466 | DEVF_G200, |
@@ -2119,8 +2112,6 @@ static struct pci_device_id matroxfb_devices[] = { | |||
2119 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2112 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
2120 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP, | 2113 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G100_AGP, |
2121 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2114 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
2122 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200EV_PCI, | ||
2123 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | ||
2124 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, | 2115 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_PCI, |
2125 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2116 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
2126 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, | 2117 | {PCI_VENDOR_ID_MATROX, PCI_DEVICE_ID_MATROX_G200_AGP, |