mmc.c (1ad6364eeb4f578e423081d1748e8a3fdf1ab01d) mmc.c (ab769f227f79bedae7840f99b6c0c4d66aafc78e)
1/*
2 * Copyright 2008, Freescale Semiconductor, Inc
3 * Andy Fleming
4 *
5 * Based vaguely on the Linux code
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */

--- 23 unchanged lines hidden (view full) ---

32
33int mmc_getwp(struct mmc *mmc)
34{
35 int wp;
36
37 wp = board_mmc_getwp(mmc);
38
39 if (wp < 0) {
1/*
2 * Copyright 2008, Freescale Semiconductor, Inc
3 * Andy Fleming
4 *
5 * Based vaguely on the Linux code
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */

--- 23 unchanged lines hidden (view full) ---

32
33int mmc_getwp(struct mmc *mmc)
34{
35 int wp;
36
37 wp = board_mmc_getwp(mmc);
38
39 if (wp < 0) {
40 if (mmc->getwp)
41 wp = mmc->getwp(mmc);
40 if (mmc->ops->getwp)
41 wp = mmc->ops->getwp(mmc);
42 else
43 wp = 0;
44 }
45
46 return wp;
47}
48
49int __board_mmc_getcd(struct mmc *mmc) {

--- 8 unchanged lines hidden (view full) ---

58 int ret;
59
60#ifdef CONFIG_MMC_TRACE
61 int i;
62 u8 *ptr;
63
64 printf("CMD_SEND:%d\n", cmd->cmdidx);
65 printf("\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg);
42 else
43 wp = 0;
44 }
45
46 return wp;
47}
48
49int __board_mmc_getcd(struct mmc *mmc) {

--- 8 unchanged lines hidden (view full) ---

58 int ret;
59
60#ifdef CONFIG_MMC_TRACE
61 int i;
62 u8 *ptr;
63
64 printf("CMD_SEND:%d\n", cmd->cmdidx);
65 printf("\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg);
66 ret = mmc->send_cmd(mmc, cmd, data);
66 ret = mmc->ops->send_cmd(mmc, cmd, data);
67 switch (cmd->resp_type) {
68 case MMC_RSP_NONE:
69 printf("\t\tMMC_RSP_NONE\n");
70 break;
71 case MMC_RSP_R1:
72 printf("\t\tMMC_RSP_R1,5,6,7 \t 0x%08X \n",
73 cmd->response[0]);
74 break;

--- 26 unchanged lines hidden (view full) ---

101 printf("\t\tMMC_RSP_R3,4\t\t 0x%08X \n",
102 cmd->response[0]);
103 break;
104 default:
105 printf("\t\tERROR MMC rsp not supported\n");
106 break;
107 }
108#else
67 switch (cmd->resp_type) {
68 case MMC_RSP_NONE:
69 printf("\t\tMMC_RSP_NONE\n");
70 break;
71 case MMC_RSP_R1:
72 printf("\t\tMMC_RSP_R1,5,6,7 \t 0x%08X \n",
73 cmd->response[0]);
74 break;

--- 26 unchanged lines hidden (view full) ---

101 printf("\t\tMMC_RSP_R3,4\t\t 0x%08X \n",
102 cmd->response[0]);
103 break;
104 default:
105 printf("\t\tERROR MMC rsp not supported\n");
106 break;
107 }
108#else
109 ret = mmc->send_cmd(mmc, cmd, data);
109 ret = mmc->ops->send_cmd(mmc, cmd, data);
110#endif
111 return ret;
112}
113
114int mmc_send_status(struct mmc *mmc, int timeout)
115{
116 struct mmc_cmd cmd;
117 int err, retries = 5;

--- 455 unchanged lines hidden (view full) ---

573
574int mmc_getcd(struct mmc *mmc)
575{
576 int cd;
577
578 cd = board_mmc_getcd(mmc);
579
580 if (cd < 0) {
110#endif
111 return ret;
112}
113
114int mmc_send_status(struct mmc *mmc, int timeout)
115{
116 struct mmc_cmd cmd;
117 int err, retries = 5;

--- 455 unchanged lines hidden (view full) ---

573
574int mmc_getcd(struct mmc *mmc)
575{
576 int cd;
577
578 cd = board_mmc_getcd(mmc);
579
580 if (cd < 0) {
581 if (mmc->getcd)
582 cd = mmc->getcd(mmc);
581 if (mmc->ops->getcd)
582 cd = mmc->ops->getcd(mmc);
583 else
584 cd = 1;
585 }
586
587 return cd;
588}
589
590static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)

--- 155 unchanged lines hidden (view full) ---

746 55,
747 60,
748 70,
749 80,
750};
751
752static void mmc_set_ios(struct mmc *mmc)
753{
583 else
584 cd = 1;
585 }
586
587 return cd;
588}
589
590static int sd_switch(struct mmc *mmc, int mode, int group, u8 value, u8 *resp)

--- 155 unchanged lines hidden (view full) ---

746 55,
747 60,
748 70,
749 80,
750};
751
752static void mmc_set_ios(struct mmc *mmc)
753{
754 mmc->set_ios(mmc);
754 if (mmc->ops->set_ios)
755 mmc->ops->set_ios(mmc);
755}
756
757void mmc_set_clock(struct mmc *mmc, uint clock)
758{
759 if (clock > mmc->f_max)
760 clock = mmc->f_max;
761
762 if (clock < mmc->f_min)

--- 439 unchanged lines hidden (view full) ---

1202 return &mmc->block_dev;
1203}
1204#endif
1205
1206int mmc_start_init(struct mmc *mmc)
1207{
1208 int err;
1209
756}
757
758void mmc_set_clock(struct mmc *mmc, uint clock)
759{
760 if (clock > mmc->f_max)
761 clock = mmc->f_max;
762
763 if (clock < mmc->f_min)

--- 439 unchanged lines hidden (view full) ---

1203 return &mmc->block_dev;
1204}
1205#endif
1206
1207int mmc_start_init(struct mmc *mmc)
1208{
1209 int err;
1210
1210 if (mmc_getcd(mmc) == 0) {
1211 /* we pretend there's no card when init is NULL */
1212 if (mmc_getcd(mmc) == 0 || mmc->ops->init == NULL) {
1211 mmc->has_init = 0;
1212#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
1213 printf("MMC: no card present\n");
1214#endif
1215 return NO_CARD_ERR;
1216 }
1217
1218 if (mmc->has_init)
1219 return 0;
1220
1213 mmc->has_init = 0;
1214#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
1215 printf("MMC: no card present\n");
1216#endif
1217 return NO_CARD_ERR;
1218 }
1219
1220 if (mmc->has_init)
1221 return 0;
1222
1221 err = mmc->init(mmc);
1223 /* made sure it's not NULL earlier */
1224 err = mmc->ops->init(mmc);
1222
1223 if (err)
1224 return err;
1225
1226 mmc_set_bus_width(mmc, 1);
1227 mmc_set_clock(mmc, 1);
1228
1229 /* Reset the Card */

--- 256 unchanged lines hidden ---
1225
1226 if (err)
1227 return err;
1228
1229 mmc_set_bus_width(mmc, 1);
1230 mmc_set_clock(mmc, 1);
1231
1232 /* Reset the Card */

--- 256 unchanged lines hidden ---