summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/hotswap.h2
-rw-r--r--firmware/export/sd.h2
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c19
-rw-r--r--firmware/target/arm/ata-sd-pp.c29
-rw-r--r--firmware/target/arm/s3c2440/sd-s3c2440.c27
-rw-r--r--firmware/target/arm/tcc780x/sd-tcc780x.c11
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c2
7 files changed, 42 insertions, 50 deletions
diff --git a/firmware/export/hotswap.h b/firmware/export/hotswap.h
index 455dee6bcc..643048976b 100644
--- a/firmware/export/hotswap.h
+++ b/firmware/export/hotswap.h
@@ -53,7 +53,6 @@ typedef struct
53#if (CONFIG_STORAGE & STORAGE_SD) 53#if (CONFIG_STORAGE & STORAGE_SD)
54 54
55#include "sd.h" 55#include "sd.h"
56#define card_detect card_detect_target
57#define card_get_info card_get_info_target 56#define card_get_info card_get_info_target
58tCardInfo *card_get_info_target(int card_no); 57tCardInfo *card_get_info_target(int card_no);
59void sd_parse_csd(tCardInfo *card); 58void sd_parse_csd(tCardInfo *card);
@@ -65,7 +64,6 @@ void sd_parse_csd(tCardInfo *card);
65#else /* STORAGE_MMC */ 64#else /* STORAGE_MMC */
66 65
67#include "ata_mmc.h" 66#include "ata_mmc.h"
68#define card_detect mmc_detect
69#define card_get_info mmc_card_info 67#define card_get_info mmc_card_info
70tCardInfo *mmc_card_info(int card_no); 68tCardInfo *mmc_card_info(int card_no);
71#define card_touched mmc_touched 69#define card_touched mmc_touched
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
index c12546562e..1c61364566 100644
--- a/firmware/export/sd.h
+++ b/firmware/export/sd.h
@@ -51,8 +51,6 @@ bool sd_present(IF_MV_NONVOID(int drive));
51void card_enable_monitoring_target(bool on); 51void card_enable_monitoring_target(bool on);
52#endif 52#endif
53 53
54bool card_detect_target(void);
55
56long sd_last_disk_activity(void); 54long sd_last_disk_activity(void);
57 55
58#ifdef CONFIG_STORAGE_MULTI 56#ifdef CONFIG_STORAGE_MULTI
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index fdb39f34c2..f13f2f868d 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -137,6 +137,16 @@ static inline void mci_delay(void)
137 } while (--i); 137 } while (--i);
138} 138}
139 139
140
141static inline bool card_detect_target(void)
142{
143#if defined(HAVE_MULTIDRIVE)
144 return !(GPIOA_PIN(2));
145#else
146 return false;
147#endif
148}
149
140#ifdef HAVE_HOTSWAP 150#ifdef HAVE_HOTSWAP
141static int sd1_oneshot_callback(struct timeout *tmo) 151static int sd1_oneshot_callback(struct timeout *tmo)
142{ 152{
@@ -872,15 +882,6 @@ tCardInfo *card_get_info_target(int card_no)
872 return &card_info[card_no]; 882 return &card_info[card_no];
873} 883}
874 884
875bool card_detect_target(void)
876{
877#if defined(HAVE_MULTIDRIVE)
878 return !(GPIOA_PIN(2));
879#else
880 return false;
881#endif
882}
883
884#ifdef HAVE_HOTSWAP 885#ifdef HAVE_HOTSWAP
885void card_enable_monitoring_target(bool on) 886void card_enable_monitoring_target(bool on)
886{ 887{
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c
index f2efd02e9d..fafc5f20d9 100644
--- a/firmware/target/arm/ata-sd-pp.c
+++ b/firmware/target/arm/ata-sd-pp.c
@@ -340,6 +340,21 @@ static int sd_wait_for_state(unsigned int state, int id)
340 } 340 }
341} 341}
342 342
343
344static inline bool card_detect_target(void)
345{
346#ifdef HAVE_HOTSWAP
347#ifdef SANSA_E200
348 return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */
349#elif defined SANSA_C200
350 return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */
351#endif
352#else
353 return false;
354#endif
355}
356
357
343static inline void copy_read_sectors_fast(unsigned char **buf) 358static inline void copy_read_sectors_fast(unsigned char **buf)
344{ 359{
345 /* Copy one chunk of 16 words using best method for start alignment */ 360 /* Copy one chunk of 16 words using best method for start alignment */
@@ -1278,20 +1293,6 @@ tCardInfo *card_get_info_target(int card_no)
1278{ 1293{
1279 return &card_info[card_no]; 1294 return &card_info[card_no];
1280} 1295}
1281
1282bool card_detect_target(void)
1283{
1284#ifdef HAVE_HOTSWAP
1285#ifdef SANSA_E200
1286 return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */
1287#elif defined SANSA_C200
1288 return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */
1289#endif
1290#else
1291 return false;
1292#endif
1293}
1294
1295#ifdef HAVE_HOTSWAP 1296#ifdef HAVE_HOTSWAP
1296static int sd1_oneshot_callback(struct timeout *tmo) 1297static int sd1_oneshot_callback(struct timeout *tmo)
1297{ 1298{
diff --git a/firmware/target/arm/s3c2440/sd-s3c2440.c b/firmware/target/arm/s3c2440/sd-s3c2440.c
index 6213cbd003..8aa53d8891 100644
--- a/firmware/target/arm/s3c2440/sd-s3c2440.c
+++ b/firmware/target/arm/s3c2440/sd-s3c2440.c
@@ -494,6 +494,17 @@ static int sd_init_card(const int card_no)
494 Generic functions 494 Generic functions
495 *****************************************************************************/ 495 *****************************************************************************/
496 496
497static inline bool card_detect_target(void)
498{
499 /* TODO - use interrupt on change? */
500#ifdef MINI2440
501 return (GPGDAT & SD_CD) == 0;
502#else
503#error Unsupported target
504#endif
505}
506
507
497/*****************************************************************************/ 508/*****************************************************************************/
498#ifdef HAVE_HOTSWAP 509#ifdef HAVE_HOTSWAP
499 510
@@ -512,16 +523,6 @@ static int sd1_oneshot_callback(struct timeout *tmo)
512 return 0; 523 return 0;
513} 524}
514 525
515bool card_detect_target(void)
516{
517 /* TODO - use interrupt on change? */
518#ifdef MINI2440
519 return (GPGDAT & SD_CD) == 0;
520#else
521#error Unsupported target
522#endif
523}
524
525void card_enable_monitoring_target(bool on) 526void card_enable_monitoring_target(bool on)
526{ 527{
527 if (on) 528 if (on)
@@ -570,12 +571,6 @@ bool sd_present(IF_MD_NONVOID(int card_no))
570/*****************************************************************************/ 571/*****************************************************************************/
571#else 572#else
572 573
573bool card_detect_target(void)
574{
575 /* not applicable */
576 return false;
577}
578
579bool sd_removable(IF_MD_NONVOID(int card_no)) 574bool sd_removable(IF_MD_NONVOID(int card_no))
580{ 575{
581#ifndef HAVE_MULTIDRIVE 576#ifndef HAVE_MULTIDRIVE
diff --git a/firmware/target/arm/tcc780x/sd-tcc780x.c b/firmware/target/arm/tcc780x/sd-tcc780x.c
index 222bb88a15..25876aa7ba 100644
--- a/firmware/target/arm/tcc780x/sd-tcc780x.c
+++ b/firmware/target/arm/tcc780x/sd-tcc780x.c
@@ -205,9 +205,13 @@ static void sd_card_mux(int card_no)
205 205
206#ifdef HAVE_HOTSWAP 206#ifdef HAVE_HOTSWAP
207 207
208bool card_detect_target(void) 208static inline bool card_detect_target(void)
209{ 209{
210#ifdef HAVE_HOTSWAP
210 return (GPIOB & (1<<26)) == 0; /* low active */ 211 return (GPIOB & (1<<26)) == 0; /* low active */
212#else
213 return false;
214#endif
211} 215}
212 216
213void card_enable_monitoring_target(bool on) 217void card_enable_monitoring_target(bool on)
@@ -261,11 +265,6 @@ bool sd_present(IF_MD_NONVOID(int card_no))
261 265
262#else 266#else
263 267
264bool card_detect_target(void)
265{
266 return false;
267}
268
269bool sd_removable(IF_MD_NONVOID(int card_no)) 268bool sd_removable(IF_MD_NONVOID(int card_no))
270{ 269{
271#ifndef HAVE_MULTIDRIVE 270#ifndef HAVE_MULTIDRIVE
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 544e0cf481..f3d67aec51 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -1200,7 +1200,7 @@ int sd_init(void)
1200 return -1; 1200 return -1;
1201} 1201}
1202 1202
1203bool card_detect_target(void) 1203static inline bool card_detect_target(void)
1204{ 1204{
1205 return (jz_sd_chkcard() == 1); 1205 return (jz_sd_chkcard() == 1);
1206} 1206}