28
26
#include <linux/mmc/core.h>
29
27
#include <linux/mmc/sdio_func.h>
30
28
#include <linux/mmc/sdio_ids.h>
29
#include <linux/suspend.h>
32
31
#include <dngl_stats.h>
35
#if defined(CONFIG_PM_SLEEP)
36
#include <linux/suspend.h>
37
extern volatile bool dhd_mmc_suspend;
39
34
#include "bcmsdh_sdmmc.h"
41
36
extern int sdio_function_init(void);
70
65
int sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, u32 regaddr,
71
66
int regsize, u32 *data);
68
void sdioh_sdio_set_host_pm_flags(int flag)
70
if (sdio_set_host_pm_flags(gInstance->func[1], flag))
71
printk(KERN_ERR "%s: Failed to set pm_flags 0x%08x\n",\
72
__func__, (unsigned int)flag);
73
75
static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
113
115
* Public entry points & extern's
115
extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *bar0, uint irq)
117
sdioh_info_t *sdioh_attach(void *bar0, uint irq)
117
119
sdioh_info_t *sd;
268
269
#endif /* defined(OOB_INTR_ONLY) && defined(HW_OOB) */
270
/* Configure callback to client when we recieve client interrupt */
271
/* Configure callback to client when we receive client interrupt */
271
272
extern SDIOH_API_RC
272
273
sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
441
442
val_size = sizeof(int);
443
444
if (plen >= (int)sizeof(int_val))
444
bcopy(params, &int_val, sizeof(int_val));
445
memcpy(&int_val, params, sizeof(int_val));
446
447
bool_val = (int_val != 0) ? true : false;
449
450
switch (actionid) {
450
451
case IOV_GVAL(IOV_MSGLEVEL):
451
452
int_val = (s32) sd_msglevel;
452
bcopy(&int_val, arg, val_size);
453
memcpy(arg, &int_val, val_size);
455
456
case IOV_SVAL(IOV_MSGLEVEL):
459
460
case IOV_GVAL(IOV_BLOCKMODE):
460
461
int_val = (s32) si->sd_blockmode;
461
bcopy(&int_val, arg, val_size);
462
memcpy(arg, &int_val, val_size);
464
465
case IOV_SVAL(IOV_BLOCKMODE):
469
470
case IOV_GVAL(IOV_BLOCKSIZE):
470
471
if ((u32) int_val > si->num_funcs) {
471
bcmerror = BCME_BADARG;
474
475
int_val = (s32) si->client_block_size[int_val];
475
bcopy(&int_val, arg, val_size);
476
memcpy(arg, &int_val, val_size);
478
479
case IOV_SVAL(IOV_BLOCKSIZE):
515
516
case IOV_GVAL(IOV_RXCHAIN):
517
bcopy(&int_val, arg, val_size);
518
memcpy(arg, &int_val, val_size);
520
521
case IOV_GVAL(IOV_DMA):
521
522
int_val = (s32) si->sd_use_dma;
522
bcopy(&int_val, arg, val_size);
523
memcpy(arg, &int_val, val_size);
525
526
case IOV_SVAL(IOV_DMA):
529
530
case IOV_GVAL(IOV_USEINTS):
530
531
int_val = (s32) si->use_client_ints;
531
bcopy(&int_val, arg, val_size);
532
memcpy(arg, &int_val, val_size);
534
535
case IOV_SVAL(IOV_USEINTS):
543
544
case IOV_GVAL(IOV_DIVISOR):
544
545
int_val = (u32) sd_divisor;
545
bcopy(&int_val, arg, val_size);
546
memcpy(arg, &int_val, val_size);
548
549
case IOV_SVAL(IOV_DIVISOR):
552
553
case IOV_GVAL(IOV_POWER):
553
554
int_val = (u32) sd_power;
554
bcopy(&int_val, arg, val_size);
555
memcpy(arg, &int_val, val_size);
557
558
case IOV_SVAL(IOV_POWER):
561
562
case IOV_GVAL(IOV_CLOCK):
562
563
int_val = (u32) sd_clock;
563
bcopy(&int_val, arg, val_size);
564
memcpy(arg, &int_val, val_size);
566
567
case IOV_SVAL(IOV_CLOCK):
570
571
case IOV_GVAL(IOV_SDMODE):
571
572
int_val = (u32) sd_sdmode;
572
bcopy(&int_val, arg, val_size);
573
memcpy(arg, &int_val, val_size);
575
576
case IOV_SVAL(IOV_SDMODE):
579
580
case IOV_GVAL(IOV_HISPEED):
580
581
int_val = (u32) sd_hiok;
581
bcopy(&int_val, arg, val_size);
582
memcpy(arg, &int_val, val_size);
584
585
case IOV_SVAL(IOV_HISPEED):
588
589
case IOV_GVAL(IOV_NUMINTS):
589
590
int_val = (s32) si->intrcount;
590
bcopy(&int_val, arg, val_size);
591
memcpy(arg, &int_val, val_size);
593
594
case IOV_GVAL(IOV_NUMLOCALINTS):
594
595
int_val = (s32) 0;
595
bcopy(&int_val, arg, val_size);
596
memcpy(arg, &int_val, val_size);
598
599
case IOV_GVAL(IOV_HOSTREG):
621
622
int_val = 32; /* sdioh_sdmmc_rreg(si,
622
623
sd_ptr->offset); */
624
bcopy(&int_val, arg, sizeof(int_val));
625
memcpy(arg, &int_val, sizeof(int_val));
653
654
if (sdioh_cfg_read
654
655
(si, sd_ptr->func, sd_ptr->offset, &data)) {
655
bcmerror = BCME_SDIO_ERROR;
659
660
int_val = (int)data;
660
bcopy(&int_val, arg, sizeof(int_val));
661
memcpy(arg, &int_val, sizeof(int_val));
1011
1012
* This function takes a buffer or packet, and fixes everything up
1013
* end, a DMA-able packet is created.
1013
* so that in the end, a DMA-able packet is created.
1015
1015
* A buffer does not have an associated packet pointer,
1016
1016
* and may or may not be aligned.
1017
1017
* A packet may consist of a single packet, or a packet chain.
1018
* If it is a packet chain,
1019
* then all the packets in the chain must be properly aligned.
1020
* If the packet data is not
1021
* aligned, then there may only be one packet, and in this case,
1022
* it is copied to a new
1018
* If it is a packet chain, then all the packets in the chain
1019
* must be properly aligned.
1021
* If the packet data is not aligned, then there may only be
1022
* one packet, and in this case, it is copied to a new
1023
1023
* aligned packet.
1039
1039
if (pkt == NULL) {
1040
1040
sd_data(("%s: Creating new %s Packet, len=%d\n",
1041
1041
__func__, write ? "TX" : "RX", buflen_u));
1042
mypkt = pkt_buf_get_skb(sd->osh, buflen_u);
1042
mypkt = bcm_pkt_buf_get_skb(buflen_u);
1044
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
1044
sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
1045
1045
__func__, buflen_u));
1046
1046
return SDIOH_API_RC_FAIL;
1049
1049
/* For a write, copy the buffer data into the packet. */
1051
bcopy(buffer, mypkt->data, buflen_u);
1051
memcpy(mypkt->data, buffer, buflen_u);
1054
1054
sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt);
1056
1056
/* For a read, copy the packet data back to the buffer. */
1058
bcopy(mypkt->data, buffer, buflen_u);
1058
memcpy(buffer, mypkt->data, buflen_u);
1060
pkt_buf_free_skb(sd->osh, mypkt, write ? true : false);
1060
bcm_pkt_buf_free_skb(mypkt);
1061
1061
} else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) {
1062
1062
/* Case 2: We have a packet, but it is unaligned. */
1067
1067
sd_data(("%s: Creating aligned %s Packet, len=%d\n",
1068
1068
__func__, write ? "TX" : "RX", pkt->len));
1069
mypkt = pkt_buf_get_skb(sd->osh, pkt->len);
1069
mypkt = bcm_pkt_buf_get_skb(pkt->len);
1071
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
1071
sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
1072
1072
__func__, pkt->len));
1073
1073
return SDIOH_API_RC_FAIL;
1076
1076
/* For a write, copy the buffer data into the packet. */
1078
bcopy(pkt->data, mypkt->data, pkt->len);
1078
memcpy(mypkt->data, pkt->data, pkt->len);
1081
1081
sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt);
1083
1083
/* For a read, copy the packet data back to the buffer. */
1085
bcopy(mypkt->data, pkt->data, mypkt->len);
1085
memcpy(pkt->data, mypkt->data, mypkt->len);
1087
pkt_buf_free_skb(sd->osh, mypkt, write ? true : false);
1087
bcm_pkt_buf_free_skb(mypkt);
1088
1088
} else { /* case 3: We have a packet and
1089
1089
it is aligned. */
1090
1090
sd_data(("%s: Aligned %s Packet, direct DMA\n",