* [PATCH 2.6.35]: Add new device IDs and registers for MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) cards.
@ 2010-11-09 6:28 Jennifer Li (TP)
2010-11-09 15:38 ` Chris Ball
0 siblings, 1 reply; 2+ messages in thread
From: Jennifer Li (TP) @ 2010-11-09 6:28 UTC (permalink / raw)
To: linux-mmc
Cc: Shirley Her (SC), Hardys Lv(WH), Rich Lin (TP), Samuel Guan(WH),
Rezwanul_Kabir, Mario_Limonciello, Joseph_Yeh, Chris Van Hoof
[-- Attachment #1: Type: text/plain, Size: 6630 bytes --]
Hi,
This can make MMC/SD driver work on O2 chip.
Best regards,
Jennifer
--- /home/j/Desktop/kernel_source_1104/linux-2.6.35/drivers/mmc/host/sdhci-pci.c 2010-08-02 06:11:14.000000000 +0800
+++ /home/j/Desktop/SD_ADMAissue_8220_8320/20101020_sdhci_pci_c/sdhci-pci.c 2010-10-20 23:44:50.000000000 +0800
@@ -39,6 +39,26 @@
#define MAX_SLOTS 8
+#ifndef PCI_DEVICE_ID_O2_8120
+#define PCI_DEVICE_ID_O2_8120 0x8120
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8220
+#define PCI_DEVICE_ID_O2_8220 0x8220
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8320
+#define PCI_DEVICE_ID_O2_8320 0x8320
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8321
+#define PCI_DEVICE_ID_O2_8321 0x8321
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8221
+#define PCI_DEVICE_ID_O2_8221 0x8221
+#endif
+
struct sdhci_pci_chip;
struct sdhci_pci_slot;
@@ -112,6 +132,118 @@ static const struct sdhci_pci_fixes sdhc
SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
};
+static int o2_probe(struct sdhci_pci_chip *chip)
+{
+ int ret;
+ u8 scratch;
+
+ if ((chip->pdev->device == PCI_DEVICE_ID_O2_8220) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8320) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8321) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8221))
+ {
+ //set D3 to 0x7f
+ ret = pci_read_config_byte(chip->pdev, 0xD3, &scratch);
+ if (ret)
+ return ret;
+
+ scratch &= 0x7f;
+
+ ret = pci_write_config_byte(chip->pdev, 0xD3, scratch);
+ if (ret)
+ return ret;
+
+ // set EE to 08
+ ret = pci_read_config_byte(chip->pdev, 0xEE, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xEE, scratch);
+ if (ret)
+ return ret;
+
+ // set Ec to 0x20
+ ret = pci_read_config_byte(chip->pdev, 0xEC, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x20;
+
+ ret = pci_write_config_byte(chip->pdev, 0xEC, scratch);
+ if (ret)
+ return ret;
+
+ // set E0 to 0x01
+ ret = pci_read_config_byte(chip->pdev, 0xE0, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x01;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE0, scratch);
+ if (ret)
+ return ret;
+
+ // set E0 to 0x73
+ ret = pci_read_config_byte(chip->pdev, 0xE0, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x73;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE0, scratch);
+ if (ret)
+ return ret;
+
+ // set E2 to 0x39
+ ret = pci_read_config_byte(chip->pdev, 0xE2, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x39;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE2, scratch);
+ if (ret)
+ return ret;
+
+ // set E7 to 0x08
+ ret = pci_read_config_byte(chip->pdev, 0xE7, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE7, scratch);
+ if (ret)
+ return ret;
+
+ // set f1 to 0x08
+ ret = pci_read_config_byte(chip->pdev, 0xF1, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xF1, scratch);
+ if (ret)
+ return ret;
+
+ //set D3 to 80
+ ret = pci_read_config_byte(chip->pdev, 0xD3, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x80;
+
+ ret = pci_write_config_byte(chip->pdev, 0xD3, scratch);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
{
u8 scratch;
@@ -275,6 +407,11 @@ static int jmicron_resume(struct sdhci_p
return 0;
}
+static const struct sdhci_pci_fixes sdhci_o2 = {
+ .probe = o2_probe,
+// .quirks = SDHCI_QUICK_ADMA_TABLE_ENTRY,
+};
+
static const struct sdhci_pci_fixes sdhci_jmicron = {
.probe = jmicron_probe,
@@ -445,6 +582,46 @@ static const struct pci_device_id pci_id
.driver_data = (kernel_ulong_t)&sdhci_via,
},
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8120,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8220,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8320,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8221,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8321,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
{ /* Generic SD host controller */
PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
},
Unless otherwise stated, this e-mail message does not constitute a solicitation to buy or sell any products or services, or to participate in any particular trading strategy. This e-mail message and any attachments are intended solely for the use of the individual or entity to which it is addressed and may contain information that is confidential or legally privileged. If you are not the intended recipient, you are hereby notified that any dissemination, distribution, copying or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and permanently delete this message and any attachments. O2Micro International Ltd., and its subsidiaries and affiliates, are neither liable for the proper and complete transmission of the information contained in this communication, the accuracy of the information contained therein, nor for any delay in its receipt.
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 4644 bytes --]
--- /home/j/Desktop/kernel_source_1104/linux-2.6.35/drivers/mmc/host/sdhci-pci.c 2010-08-02 06:11:14.000000000 +0800
+++ /home/j/Desktop/SD_ADMAissue_8220_8320/20101020_sdhci_pci_c/sdhci-pci.c 2010-10-20 23:44:50.000000000 +0800
@@ -39,6 +39,26 @@
#define MAX_SLOTS 8
+#ifndef PCI_DEVICE_ID_O2_8120
+#define PCI_DEVICE_ID_O2_8120 0x8120
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8220
+#define PCI_DEVICE_ID_O2_8220 0x8220
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8320
+#define PCI_DEVICE_ID_O2_8320 0x8320
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8321
+#define PCI_DEVICE_ID_O2_8321 0x8321
+#endif
+
+#ifndef PCI_DEVICE_ID_O2_8221
+#define PCI_DEVICE_ID_O2_8221 0x8221
+#endif
+
struct sdhci_pci_chip;
struct sdhci_pci_slot;
@@ -112,6 +132,118 @@ static const struct sdhci_pci_fixes sdhc
SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
};
+static int o2_probe(struct sdhci_pci_chip *chip)
+{
+ int ret;
+ u8 scratch;
+
+ if ((chip->pdev->device == PCI_DEVICE_ID_O2_8220) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8320) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8321) ||
+ (chip->pdev->device == PCI_DEVICE_ID_O2_8221))
+ {
+ //set D3 to 0x7f
+ ret = pci_read_config_byte(chip->pdev, 0xD3, &scratch);
+ if (ret)
+ return ret;
+
+ scratch &= 0x7f;
+
+ ret = pci_write_config_byte(chip->pdev, 0xD3, scratch);
+ if (ret)
+ return ret;
+
+ // set EE to 08
+ ret = pci_read_config_byte(chip->pdev, 0xEE, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xEE, scratch);
+ if (ret)
+ return ret;
+
+ // set Ec to 0x20
+ ret = pci_read_config_byte(chip->pdev, 0xEC, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x20;
+
+ ret = pci_write_config_byte(chip->pdev, 0xEC, scratch);
+ if (ret)
+ return ret;
+
+ // set E0 to 0x01
+ ret = pci_read_config_byte(chip->pdev, 0xE0, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x01;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE0, scratch);
+ if (ret)
+ return ret;
+
+ // set E0 to 0x73
+ ret = pci_read_config_byte(chip->pdev, 0xE0, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x73;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE0, scratch);
+ if (ret)
+ return ret;
+
+ // set E2 to 0x39
+ ret = pci_read_config_byte(chip->pdev, 0xE2, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x39;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE2, scratch);
+ if (ret)
+ return ret;
+
+ // set E7 to 0x08
+ ret = pci_read_config_byte(chip->pdev, 0xE7, &scratch);
+ if (ret)
+ return ret;
+
+ scratch = 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xE7, scratch);
+ if (ret)
+ return ret;
+
+ // set f1 to 0x08
+ ret = pci_read_config_byte(chip->pdev, 0xF1, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x08;
+
+ ret = pci_write_config_byte(chip->pdev, 0xF1, scratch);
+ if (ret)
+ return ret;
+
+ //set D3 to 80
+ ret = pci_read_config_byte(chip->pdev, 0xD3, &scratch);
+ if (ret)
+ return ret;
+
+ scratch |= 0x80;
+
+ ret = pci_write_config_byte(chip->pdev, 0xD3, scratch);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
static int jmicron_pmos(struct sdhci_pci_chip *chip, int on)
{
u8 scratch;
@@ -275,6 +407,11 @@ static int jmicron_resume(struct sdhci_p
return 0;
}
+static const struct sdhci_pci_fixes sdhci_o2 = {
+ .probe = o2_probe,
+// .quirks = SDHCI_QUICK_ADMA_TABLE_ENTRY,
+};
+
static const struct sdhci_pci_fixes sdhci_jmicron = {
.probe = jmicron_probe,
@@ -445,6 +582,46 @@ static const struct pci_device_id pci_id
.driver_data = (kernel_ulong_t)&sdhci_via,
},
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8120,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8220,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8320,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8221,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
+ {
+ .vendor = PCI_VENDOR_ID_O2,
+ .device = PCI_DEVICE_ID_O2_8321,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .driver_data = (kernel_ulong_t)&sdhci_o2,
+ },
+
{ /* Generic SD host controller */
PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
},
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 2.6.35]: Add new device IDs and registers for MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) cards.
2010-11-09 6:28 [PATCH 2.6.35]: Add new device IDs and registers for MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) cards Jennifer Li (TP)
@ 2010-11-09 15:38 ` Chris Ball
0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2010-11-09 15:38 UTC (permalink / raw)
To: Jennifer Li (TP)
Cc: linux-mmc, Shirley Her (SC), Hardys Lv(WH), Rich Lin (TP),
Samuel Guan(WH), Rezwanul_Kabir, Mario_Limonciello, Joseph_Yeh,
Chris Van Hoof
Hi Jennifer,
On Tue, Nov 09, 2010 at 02:28:00PM +0800, Jennifer Li (TP) wrote:
> Hi,
>
> This can make MMC/SD driver work on O2 chip.
>
> Best regards,
> Jennifer
Thanks for the patch submission. There are some changes that need to
be made before this can be accepted into the kernel -- you can read
more about the patch guidelines here:
http://www.kernel.org/doc/Documentation/SubmittingPatches
http://www.kernel.org/doc/Documentation/CodingStyle
In particular:
* The patch needs a "Signed-off-by" line.
* Please submit a summary that explains how the patch works in general.
Your directory name mentions "SD_ADMAissue_8220_8320" -- could you
explain what that issue is, and how this patch fixes it? I guess
I'm particularly interested in why you have to make so many PCI
config writes, and what they achieve.
* It would be ideal if you could generate the patch using Git, and if it
could be based on 2.6.36 or newer instead of 2.6.35.
* In lines like this:
ret = pci_read_config_byte(chip->pdev, 0xD3, &scratch);
please use symbolic names -- the name of the register -- instead
of numbers like 0xD3. For example, from via-sdmmc.c:
#define VIA_CRDR_PCI_WORK_MODE 0x40
#define VIA_CRDR_PCI_DBG_MODE 0x41
...
pci_write_config_byte(pcidev, VIA_CRDR_PCI_WORK_MODE, 0);
pci_write_config_byte(pcidev, VIA_CRDR_PCI_DBG_MODE, 0);
* Instead of comments like "// set E0 to 0x73", please describe what's
actually happening to the hardware. For example, from the jmicron
code:
/*
* Turn PMOS on [bit 0], set over current detection to 2.4 V
* [bit 1:2] and enable over current debouncing [bit 6].
*/
(Linux uses "/* */" comments rather than "//" comments.)
* Commented-out code shouldn't be submitted:
+// .quirks = SDHCI_QUICK_ADMA_TABLE_ENTRY,
* The PCI device ID symbols should only be added to include/linux/pci_ids.h.
There's already a space for other O2 devices in there.
* I think it's generally okay not to check the return value on
pci_write_config_byte().
Please fix these and resubmit the patch. Thanks!
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-09 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-09 6:28 [PATCH 2.6.35]: Add new device IDs and registers for MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) cards Jennifer Li (TP)
2010-11-09 15:38 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).