mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Juergen Beisert <jbe@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/7] Add MCI card support to barebox
Date: Thu, 7 Oct 2010 17:37:14 +0200	[thread overview]
Message-ID: <20101007153713.GH28242@pengutronix.de> (raw)
In-Reply-To: <1286457858-29771-6-git-send-email-jbe@pengutronix.de>

Hi Jürgen,

On Thu, Oct 07, 2010 at 03:24:16PM +0200, Juergen Beisert wrote:
> This adds the basic framework to handle MCI cards in barebox.
> 
> Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
> ---
>  drivers/Kconfig        |    1 +
>  drivers/Makefile       |    1 +
>  drivers/mci/Kconfig    |   30 ++
>  drivers/mci/Makefile   |    1 +
>  drivers/mci/mci-core.c | 1308 ++++++++++++++++++++++++++++++++++++++++++++++++
>  include/mci.h          |  230 +++++++++
>  6 files changed, 1571 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/mci/Kconfig
>  create mode 100644 drivers/mci/Makefile
>  create mode 100644 drivers/mci/mci-core.c
>  create mode 100644 include/mci.h
>

This whole patch looks quite good.
Please add some linebreaks in mci-core.c. I don't want strict 80
character lines, but some lines are really long.

[snip]

> +static int mci_probe(struct device_d *mci_dev)
> +{
> +	struct mci *mci;
> +	int rc;
> +
> +	mci = xzalloc(sizeof(struct mci));
> +	mci_dev->priv = mci;
> +
> +#ifdef CONFIG_MCI_STARTUP
> +	/* if enabled, probe the attached card immediately */
> +	rc = mci_card_probe(mci_dev);
> +	if (rc == -ENODEV) {
> +		/*
> +		 * If it fails, add the 'probe' parameter to give the user
> +		 * a chance to insert a card and try again. Note: This may fail
> +		 * systems that rely on the MCI card for startup (for the
> +		 * persistant environment for example)
> +		 */
> +		rc = add_mci_parameter(mci_dev);
> +		if (rc != 0) {
> +			pr_err("Failed to add 'probe' parameter to the MCI device\n");
> +			goto on_error;
> +		}
> +	}
> +#endif
> +
> +#ifndef CONFIG_MCI_STARTUP

#else instead?

> +	/* add params on demand */
> +	rc = add_mci_parameter(mci_dev);
> +	if (rc != 0) {
> +		pr_err("Failed to add 'probe' parameter to the MCI device\n");
> +		goto on_error;
> +	}
> +#endif
> +
> +	return rc;
> +
> +on_error:
> +	free(mci);
> +	return rc;
> +}
> +

[snip]

> +
> +/** host information */
> +struct mci_platformdata {
> +	struct device_d *hw_dev;	/**< the host MCI hardware device */
> +	unsigned voltages;
> +	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* and FIXME */
> +	unsigned f_min;		/**< host interface lower limit */
> +	unsigned f_max;		/**< host interface upper limit */
> +	unsigned clock;		/**< Current clock used to talk to the card */
> +	unsigned bus_width;	/**< used data bus width to the card */
> +
> +	int (*init)(struct device_d*, struct device_d*);	/**< init the host interface */
> +	void (*set_ios)(struct device_d*, struct device_d*, unsigned, unsigned);	/**< change host interface settings */
> +	int (*send_cmd)(struct device_d*, struct mci_cmd*, struct mci_data*);	/**< handle a command */
> +};

I prefer this struct named mci_host, this seems to match better what it
actually is. For the convenience of drivers set init/set_ios/send_cmd
functions should be passed a pointer to the mci_host, not the device,
because that's what they actually registered. I already prepared a patch
for this, I'll send it in a seperate mail.

> +
> +/** MMC/SD and interface instance information */
> +struct mci {
> +	unsigned version;
> +	int high_capacity;	/**< != 0 when a high capacity card is connected (OCR -> OCR_HCS) */
> +	unsigned card_caps;	/**< Card's capabilities */
> +	unsigned ocr;		/**< card's "operation condition register" */
> +	unsigned scr[2];
> +	unsigned csd[4];	/**< card's "card specific data register" */
> +	unsigned cid[4];	/**< card's "card identification register" */
> +	unsigned short rca;	/* FIXME */
> +	unsigned tran_speed;	/**< not yet used */
> +	unsigned read_bl_len;	/**< currently used data block length for read accesses */
> +	unsigned write_bl_len;	/**< currently used data block length for write accesses */
> +	uint64_t capacity;	/**< Card's data capacity in bytes */
> +	int ready_for_use;	/** true if already probed */
> +};
> +
> +int mci_register(struct mci_platformdata*);
> +
> +#define GET_HOST_DATA(x) (x->priv)
> +#define GET_HOST_PDATA(x) (x->platform_data)
> +#define GET_MCI_DATA(x) (x->priv)
> +#define GET_MCI_PDATA(x) (x->platform_data)
> +
> +#endif /* _MCI_H_ */
> -- 
> 1.7.2.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2010-10-07 15:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07 13:24 [RFC] " Juergen Beisert
2010-10-07 13:24 ` [PATCH 1/7] x-functions do not return in case of failure Juergen Beisert
2010-10-07 13:24 ` [PATCH 2/7] Make the disk driver less noisy Juergen Beisert
2010-10-07 13:24 ` [PATCH 3/7] Don't use a sector buffer on stack Juergen Beisert
2010-10-07 13:24 ` [PATCH 4/7] Don't try to guess the size of a disk if its size value is already given Juergen Beisert
2010-10-07 13:24 ` [PATCH 5/7] Add MCI card support to barebox Juergen Beisert
2010-10-07 15:37   ` Sascha Hauer [this message]
2010-10-07 16:00     ` Juergen Beisert
2010-10-07 16:59       ` Sascha Hauer
2010-10-07 17:39         ` Juergen Beisert
2010-10-07 13:24 ` [PATCH 6/7] Add i.MX23 MCI card support Juergen Beisert
2010-10-07 13:24 ` [PATCH 7/7] Add S3C2440 " Juergen Beisert
2010-10-07 17:10   ` Sascha Hauer
2010-10-07 17:51     ` Juergen Beisert
2010-10-07 15:16 ` [RFC] Add MCI card support to barebox Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101007153713.GH28242@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jbe@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox