···1212 * published by the Free Software Foundation.1313 */1414#include <linux/kernel.h>1515+#include <linux/export.h>1516#include <linux/list.h>1617#include <linux/errno.h>1718#include <linux/err.h>···22212322#include <asm/mach-types.h>24232525-#include <plat/cpu.h>2626-#include <plat/usb.h>2727-#include <plat/clock.h>2828-#include <plat/sram.h>2929-#include <plat/clkdev_omap.h>3030-3124#include <mach/hardware.h>32252626+#include "soc.h"3327#include "iomap.h"3428#include "clock.h"3529#include "opp.h"3030+#include "sram.h"36313732__u32 arm_idlect1_mask;3833struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;3434+3535+static LIST_HEAD(clocks);3636+static DEFINE_MUTEX(clocks_mutex);3737+static DEFINE_SPINLOCK(clockfw_lock);39384039/*4140 * Omap1 specific clock functions···608607}609608610609#endif610610+611611+612612+int clk_enable(struct clk *clk)613613+{614614+ unsigned long flags;615615+ int ret;616616+617617+ if (clk == NULL || IS_ERR(clk))618618+ return -EINVAL;619619+620620+ spin_lock_irqsave(&clockfw_lock, flags);621621+ ret = omap1_clk_enable(clk);622622+ spin_unlock_irqrestore(&clockfw_lock, flags);623623+624624+ return ret;625625+}626626+EXPORT_SYMBOL(clk_enable);627627+628628+void clk_disable(struct clk *clk)629629+{630630+ unsigned long flags;631631+632632+ if (clk == NULL || IS_ERR(clk))633633+ return;634634+635635+ spin_lock_irqsave(&clockfw_lock, flags);636636+ if (clk->usecount == 0) {637637+ pr_err("Trying disable clock %s with 0 usecount\n",638638+ clk->name);639639+ WARN_ON(1);640640+ goto out;641641+ }642642+643643+ omap1_clk_disable(clk);644644+645645+out:646646+ spin_unlock_irqrestore(&clockfw_lock, flags);647647+}648648+EXPORT_SYMBOL(clk_disable);649649+650650+unsigned long clk_get_rate(struct clk *clk)651651+{652652+ unsigned long flags;653653+ unsigned long ret;654654+655655+ if (clk == NULL || IS_ERR(clk))656656+ return 0;657657+658658+ spin_lock_irqsave(&clockfw_lock, flags);659659+ ret = clk->rate;660660+ spin_unlock_irqrestore(&clockfw_lock, flags);661661+662662+ return ret;663663+}664664+EXPORT_SYMBOL(clk_get_rate);665665+666666+/*667667+ * Optional clock functions defined in include/linux/clk.h668668+ */669669+670670+long clk_round_rate(struct clk *clk, unsigned long rate)671671+{672672+ unsigned long flags;673673+ long ret;674674+675675+ if (clk == NULL || IS_ERR(clk))676676+ return 0;677677+678678+ spin_lock_irqsave(&clockfw_lock, flags);679679+ ret = omap1_clk_round_rate(clk, rate);680680+ spin_unlock_irqrestore(&clockfw_lock, flags);681681+682682+ return ret;683683+}684684+EXPORT_SYMBOL(clk_round_rate);685685+686686+int clk_set_rate(struct clk *clk, unsigned long rate)687687+{688688+ unsigned long flags;689689+ int ret = -EINVAL;690690+691691+ if (clk == NULL || IS_ERR(clk))692692+ return ret;693693+694694+ spin_lock_irqsave(&clockfw_lock, flags);695695+ ret = omap1_clk_set_rate(clk, rate);696696+ if (ret == 0)697697+ propagate_rate(clk);698698+ spin_unlock_irqrestore(&clockfw_lock, flags);699699+700700+ return ret;701701+}702702+EXPORT_SYMBOL(clk_set_rate);703703+704704+int clk_set_parent(struct clk *clk, struct clk *parent)705705+{706706+ WARN_ONCE(1, "clk_set_parent() not implemented for OMAP1\n");707707+708708+ return -EINVAL;709709+}710710+EXPORT_SYMBOL(clk_set_parent);711711+712712+struct clk *clk_get_parent(struct clk *clk)713713+{714714+ return clk->parent;715715+}716716+EXPORT_SYMBOL(clk_get_parent);717717+718718+/*719719+ * OMAP specific clock functions shared between omap1 and omap2720720+ */721721+722722+int __initdata mpurate;723723+724724+/*725725+ * By default we use the rate set by the bootloader.726726+ * You can override this with mpurate= cmdline option.727727+ */728728+static int __init omap_clk_setup(char *str)729729+{730730+ get_option(&str, &mpurate);731731+732732+ if (!mpurate)733733+ return 1;734734+735735+ if (mpurate < 1000)736736+ mpurate *= 1000000;737737+738738+ return 1;739739+}740740+__setup("mpurate=", omap_clk_setup);741741+742742+/* Used for clocks that always have same value as the parent clock */743743+unsigned long followparent_recalc(struct clk *clk)744744+{745745+ return clk->parent->rate;746746+}747747+748748+/*749749+ * Used for clocks that have the same value as the parent clock,750750+ * divided by some factor751751+ */752752+unsigned long omap_fixed_divisor_recalc(struct clk *clk)753753+{754754+ WARN_ON(!clk->fixed_div);755755+756756+ return clk->parent->rate / clk->fixed_div;757757+}758758+759759+void clk_reparent(struct clk *child, struct clk *parent)760760+{761761+ list_del_init(&child->sibling);762762+ if (parent)763763+ list_add(&child->sibling, &parent->children);764764+ child->parent = parent;765765+766766+ /* now do the debugfs renaming to reattach the child767767+ to the proper parent */768768+}769769+770770+/* Propagate rate to children */771771+void propagate_rate(struct clk *tclk)772772+{773773+ struct clk *clkp;774774+775775+ list_for_each_entry(clkp, &tclk->children, sibling) {776776+ if (clkp->recalc)777777+ clkp->rate = clkp->recalc(clkp);778778+ propagate_rate(clkp);779779+ }780780+}781781+782782+static LIST_HEAD(root_clks);783783+784784+/**785785+ * recalculate_root_clocks - recalculate and propagate all root clocks786786+ *787787+ * Recalculates all root clocks (clocks with no parent), which if the788788+ * clock's .recalc is set correctly, should also propagate their rates.789789+ * Called at init.790790+ */791791+void recalculate_root_clocks(void)792792+{793793+ struct clk *clkp;794794+795795+ list_for_each_entry(clkp, &root_clks, sibling) {796796+ if (clkp->recalc)797797+ clkp->rate = clkp->recalc(clkp);798798+ propagate_rate(clkp);799799+ }800800+}801801+802802+/**803803+ * clk_preinit - initialize any fields in the struct clk before clk init804804+ * @clk: struct clk * to initialize805805+ *806806+ * Initialize any struct clk fields needed before normal clk initialization807807+ * can run. No return value.808808+ */809809+void clk_preinit(struct clk *clk)810810+{811811+ INIT_LIST_HEAD(&clk->children);812812+}813813+814814+int clk_register(struct clk *clk)815815+{816816+ if (clk == NULL || IS_ERR(clk))817817+ return -EINVAL;818818+819819+ /*820820+ * trap out already registered clocks821821+ */822822+ if (clk->node.next || clk->node.prev)823823+ return 0;824824+825825+ mutex_lock(&clocks_mutex);826826+ if (clk->parent)827827+ list_add(&clk->sibling, &clk->parent->children);828828+ else829829+ list_add(&clk->sibling, &root_clks);830830+831831+ list_add(&clk->node, &clocks);832832+ if (clk->init)833833+ clk->init(clk);834834+ mutex_unlock(&clocks_mutex);835835+836836+ return 0;837837+}838838+EXPORT_SYMBOL(clk_register);839839+840840+void clk_unregister(struct clk *clk)841841+{842842+ if (clk == NULL || IS_ERR(clk))843843+ return;844844+845845+ mutex_lock(&clocks_mutex);846846+ list_del(&clk->sibling);847847+ list_del(&clk->node);848848+ mutex_unlock(&clocks_mutex);849849+}850850+EXPORT_SYMBOL(clk_unregister);851851+852852+void clk_enable_init_clocks(void)853853+{854854+ struct clk *clkp;855855+856856+ list_for_each_entry(clkp, &clocks, node)857857+ if (clkp->flags & ENABLE_ON_INIT)858858+ clk_enable(clkp);859859+}860860+861861+/**862862+ * omap_clk_get_by_name - locate OMAP struct clk by its name863863+ * @name: name of the struct clk to locate864864+ *865865+ * Locate an OMAP struct clk by its name. Assumes that struct clk866866+ * names are unique. Returns NULL if not found or a pointer to the867867+ * struct clk if found.868868+ */869869+struct clk *omap_clk_get_by_name(const char *name)870870+{871871+ struct clk *c;872872+ struct clk *ret = NULL;873873+874874+ mutex_lock(&clocks_mutex);875875+876876+ list_for_each_entry(c, &clocks, node) {877877+ if (!strcmp(c->name, name)) {878878+ ret = c;879879+ break;880880+ }881881+ }882882+883883+ mutex_unlock(&clocks_mutex);884884+885885+ return ret;886886+}887887+888888+int omap_clk_enable_autoidle_all(void)889889+{890890+ struct clk *c;891891+ unsigned long flags;892892+893893+ spin_lock_irqsave(&clockfw_lock, flags);894894+895895+ list_for_each_entry(c, &clocks, node)896896+ if (c->ops->allow_idle)897897+ c->ops->allow_idle(c);898898+899899+ spin_unlock_irqrestore(&clockfw_lock, flags);900900+901901+ return 0;902902+}903903+904904+int omap_clk_disable_autoidle_all(void)905905+{906906+ struct clk *c;907907+ unsigned long flags;908908+909909+ spin_lock_irqsave(&clockfw_lock, flags);910910+911911+ list_for_each_entry(c, &clocks, node)912912+ if (c->ops->deny_idle)913913+ c->ops->deny_idle(c);914914+915915+ spin_unlock_irqrestore(&clockfw_lock, flags);916916+917917+ return 0;918918+}919919+920920+/*921921+ * Low level helpers922922+ */923923+static int clkll_enable_null(struct clk *clk)924924+{925925+ return 0;926926+}927927+928928+static void clkll_disable_null(struct clk *clk)929929+{930930+}931931+932932+const struct clkops clkops_null = {933933+ .enable = clkll_enable_null,934934+ .disable = clkll_disable_null,935935+};936936+937937+/*938938+ * Dummy clock939939+ *940940+ * Used for clock aliases that are needed on some OMAPs, but not others941941+ */942942+struct clk dummy_ck = {943943+ .name = "dummy",944944+ .ops = &clkops_null,945945+};946946+947947+/*948948+ *949949+ */950950+951951+#ifdef CONFIG_OMAP_RESET_CLOCKS952952+/*953953+ * Disable any unused clocks left on by the bootloader954954+ */955955+static int __init clk_disable_unused(void)956956+{957957+ struct clk *ck;958958+ unsigned long flags;959959+960960+ pr_info("clock: disabling unused clocks to save power\n");961961+962962+ spin_lock_irqsave(&clockfw_lock, flags);963963+ list_for_each_entry(ck, &clocks, node) {964964+ if (ck->ops == &clkops_null)965965+ continue;966966+967967+ if (ck->usecount > 0 || !ck->enable_reg)968968+ continue;969969+970970+ omap1_clk_disable_unused(ck);971971+ }972972+ spin_unlock_irqrestore(&clockfw_lock, flags);973973+974974+ return 0;975975+}976976+late_initcall(clk_disable_unused);977977+late_initcall(omap_clk_enable_autoidle_all);978978+#endif979979+980980+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)981981+/*982982+ * debugfs support to trace clock tree hierarchy and attributes983983+ */984984+985985+#include <linux/debugfs.h>986986+#include <linux/seq_file.h>987987+988988+static struct dentry *clk_debugfs_root;989989+990990+static int clk_dbg_show_summary(struct seq_file *s, void *unused)991991+{992992+ struct clk *c;993993+ struct clk *pa;994994+995995+ mutex_lock(&clocks_mutex);996996+ seq_printf(s, "%-30s %-30s %-10s %s\n",997997+ "clock-name", "parent-name", "rate", "use-count");998998+999999+ list_for_each_entry(c, &clocks, node) {10001000+ pa = c->parent;10011001+ seq_printf(s, "%-30s %-30s %-10lu %d\n",10021002+ c->name, pa ? pa->name : "none", c->rate,10031003+ c->usecount);10041004+ }10051005+ mutex_unlock(&clocks_mutex);10061006+10071007+ return 0;10081008+}10091009+10101010+static int clk_dbg_open(struct inode *inode, struct file *file)10111011+{10121012+ return single_open(file, clk_dbg_show_summary, inode->i_private);10131013+}10141014+10151015+static const struct file_operations debug_clock_fops = {10161016+ .open = clk_dbg_open,10171017+ .read = seq_read,10181018+ .llseek = seq_lseek,10191019+ .release = single_release,10201020+};10211021+10221022+static int clk_debugfs_register_one(struct clk *c)10231023+{10241024+ int err;10251025+ struct dentry *d;10261026+ struct clk *pa = c->parent;10271027+10281028+ d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);10291029+ if (!d)10301030+ return -ENOMEM;10311031+ c->dent = d;10321032+10331033+ d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);10341034+ if (!d) {10351035+ err = -ENOMEM;10361036+ goto err_out;10371037+ }10381038+ d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);10391039+ if (!d) {10401040+ err = -ENOMEM;10411041+ goto err_out;10421042+ }10431043+ d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);10441044+ if (!d) {10451045+ err = -ENOMEM;10461046+ goto err_out;10471047+ }10481048+ return 0;10491049+10501050+err_out:10511051+ debugfs_remove_recursive(c->dent);10521052+ return err;10531053+}10541054+10551055+static int clk_debugfs_register(struct clk *c)10561056+{10571057+ int err;10581058+ struct clk *pa = c->parent;10591059+10601060+ if (pa && !pa->dent) {10611061+ err = clk_debugfs_register(pa);10621062+ if (err)10631063+ return err;10641064+ }10651065+10661066+ if (!c->dent) {10671067+ err = clk_debugfs_register_one(c);10681068+ if (err)10691069+ return err;10701070+ }10711071+ return 0;10721072+}10731073+10741074+static int __init clk_debugfs_init(void)10751075+{10761076+ struct clk *c;10771077+ struct dentry *d;10781078+ int err;10791079+10801080+ d = debugfs_create_dir("clock", NULL);10811081+ if (!d)10821082+ return -ENOMEM;10831083+ clk_debugfs_root = d;10841084+10851085+ list_for_each_entry(c, &clocks, node) {10861086+ err = clk_debugfs_register(c);10871087+ if (err)10881088+ goto err_out;10891089+ }10901090+10911091+ d = debugfs_create_file("summary", S_IRUGO,10921092+ d, NULL, &debug_clock_fops);10931093+ if (!d)10941094+ return -ENOMEM;10951095+10961096+ return 0;10971097+err_out:10981098+ debugfs_remove_recursive(clk_debugfs_root);10991099+ return err;11001100+}11011101+late_initcall(clk_debugfs_init);11021102+11031103+#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
+177-1
arch/arm/mach-omap1/clock.h
···1414#define __ARCH_ARM_MACH_OMAP1_CLOCK_H15151616#include <linux/clk.h>1717+#include <linux/list.h>17181818-#include <plat/clock.h>1919+#include <linux/clkdev.h>2020+2121+struct module;2222+struct clk;2323+2424+struct omap_clk {2525+ u16 cpu;2626+ struct clk_lookup lk;2727+};2828+2929+#define CLK(dev, con, ck, cp) \3030+ { \3131+ .cpu = cp, \3232+ .lk = { \3333+ .dev_id = dev, \3434+ .con_id = con, \3535+ .clk = ck, \3636+ }, \3737+ }3838+3939+/* Platform flags for the clkdev-OMAP integration code */4040+#define CK_310 (1 << 0)4141+#define CK_7XX (1 << 1) /* 7xx, 850 */4242+#define CK_1510 (1 << 2)4343+#define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */4444+#define CK_1710 (1 << 4) /* 1710 extra for rate selection */4545+4646+4747+/* Temporary, needed during the common clock framework conversion */4848+#define __clk_get_name(clk) (clk->name)4949+#define __clk_get_parent(clk) (clk->parent)5050+#define __clk_get_rate(clk) (clk->rate)5151+5252+/**5353+ * struct clkops - some clock function pointers5454+ * @enable: fn ptr that enables the current clock in hardware5555+ * @disable: fn ptr that enables the current clock in hardware5656+ * @find_idlest: function returning the IDLEST register for the clock's IP blk5757+ * @find_companion: function returning the "companion" clk reg for the clock5858+ * @allow_idle: fn ptr that enables autoidle for the current clock in hardware5959+ * @deny_idle: fn ptr that disables autoidle for the current clock in hardware6060+ *6161+ * A "companion" clk is an accompanying clock to the one being queried6262+ * that must be enabled for the IP module connected to the clock to6363+ * become accessible by the hardware. Neither @find_idlest nor6464+ * @find_companion should be needed; that information is IP6565+ * block-specific; the hwmod code has been created to handle this, but6666+ * until hwmod data is ready and drivers have been converted to use PM6767+ * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and6868+ * @find_companion must, unfortunately, remain.6969+ */7070+struct clkops {7171+ int (*enable)(struct clk *);7272+ void (*disable)(struct clk *);7373+ void (*find_idlest)(struct clk *, void __iomem **,7474+ u8 *, u8 *);7575+ void (*find_companion)(struct clk *, void __iomem **,7676+ u8 *);7777+ void (*allow_idle)(struct clk *);7878+ void (*deny_idle)(struct clk *);7979+};8080+8181+/*8282+ * struct clk.flags possibilities8383+ *8484+ * XXX document the rest of the clock flags here8585+ *8686+ * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL8787+ * bits share the same register. This flag allows the8888+ * omap4_dpllmx*() code to determine which GATE_CTRL bit field8989+ * should be used. This is a temporary solution - a better approach9090+ * would be to associate clock type-specific data with the clock,9191+ * similar to the struct dpll_data approach.9292+ */9393+#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */9494+#define CLOCK_IDLE_CONTROL (1 << 1)9595+#define CLOCK_NO_IDLE_PARENT (1 << 2)9696+#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */9797+#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */9898+#define CLOCK_CLKOUTX2 (1 << 5)9999+100100+/**101101+ * struct clk - OMAP struct clk102102+ * @node: list_head connecting this clock into the full clock list103103+ * @ops: struct clkops * for this clock104104+ * @name: the name of the clock in the hardware (used in hwmod data and debug)105105+ * @parent: pointer to this clock's parent struct clk106106+ * @children: list_head connecting to the child clks' @sibling list_heads107107+ * @sibling: list_head connecting this clk to its parent clk's @children108108+ * @rate: current clock rate109109+ * @enable_reg: register to write to enable the clock (see @enable_bit)110110+ * @recalc: fn ptr that returns the clock's current rate111111+ * @set_rate: fn ptr that can change the clock's current rate112112+ * @round_rate: fn ptr that can round the clock's current rate113113+ * @init: fn ptr to do clock-specific initialization114114+ * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)115115+ * @usecount: number of users that have requested this clock to be enabled116116+ * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div117117+ * @flags: see "struct clk.flags possibilities" above118118+ * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)119119+ * @src_offset: bitshift for source selection bitfield (OMAP1 only)120120+ *121121+ * XXX @rate_offset, @src_offset should probably be removed and OMAP1122122+ * clock code converted to use clksel.123123+ *124124+ * XXX @usecount is poorly named. It should be "enable_count" or125125+ * something similar. "users" in the description refers to kernel126126+ * code (core code or drivers) that have called clk_enable() and not127127+ * yet called clk_disable(); the usecount of parent clocks is also128128+ * incremented by the clock code when clk_enable() is called on child129129+ * clocks and decremented by the clock code when clk_disable() is130130+ * called on child clocks.131131+ *132132+ * XXX @clkdm, @usecount, @children, @sibling should be marked for133133+ * internal use only.134134+ *135135+ * @children and @sibling are used to optimize parent-to-child clock136136+ * tree traversals. (child-to-parent traversals use @parent.)137137+ *138138+ * XXX The notion of the clock's current rate probably needs to be139139+ * separated from the clock's target rate.140140+ */141141+struct clk {142142+ struct list_head node;143143+ const struct clkops *ops;144144+ const char *name;145145+ struct clk *parent;146146+ struct list_head children;147147+ struct list_head sibling; /* node for children */148148+ unsigned long rate;149149+ void __iomem *enable_reg;150150+ unsigned long (*recalc)(struct clk *);151151+ int (*set_rate)(struct clk *, unsigned long);152152+ long (*round_rate)(struct clk *, unsigned long);153153+ void (*init)(struct clk *);154154+ u8 enable_bit;155155+ s8 usecount;156156+ u8 fixed_div;157157+ u8 flags;158158+ u8 rate_offset;159159+ u8 src_offset;160160+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)161161+ struct dentry *dent; /* For visible tree hierarchy */162162+#endif163163+};164164+165165+struct clk_functions {166166+ int (*clk_enable)(struct clk *clk);167167+ void (*clk_disable)(struct clk *clk);168168+ long (*clk_round_rate)(struct clk *clk, unsigned long rate);169169+ int (*clk_set_rate)(struct clk *clk, unsigned long rate);170170+ int (*clk_set_parent)(struct clk *clk, struct clk *parent);171171+ void (*clk_allow_idle)(struct clk *clk);172172+ void (*clk_deny_idle)(struct clk *clk);173173+ void (*clk_disable_unused)(struct clk *clk);174174+};175175+176176+extern int mpurate;177177+178178+extern int clk_init(struct clk_functions *custom_clocks);179179+extern void clk_preinit(struct clk *clk);180180+extern int clk_register(struct clk *clk);181181+extern void clk_reparent(struct clk *child, struct clk *parent);182182+extern void clk_unregister(struct clk *clk);183183+extern void propagate_rate(struct clk *clk);184184+extern void recalculate_root_clocks(void);185185+extern unsigned long followparent_recalc(struct clk *clk);186186+extern void clk_enable_init_clocks(void);187187+unsigned long omap_fixed_divisor_recalc(struct clk *clk);188188+extern struct clk *omap_clk_get_by_name(const char *name);189189+extern int omap_clk_enable_autoidle_all(void);190190+extern int omap_clk_disable_autoidle_all(void);191191+192192+extern const struct clkops clkops_null;193193+194194+extern struct clk dummy_ck;1919520196int omap1_clk_init(void);21197void omap1_clk_late_init(void);
+2-14
arch/arm/mach-omap1/clock_data.c
···22222323#include <asm/mach-types.h> /* for machine_is_* */24242525-#include <plat/clock.h>2626-#include <plat/cpu.h>2727-#include <plat/clkdev_omap.h>2828-#include <plat/sram.h> /* for omap_sram_reprogram_clock() */2525+#include "soc.h"29263027#include <mach/hardware.h>3128#include <mach/usb.h> /* for OTG_BASE */32293330#include "iomap.h"3431#include "clock.h"3232+#include "sram.h"35333634/* Some ARM_IDLECT1 bit shifts - used in struct arm_idlect1_clk */3735#define IDL_CLKOUT_ARM_SHIFT 12···763765 * init764766 */765767766766-static struct clk_functions omap1_clk_functions = {767767- .clk_enable = omap1_clk_enable,768768- .clk_disable = omap1_clk_disable,769769- .clk_round_rate = omap1_clk_round_rate,770770- .clk_set_rate = omap1_clk_set_rate,771771- .clk_disable_unused = omap1_clk_disable_unused,772772-};773773-774768static void __init omap1_show_rates(void)775769{776770 pr_notice("Clocking rate (xtal/DPLL1/MPU): %ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n",···792802 omap_writew(reg, SOFT_REQ_REG);793803 if (!cpu_is_omap15xx())794804 omap_writew(0, SOFT_REQ_REG2);795795-796796- clk_init(&omap1_clk_functions);797805798806 /* By default all idlect1 clocks are allowed to idle */799807 arm_idlect1_mask = ~0;
···11+/*22+ * OMAP1 DMA channel definitions33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License as published by66+ * the Free Software Foundation; either version 2 of the License, or77+ * (at your option) any later version.88+ *99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1717+ */1818+1919+#ifndef __OMAP1_DMA_CHANNEL_H2020+#define __OMAP1_DMA_CHANNEL_H2121+2222+/* DMA channels for omap1 */2323+#define OMAP_DMA_NO_DEVICE 02424+#define OMAP_DMA_MCSI1_TX 12525+#define OMAP_DMA_MCSI1_RX 22626+#define OMAP_DMA_I2C_RX 32727+#define OMAP_DMA_I2C_TX 42828+#define OMAP_DMA_EXT_NDMA_REQ 52929+#define OMAP_DMA_EXT_NDMA_REQ2 63030+#define OMAP_DMA_UWIRE_TX 73131+#define OMAP_DMA_MCBSP1_TX 83232+#define OMAP_DMA_MCBSP1_RX 93333+#define OMAP_DMA_MCBSP3_TX 103434+#define OMAP_DMA_MCBSP3_RX 113535+#define OMAP_DMA_UART1_TX 123636+#define OMAP_DMA_UART1_RX 133737+#define OMAP_DMA_UART2_TX 143838+#define OMAP_DMA_UART2_RX 153939+#define OMAP_DMA_MCBSP2_TX 164040+#define OMAP_DMA_MCBSP2_RX 174141+#define OMAP_DMA_UART3_TX 184242+#define OMAP_DMA_UART3_RX 194343+#define OMAP_DMA_CAMERA_IF_RX 204444+#define OMAP_DMA_MMC_TX 214545+#define OMAP_DMA_MMC_RX 224646+#define OMAP_DMA_NAND 234747+#define OMAP_DMA_IRQ_LCD_LINE 244848+#define OMAP_DMA_MEMORY_STICK 254949+#define OMAP_DMA_USB_W2FC_RX0 265050+#define OMAP_DMA_USB_W2FC_RX1 275151+#define OMAP_DMA_USB_W2FC_RX2 285252+#define OMAP_DMA_USB_W2FC_TX0 295353+#define OMAP_DMA_USB_W2FC_TX1 305454+#define OMAP_DMA_USB_W2FC_TX2 315555+5656+/* These are only for 1610 */5757+#define OMAP_DMA_CRYPTO_DES_IN 325858+#define OMAP_DMA_SPI_TX 335959+#define OMAP_DMA_SPI_RX 346060+#define OMAP_DMA_CRYPTO_HASH 356161+#define OMAP_DMA_CCP_ATTN 366262+#define OMAP_DMA_CCP_FIFO_NOT_EMPTY 376363+#define OMAP_DMA_CMT_APE_TX_CHAN_0 386464+#define OMAP_DMA_CMT_APE_RV_CHAN_0 396565+#define OMAP_DMA_CMT_APE_TX_CHAN_1 406666+#define OMAP_DMA_CMT_APE_RV_CHAN_1 416767+#define OMAP_DMA_CMT_APE_TX_CHAN_2 426868+#define OMAP_DMA_CMT_APE_RV_CHAN_2 436969+#define OMAP_DMA_CMT_APE_TX_CHAN_3 447070+#define OMAP_DMA_CMT_APE_RV_CHAN_3 457171+#define OMAP_DMA_CMT_APE_TX_CHAN_4 467272+#define OMAP_DMA_CMT_APE_RV_CHAN_4 477373+#define OMAP_DMA_CMT_APE_TX_CHAN_5 487474+#define OMAP_DMA_CMT_APE_RV_CHAN_5 497575+#define OMAP_DMA_CMT_APE_TX_CHAN_6 507676+#define OMAP_DMA_CMT_APE_RV_CHAN_6 517777+#define OMAP_DMA_CMT_APE_TX_CHAN_7 527878+#define OMAP_DMA_CMT_APE_RV_CHAN_7 537979+#define OMAP_DMA_MMC2_TX 548080+#define OMAP_DMA_MMC2_RX 558181+#define OMAP_DMA_CRYPTO_DES_OUT 568282+8383+#endif /* __OMAP1_DMA_CHANNEL_H */
···3939#include <asm/sizes.h>4040#ifndef __ASSEMBLER__4141#include <asm/types.h>4242-#include <plat/cpu.h>4242+#include <mach/soc.h>43434444/*4545 * NOTE: Please use ioremap + __raw_read/write where possible instead of these···5151extern void omap_writew(u16 v, u32 pa);5252extern void omap_writel(u32 v, u32 pa);53535454-#include <plat/tc.h>5454+#include <mach/tc.h>55555656/* Almost all documentation for chip and board memory maps assumes5757 * BM is clear. Most devel boards have a switch to control booting···72727373#endif /* ifndef __ASSEMBLER__ */74747575-#include <plat/serial.h>7575+#define OMAP1_IO_OFFSET 0x01000000 /* Virtual IO = 0xfefb0000 */7676+#define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET)7777+7878+#include <mach/serial.h>76797780/*7881 * ---------------------------------------------------------------------------
+1-1
arch/arm/mach-omap1/include/mach/memory.h
···1919 * because of the strncmp().2020 */2121#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)2222-#include <plat/cpu.h>2222+#include <mach/soc.h>23232424/*2525 * OMAP-1510 Local Bus address offset
···11+/*22+ * Copyright (C) 2009 Texas Instruments33+ * Added OMAP4 support- Santosh Shilimkar <santosh.shilimkar@ti.com>44+ *55+ * This program is distributed in the hope that it will be useful,66+ * but WITHOUT ANY WARRANTY; without even the implied warranty of77+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the88+ * GNU General Public License for more details.99+ */1010+1111+#ifndef __ASM_ARCH_SERIAL_H1212+#define __ASM_ARCH_SERIAL_H1313+1414+#include <linux/init.h>1515+1616+/*1717+ * Memory entry used for the DEBUG_LL UART configuration, relative to1818+ * start of RAM. See also uncompress.h and debug-macro.S.1919+ *2020+ * Note that using a memory location for storing the UART configuration2121+ * has at least two limitations:2222+ *2323+ * 1. Kernel uncompress code cannot overlap OMAP_UART_INFO as the2424+ * uncompress code could then partially overwrite itself2525+ * 2. We assume printascii is called at least once before paging_init,2626+ * and addruart has a chance to read OMAP_UART_INFO2727+ */2828+#define OMAP_UART_INFO_OFS 0x3ffc2929+3030+/* OMAP1 serial ports */3131+#define OMAP1_UART1_BASE 0xfffb00003232+#define OMAP1_UART2_BASE 0xfffb08003333+#define OMAP1_UART3_BASE 0xfffb98003434+3535+#define OMAP_PORT_SHIFT 23636+#define OMAP7XX_PORT_SHIFT 03737+3838+#define OMAP1510_BASE_BAUD (12000000/16)3939+#define OMAP16XX_BASE_BAUD (48000000/16)4040+4141+/*4242+ * DEBUG_LL port encoding stored into the UART1 scratchpad register by4343+ * decomp_setup in uncompress.h4444+ */4545+#define OMAP1UART1 114646+#define OMAP1UART2 124747+#define OMAP1UART3 134848+4949+#ifndef __ASSEMBLER__5050+extern void omap_serial_init(void);5151+#endif5252+5353+#endif
+229
arch/arm/mach-omap1/include/mach/soc.h
···11+/*22+ * OMAP cpu type detection33+ *44+ * Copyright (C) 2004, 2008 Nokia Corporation55+ *66+ * Copyright (C) 2009-11 Texas Instruments.77+ *88+ * Written by Tony Lindgren <tony.lindgren@nokia.com>99+ *1010+ * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>1111+ *1212+ * This program is free software; you can redistribute it and/or modify1313+ * it under the terms of the GNU General Public License as published by1414+ * the Free Software Foundation; either version 2 of the License, or1515+ * (at your option) any later version.1616+ *1717+ * This program is distributed in the hope that it will be useful,1818+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1919+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2020+ * GNU General Public License for more details.2121+ *2222+ * You should have received a copy of the GNU General Public License2323+ * along with this program; if not, write to the Free Software2424+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2525+ *2626+ */2727+2828+#ifndef __ASM_ARCH_OMAP_CPU_H2929+#define __ASM_ARCH_OMAP_CPU_H3030+3131+#ifndef __ASSEMBLY__3232+3333+#include <linux/bitops.h>3434+3535+/*3636+ * Test if multicore OMAP support is needed3737+ */3838+#undef MULTI_OMAP13939+#undef OMAP_NAME4040+4141+#ifdef CONFIG_ARCH_OMAP7304242+# ifdef OMAP_NAME4343+# undef MULTI_OMAP14444+# define MULTI_OMAP14545+# else4646+# define OMAP_NAME omap7304747+# endif4848+#endif4949+#ifdef CONFIG_ARCH_OMAP8505050+# ifdef OMAP_NAME5151+# undef MULTI_OMAP15252+# define MULTI_OMAP15353+# else5454+# define OMAP_NAME omap8505555+# endif5656+#endif5757+#ifdef CONFIG_ARCH_OMAP15XX5858+# ifdef OMAP_NAME5959+# undef MULTI_OMAP16060+# define MULTI_OMAP16161+# else6262+# define OMAP_NAME omap15106363+# endif6464+#endif6565+#ifdef CONFIG_ARCH_OMAP16XX6666+# ifdef OMAP_NAME6767+# undef MULTI_OMAP16868+# define MULTI_OMAP16969+# else7070+# define OMAP_NAME omap16xx7171+# endif7272+#endif7373+7474+/*7575+ * omap_rev bits:7676+ * CPU id bits (0730, 1510, 1710, 2422...) [31:16]7777+ * CPU revision (See _REV_ defined in cpu.h) [15:08]7878+ * CPU class bits (15xx, 16xx, 24xx, 34xx...) [07:00]7979+ */8080+unsigned int omap_rev(void);8181+8282+/*8383+ * Get the CPU revision for OMAP devices8484+ */8585+#define GET_OMAP_REVISION() ((omap_rev() >> 8) & 0xff)8686+8787+/*8888+ * Macros to group OMAP into cpu classes.8989+ * These can be used in most places.9090+ * cpu_is_omap7xx(): True for OMAP730, OMAP8509191+ * cpu_is_omap15xx(): True for OMAP1510, OMAP5910 and OMAP3109292+ * cpu_is_omap16xx(): True for OMAP1610, OMAP5912 and OMAP17109393+ */9494+#define GET_OMAP_CLASS (omap_rev() & 0xff)9595+9696+#define IS_OMAP_CLASS(class, id) \9797+static inline int is_omap ##class (void) \9898+{ \9999+ return (GET_OMAP_CLASS == (id)) ? 1 : 0; \100100+}101101+102102+#define GET_OMAP_SUBCLASS ((omap_rev() >> 20) & 0x0fff)103103+104104+#define IS_OMAP_SUBCLASS(subclass, id) \105105+static inline int is_omap ##subclass (void) \106106+{ \107107+ return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \108108+}109109+110110+IS_OMAP_CLASS(7xx, 0x07)111111+IS_OMAP_CLASS(15xx, 0x15)112112+IS_OMAP_CLASS(16xx, 0x16)113113+114114+#define cpu_is_omap7xx() 0115115+#define cpu_is_omap15xx() 0116116+#define cpu_is_omap16xx() 0117117+118118+#if defined(MULTI_OMAP1)119119+# if defined(CONFIG_ARCH_OMAP730)120120+# undef cpu_is_omap7xx121121+# define cpu_is_omap7xx() is_omap7xx()122122+# endif123123+# if defined(CONFIG_ARCH_OMAP850)124124+# undef cpu_is_omap7xx125125+# define cpu_is_omap7xx() is_omap7xx()126126+# endif127127+# if defined(CONFIG_ARCH_OMAP15XX)128128+# undef cpu_is_omap15xx129129+# define cpu_is_omap15xx() is_omap15xx()130130+# endif131131+# if defined(CONFIG_ARCH_OMAP16XX)132132+# undef cpu_is_omap16xx133133+# define cpu_is_omap16xx() is_omap16xx()134134+# endif135135+#else136136+# if defined(CONFIG_ARCH_OMAP730)137137+# undef cpu_is_omap7xx138138+# define cpu_is_omap7xx() 1139139+# endif140140+# if defined(CONFIG_ARCH_OMAP850)141141+# undef cpu_is_omap7xx142142+# define cpu_is_omap7xx() 1143143+# endif144144+# if defined(CONFIG_ARCH_OMAP15XX)145145+# undef cpu_is_omap15xx146146+# define cpu_is_omap15xx() 1147147+# endif148148+# if defined(CONFIG_ARCH_OMAP16XX)149149+# undef cpu_is_omap16xx150150+# define cpu_is_omap16xx() 1151151+# endif152152+#endif153153+154154+/*155155+ * Macros to detect individual cpu types.156156+ * These are only rarely needed.157157+ * cpu_is_omap310(): True for OMAP310158158+ * cpu_is_omap1510(): True for OMAP1510159159+ * cpu_is_omap1610(): True for OMAP1610160160+ * cpu_is_omap1611(): True for OMAP1611161161+ * cpu_is_omap5912(): True for OMAP5912162162+ * cpu_is_omap1621(): True for OMAP1621163163+ * cpu_is_omap1710(): True for OMAP1710164164+ */165165+#define GET_OMAP_TYPE ((omap_rev() >> 16) & 0xffff)166166+167167+#define IS_OMAP_TYPE(type, id) \168168+static inline int is_omap ##type (void) \169169+{ \170170+ return (GET_OMAP_TYPE == (id)) ? 1 : 0; \171171+}172172+173173+IS_OMAP_TYPE(310, 0x0310)174174+IS_OMAP_TYPE(1510, 0x1510)175175+IS_OMAP_TYPE(1610, 0x1610)176176+IS_OMAP_TYPE(1611, 0x1611)177177+IS_OMAP_TYPE(5912, 0x1611)178178+IS_OMAP_TYPE(1621, 0x1621)179179+IS_OMAP_TYPE(1710, 0x1710)180180+181181+#define cpu_is_omap310() 0182182+#define cpu_is_omap1510() 0183183+#define cpu_is_omap1610() 0184184+#define cpu_is_omap5912() 0185185+#define cpu_is_omap1611() 0186186+#define cpu_is_omap1621() 0187187+#define cpu_is_omap1710() 0188188+189189+/* These are needed to compile common code */190190+#ifdef CONFIG_ARCH_OMAP1191191+#define cpu_is_omap242x() 0192192+#define cpu_is_omap2430() 0193193+#define cpu_is_omap243x() 0194194+#define cpu_is_omap24xx() 0195195+#define cpu_is_omap34xx() 0196196+#define cpu_is_omap44xx() 0197197+#define soc_is_omap54xx() 0198198+#define soc_is_am33xx() 0199199+#define cpu_class_is_omap1() 1200200+#define cpu_class_is_omap2() 0201201+#endif202202+203203+/*204204+ * Whether we have MULTI_OMAP1 or not, we still need to distinguish205205+ * between 310 vs. 1510 and 1611B/5912 vs. 1710.206206+ */207207+208208+#if defined(CONFIG_ARCH_OMAP15XX)209209+# undef cpu_is_omap310210210+# undef cpu_is_omap1510211211+# define cpu_is_omap310() is_omap310()212212+# define cpu_is_omap1510() is_omap1510()213213+#endif214214+215215+#if defined(CONFIG_ARCH_OMAP16XX)216216+# undef cpu_is_omap1610217217+# undef cpu_is_omap1611218218+# undef cpu_is_omap5912219219+# undef cpu_is_omap1621220220+# undef cpu_is_omap1710221221+# define cpu_is_omap1610() is_omap1610()222222+# define cpu_is_omap1611() is_omap1611()223223+# define cpu_is_omap5912() is_omap5912()224224+# define cpu_is_omap1621() is_omap1621()225225+# define cpu_is_omap1710() is_omap1710()226226+#endif227227+228228+#endif /* __ASSEMBLY__ */229229+#endif
+119-2
arch/arm/mach-omap1/include/mach/uncompress.h
···11/*22- * arch/arm/mach-omap1/include/mach/uncompress.h22+ * arch/arm/plat-omap/include/mach/uncompress.h33+ *44+ * Serial port stubs for kernel decompress status messages55+ *66+ * Initially based on:77+ * linux-2.4.15-rmk1-dsplinux1.6/arch/arm/plat-omap/include/mach1510/uncompress.h88+ * Copyright (C) 2000 RidgeRun, Inc.99+ * Author: Greg Lonnon <glonnon@ridgerun.com>1010+ *1111+ * Rewritten by:1212+ * Author: <source@mvista.com>1313+ * 2004 (c) MontaVista Software, Inc.1414+ *1515+ * This file is licensed under the terms of the GNU General Public License1616+ * version 2. This program is licensed "as is" without any warranty of any1717+ * kind, whether express or implied.318 */41955-#include <plat/uncompress.h>2020+#include <linux/types.h>2121+#include <linux/serial_reg.h>2222+2323+#include <asm/memory.h>2424+#include <asm/mach-types.h>2525+2626+#include "serial.h"2727+2828+#define MDR1_MODE_MASK 0x072929+3030+volatile u8 *uart_base;3131+int uart_shift;3232+3333+/*3434+ * Store the DEBUG_LL uart number into memory.3535+ * See also debug-macro.S, and serial.c for related code.3636+ */3737+static void set_omap_uart_info(unsigned char port)3838+{3939+ /*4040+ * Get address of some.bss variable and round it down4141+ * a la CONFIG_AUTO_ZRELADDR.4242+ */4343+ u32 ram_start = (u32)&uart_shift & 0xf8000000;4444+ u32 *uart_info = (u32 *)(ram_start + OMAP_UART_INFO_OFS);4545+ *uart_info = port;4646+}4747+4848+static void putc(int c)4949+{5050+ if (!uart_base)5151+ return;5252+5353+ /* Check for UART 16x mode */5454+ if ((uart_base[UART_OMAP_MDR1 << uart_shift] & MDR1_MODE_MASK) != 0)5555+ return;5656+5757+ while (!(uart_base[UART_LSR << uart_shift] & UART_LSR_THRE))5858+ barrier();5959+ uart_base[UART_TX << uart_shift] = c;6060+}6161+6262+static inline void flush(void)6363+{6464+}6565+6666+/*6767+ * Macros to configure UART1 and debug UART6868+ */6969+#define _DEBUG_LL_ENTRY(mach, dbg_uart, dbg_shft, dbg_id) \7070+ if (machine_is_##mach()) { \7171+ uart_base = (volatile u8 *)(dbg_uart); \7272+ uart_shift = (dbg_shft); \7373+ port = (dbg_id); \7474+ set_omap_uart_info(port); \7575+ break; \7676+ }7777+7878+#define DEBUG_LL_OMAP7XX(p, mach) \7979+ _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP7XX_PORT_SHIFT, \8080+ OMAP1UART##p)8181+8282+#define DEBUG_LL_OMAP1(p, mach) \8383+ _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP_PORT_SHIFT, \8484+ OMAP1UART##p)8585+8686+static inline void arch_decomp_setup(void)8787+{8888+ int port = 0;8989+9090+ /*9191+ * Initialize the port based on the machine ID from the bootloader.9292+ * Note that we're using macros here instead of switch statement9393+ * as machine_is functions are optimized out for the boards that9494+ * are not selected.9595+ */9696+ do {9797+ /* omap7xx/8xx based boards using UART1 with shift 0 */9898+ DEBUG_LL_OMAP7XX(1, herald);9999+ DEBUG_LL_OMAP7XX(1, omap_perseus2);100100+101101+ /* omap15xx/16xx based boards using UART1 */102102+ DEBUG_LL_OMAP1(1, ams_delta);103103+ DEBUG_LL_OMAP1(1, nokia770);104104+ DEBUG_LL_OMAP1(1, omap_h2);105105+ DEBUG_LL_OMAP1(1, omap_h3);106106+ DEBUG_LL_OMAP1(1, omap_innovator);107107+ DEBUG_LL_OMAP1(1, omap_osk);108108+ DEBUG_LL_OMAP1(1, omap_palmte);109109+ DEBUG_LL_OMAP1(1, omap_palmz71);110110+111111+ /* omap15xx/16xx based boards using UART2 */112112+ DEBUG_LL_OMAP1(2, omap_palmtt);113113+114114+ /* omap15xx/16xx based boards using UART3 */115115+ DEBUG_LL_OMAP1(3, sx1);116116+ } while (0);117117+}118118+119119+/*120120+ * nothing to do121121+ */122122+#define arch_decomp_wdog()
···1010 * published by the Free Software Foundation.1111 */12121313-#include <plat/clkdev_omap.h>1313+#include "clock.h"1414#include "opp.h"15151616/*-------------------------------------------------------------------------
···11+/*22+ * We can move mach/soc.h here once the drivers are fixed33+ */44+#include <mach/soc.h>
+76
arch/arm/mach-omap1/sram-init.c
···11+/*22+ * OMAP SRAM detection and management33+ *44+ * Copyright (C) 2005 Nokia Corporation55+ * Written by Tony Lindgren <tony@atomide.com>66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License version 2 as99+ * published by the Free Software Foundation.1010+ */1111+1212+#include <linux/module.h>1313+#include <linux/kernel.h>1414+#include <linux/init.h>1515+#include <linux/io.h>1616+1717+#include <asm/fncpy.h>1818+#include <asm/tlb.h>1919+#include <asm/cacheflush.h>2020+2121+#include <asm/mach/map.h>2222+2323+#include "soc.h"2424+#include "sram.h"2525+2626+#define OMAP1_SRAM_PA 0x200000002727+#define SRAM_BOOTLOADER_SZ 0x802828+2929+/*3030+ * The amount of SRAM depends on the core type.3131+ * Note that we cannot try to test for SRAM here because writes3232+ * to secure SRAM will hang the system. Also the SRAM is not3333+ * yet mapped at this point.3434+ */3535+static void __init omap_detect_and_map_sram(void)3636+{3737+ unsigned long omap_sram_skip = SRAM_BOOTLOADER_SZ;3838+ unsigned long omap_sram_start = OMAP1_SRAM_PA;3939+ unsigned long omap_sram_size;4040+4141+ if (cpu_is_omap7xx())4242+ omap_sram_size = 0x32000; /* 200K */4343+ else if (cpu_is_omap15xx())4444+ omap_sram_size = 0x30000; /* 192K */4545+ else if (cpu_is_omap1610() || cpu_is_omap1611() ||4646+ cpu_is_omap1621() || cpu_is_omap1710())4747+ omap_sram_size = 0x4000; /* 16K */4848+ else {4949+ pr_err("Could not detect SRAM size\n");5050+ omap_sram_size = 0x4000;5151+ }5252+5353+ omap_map_sram(omap_sram_start, omap_sram_size,5454+ omap_sram_skip, 1);5555+}5656+5757+static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);5858+5959+void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)6060+{6161+ BUG_ON(!_omap_sram_reprogram_clock);6262+ /* On 730, bit 13 must always be 1 */6363+ if (cpu_is_omap7xx())6464+ ckctl |= 0x2000;6565+ _omap_sram_reprogram_clock(dpllctl, ckctl);6666+}6767+6868+int __init omap_sram_init(void)6969+{7070+ omap_detect_and_map_sram();7171+ _omap_sram_reprogram_clock =7272+ omap_sram_push(omap1_sram_reprogram_clock,7373+ omap1_sram_reprogram_clock_sz);7474+7575+ return 0;7676+}
+7
arch/arm/mach-omap1/sram.h
···11+#include <plat/sram.h>22+33+extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl);44+55+/* Do not use these */66+extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl);77+extern unsigned long omap1_sram_reprogram_clock_sz;
···1515#undef DEBUG16161717#include <linux/kernel.h>1818+#include <linux/export.h>1819#include <linux/list.h>1920#include <linux/errno.h>2021#include <linux/err.h>···26252726#include <asm/cpu.h>28272929-#include <plat/clock.h>3028#include <plat/prcm.h>31293230#include <trace/events/power.h>···4646 * afterwards.4747 */4848static bool clkdm_control = true;4949+5050+static LIST_HEAD(clocks);5151+static DEFINE_MUTEX(clocks_mutex);5252+static DEFINE_SPINLOCK(clockfw_lock);49535054/*5155 * OMAP2+ specific clock functions···516512517513/* Common data */518514519519-struct clk_functions omap2_clk_functions = {520520- .clk_enable = omap2_clk_enable,521521- .clk_disable = omap2_clk_disable,522522- .clk_round_rate = omap2_clk_round_rate,523523- .clk_set_rate = omap2_clk_set_rate,524524- .clk_set_parent = omap2_clk_set_parent,525525- .clk_disable_unused = omap2_clk_disable_unused,515515+int clk_enable(struct clk *clk)516516+{517517+ unsigned long flags;518518+ int ret;519519+520520+ if (clk == NULL || IS_ERR(clk))521521+ return -EINVAL;522522+523523+ spin_lock_irqsave(&clockfw_lock, flags);524524+ ret = omap2_clk_enable(clk);525525+ spin_unlock_irqrestore(&clockfw_lock, flags);526526+527527+ return ret;528528+}529529+EXPORT_SYMBOL(clk_enable);530530+531531+void clk_disable(struct clk *clk)532532+{533533+ unsigned long flags;534534+535535+ if (clk == NULL || IS_ERR(clk))536536+ return;537537+538538+ spin_lock_irqsave(&clockfw_lock, flags);539539+ if (clk->usecount == 0) {540540+ pr_err("Trying disable clock %s with 0 usecount\n",541541+ clk->name);542542+ WARN_ON(1);543543+ goto out;544544+ }545545+546546+ omap2_clk_disable(clk);547547+548548+out:549549+ spin_unlock_irqrestore(&clockfw_lock, flags);550550+}551551+EXPORT_SYMBOL(clk_disable);552552+553553+unsigned long clk_get_rate(struct clk *clk)554554+{555555+ unsigned long flags;556556+ unsigned long ret;557557+558558+ if (clk == NULL || IS_ERR(clk))559559+ return 0;560560+561561+ spin_lock_irqsave(&clockfw_lock, flags);562562+ ret = clk->rate;563563+ spin_unlock_irqrestore(&clockfw_lock, flags);564564+565565+ return ret;566566+}567567+EXPORT_SYMBOL(clk_get_rate);568568+569569+/*570570+ * Optional clock functions defined in include/linux/clk.h571571+ */572572+573573+long clk_round_rate(struct clk *clk, unsigned long rate)574574+{575575+ unsigned long flags;576576+ long ret;577577+578578+ if (clk == NULL || IS_ERR(clk))579579+ return 0;580580+581581+ spin_lock_irqsave(&clockfw_lock, flags);582582+ ret = omap2_clk_round_rate(clk, rate);583583+ spin_unlock_irqrestore(&clockfw_lock, flags);584584+585585+ return ret;586586+}587587+EXPORT_SYMBOL(clk_round_rate);588588+589589+int clk_set_rate(struct clk *clk, unsigned long rate)590590+{591591+ unsigned long flags;592592+ int ret = -EINVAL;593593+594594+ if (clk == NULL || IS_ERR(clk))595595+ return ret;596596+597597+ spin_lock_irqsave(&clockfw_lock, flags);598598+ ret = omap2_clk_set_rate(clk, rate);599599+ if (ret == 0)600600+ propagate_rate(clk);601601+ spin_unlock_irqrestore(&clockfw_lock, flags);602602+603603+ return ret;604604+}605605+EXPORT_SYMBOL(clk_set_rate);606606+607607+int clk_set_parent(struct clk *clk, struct clk *parent)608608+{609609+ unsigned long flags;610610+ int ret = -EINVAL;611611+612612+ if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))613613+ return ret;614614+615615+ spin_lock_irqsave(&clockfw_lock, flags);616616+ if (clk->usecount == 0) {617617+ ret = omap2_clk_set_parent(clk, parent);618618+ if (ret == 0)619619+ propagate_rate(clk);620620+ } else {621621+ ret = -EBUSY;622622+ }623623+ spin_unlock_irqrestore(&clockfw_lock, flags);624624+625625+ return ret;626626+}627627+EXPORT_SYMBOL(clk_set_parent);628628+629629+struct clk *clk_get_parent(struct clk *clk)630630+{631631+ return clk->parent;632632+}633633+EXPORT_SYMBOL(clk_get_parent);634634+635635+/*636636+ * OMAP specific clock functions shared between omap1 and omap2637637+ */638638+639639+int __initdata mpurate;640640+641641+/*642642+ * By default we use the rate set by the bootloader.643643+ * You can override this with mpurate= cmdline option.644644+ */645645+static int __init omap_clk_setup(char *str)646646+{647647+ get_option(&str, &mpurate);648648+649649+ if (!mpurate)650650+ return 1;651651+652652+ if (mpurate < 1000)653653+ mpurate *= 1000000;654654+655655+ return 1;656656+}657657+__setup("mpurate=", omap_clk_setup);658658+659659+/* Used for clocks that always have same value as the parent clock */660660+unsigned long followparent_recalc(struct clk *clk)661661+{662662+ return clk->parent->rate;663663+}664664+665665+/*666666+ * Used for clocks that have the same value as the parent clock,667667+ * divided by some factor668668+ */669669+unsigned long omap_fixed_divisor_recalc(struct clk *clk)670670+{671671+ WARN_ON(!clk->fixed_div);672672+673673+ return clk->parent->rate / clk->fixed_div;674674+}675675+676676+void clk_reparent(struct clk *child, struct clk *parent)677677+{678678+ list_del_init(&child->sibling);679679+ if (parent)680680+ list_add(&child->sibling, &parent->children);681681+ child->parent = parent;682682+683683+ /* now do the debugfs renaming to reattach the child684684+ to the proper parent */685685+}686686+687687+/* Propagate rate to children */688688+void propagate_rate(struct clk *tclk)689689+{690690+ struct clk *clkp;691691+692692+ list_for_each_entry(clkp, &tclk->children, sibling) {693693+ if (clkp->recalc)694694+ clkp->rate = clkp->recalc(clkp);695695+ propagate_rate(clkp);696696+ }697697+}698698+699699+static LIST_HEAD(root_clks);700700+701701+/**702702+ * recalculate_root_clocks - recalculate and propagate all root clocks703703+ *704704+ * Recalculates all root clocks (clocks with no parent), which if the705705+ * clock's .recalc is set correctly, should also propagate their rates.706706+ * Called at init.707707+ */708708+void recalculate_root_clocks(void)709709+{710710+ struct clk *clkp;711711+712712+ list_for_each_entry(clkp, &root_clks, sibling) {713713+ if (clkp->recalc)714714+ clkp->rate = clkp->recalc(clkp);715715+ propagate_rate(clkp);716716+ }717717+}718718+719719+/**720720+ * clk_preinit - initialize any fields in the struct clk before clk init721721+ * @clk: struct clk * to initialize722722+ *723723+ * Initialize any struct clk fields needed before normal clk initialization724724+ * can run. No return value.725725+ */726726+void clk_preinit(struct clk *clk)727727+{728728+ INIT_LIST_HEAD(&clk->children);729729+}730730+731731+int clk_register(struct clk *clk)732732+{733733+ if (clk == NULL || IS_ERR(clk))734734+ return -EINVAL;735735+736736+ /*737737+ * trap out already registered clocks738738+ */739739+ if (clk->node.next || clk->node.prev)740740+ return 0;741741+742742+ mutex_lock(&clocks_mutex);743743+ if (clk->parent)744744+ list_add(&clk->sibling, &clk->parent->children);745745+ else746746+ list_add(&clk->sibling, &root_clks);747747+748748+ list_add(&clk->node, &clocks);749749+ if (clk->init)750750+ clk->init(clk);751751+ mutex_unlock(&clocks_mutex);752752+753753+ return 0;754754+}755755+EXPORT_SYMBOL(clk_register);756756+757757+void clk_unregister(struct clk *clk)758758+{759759+ if (clk == NULL || IS_ERR(clk))760760+ return;761761+762762+ mutex_lock(&clocks_mutex);763763+ list_del(&clk->sibling);764764+ list_del(&clk->node);765765+ mutex_unlock(&clocks_mutex);766766+}767767+EXPORT_SYMBOL(clk_unregister);768768+769769+void clk_enable_init_clocks(void)770770+{771771+ struct clk *clkp;772772+773773+ list_for_each_entry(clkp, &clocks, node)774774+ if (clkp->flags & ENABLE_ON_INIT)775775+ clk_enable(clkp);776776+}777777+778778+/**779779+ * omap_clk_get_by_name - locate OMAP struct clk by its name780780+ * @name: name of the struct clk to locate781781+ *782782+ * Locate an OMAP struct clk by its name. Assumes that struct clk783783+ * names are unique. Returns NULL if not found or a pointer to the784784+ * struct clk if found.785785+ */786786+struct clk *omap_clk_get_by_name(const char *name)787787+{788788+ struct clk *c;789789+ struct clk *ret = NULL;790790+791791+ mutex_lock(&clocks_mutex);792792+793793+ list_for_each_entry(c, &clocks, node) {794794+ if (!strcmp(c->name, name)) {795795+ ret = c;796796+ break;797797+ }798798+ }799799+800800+ mutex_unlock(&clocks_mutex);801801+802802+ return ret;803803+}804804+805805+int omap_clk_enable_autoidle_all(void)806806+{807807+ struct clk *c;808808+ unsigned long flags;809809+810810+ spin_lock_irqsave(&clockfw_lock, flags);811811+812812+ list_for_each_entry(c, &clocks, node)813813+ if (c->ops->allow_idle)814814+ c->ops->allow_idle(c);815815+816816+ spin_unlock_irqrestore(&clockfw_lock, flags);817817+818818+ return 0;819819+}820820+821821+int omap_clk_disable_autoidle_all(void)822822+{823823+ struct clk *c;824824+ unsigned long flags;825825+826826+ spin_lock_irqsave(&clockfw_lock, flags);827827+828828+ list_for_each_entry(c, &clocks, node)829829+ if (c->ops->deny_idle)830830+ c->ops->deny_idle(c);831831+832832+ spin_unlock_irqrestore(&clockfw_lock, flags);833833+834834+ return 0;835835+}836836+837837+/*838838+ * Low level helpers839839+ */840840+static int clkll_enable_null(struct clk *clk)841841+{842842+ return 0;843843+}844844+845845+static void clkll_disable_null(struct clk *clk)846846+{847847+}848848+849849+const struct clkops clkops_null = {850850+ .enable = clkll_enable_null,851851+ .disable = clkll_disable_null,526852};853853+854854+/*855855+ * Dummy clock856856+ *857857+ * Used for clock aliases that are needed on some OMAPs, but not others858858+ */859859+struct clk dummy_ck = {860860+ .name = "dummy",861861+ .ops = &clkops_null,862862+};863863+864864+/*865865+ *866866+ */867867+868868+#ifdef CONFIG_OMAP_RESET_CLOCKS869869+/*870870+ * Disable any unused clocks left on by the bootloader871871+ */872872+static int __init clk_disable_unused(void)873873+{874874+ struct clk *ck;875875+ unsigned long flags;876876+877877+ pr_info("clock: disabling unused clocks to save power\n");878878+879879+ spin_lock_irqsave(&clockfw_lock, flags);880880+ list_for_each_entry(ck, &clocks, node) {881881+ if (ck->ops == &clkops_null)882882+ continue;883883+884884+ if (ck->usecount > 0 || !ck->enable_reg)885885+ continue;886886+887887+ omap2_clk_disable_unused(ck);888888+ }889889+ spin_unlock_irqrestore(&clockfw_lock, flags);890890+891891+ return 0;892892+}893893+late_initcall(clk_disable_unused);894894+late_initcall(omap_clk_enable_autoidle_all);895895+#endif896896+897897+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)898898+/*899899+ * debugfs support to trace clock tree hierarchy and attributes900900+ */901901+902902+#include <linux/debugfs.h>903903+#include <linux/seq_file.h>904904+905905+static struct dentry *clk_debugfs_root;906906+907907+static int clk_dbg_show_summary(struct seq_file *s, void *unused)908908+{909909+ struct clk *c;910910+ struct clk *pa;911911+912912+ mutex_lock(&clocks_mutex);913913+ seq_printf(s, "%-30s %-30s %-10s %s\n",914914+ "clock-name", "parent-name", "rate", "use-count");915915+916916+ list_for_each_entry(c, &clocks, node) {917917+ pa = c->parent;918918+ seq_printf(s, "%-30s %-30s %-10lu %d\n",919919+ c->name, pa ? pa->name : "none", c->rate,920920+ c->usecount);921921+ }922922+ mutex_unlock(&clocks_mutex);923923+924924+ return 0;925925+}926926+927927+static int clk_dbg_open(struct inode *inode, struct file *file)928928+{929929+ return single_open(file, clk_dbg_show_summary, inode->i_private);930930+}931931+932932+static const struct file_operations debug_clock_fops = {933933+ .open = clk_dbg_open,934934+ .read = seq_read,935935+ .llseek = seq_lseek,936936+ .release = single_release,937937+};938938+939939+static int clk_debugfs_register_one(struct clk *c)940940+{941941+ int err;942942+ struct dentry *d;943943+ struct clk *pa = c->parent;944944+945945+ d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);946946+ if (!d)947947+ return -ENOMEM;948948+ c->dent = d;949949+950950+ d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);951951+ if (!d) {952952+ err = -ENOMEM;953953+ goto err_out;954954+ }955955+ d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);956956+ if (!d) {957957+ err = -ENOMEM;958958+ goto err_out;959959+ }960960+ d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);961961+ if (!d) {962962+ err = -ENOMEM;963963+ goto err_out;964964+ }965965+ return 0;966966+967967+err_out:968968+ debugfs_remove_recursive(c->dent);969969+ return err;970970+}971971+972972+static int clk_debugfs_register(struct clk *c)973973+{974974+ int err;975975+ struct clk *pa = c->parent;976976+977977+ if (pa && !pa->dent) {978978+ err = clk_debugfs_register(pa);979979+ if (err)980980+ return err;981981+ }982982+983983+ if (!c->dent) {984984+ err = clk_debugfs_register_one(c);985985+ if (err)986986+ return err;987987+ }988988+ return 0;989989+}990990+991991+static int __init clk_debugfs_init(void)992992+{993993+ struct clk *c;994994+ struct dentry *d;995995+ int err;996996+997997+ d = debugfs_create_dir("clock", NULL);998998+ if (!d)999999+ return -ENOMEM;10001000+ clk_debugfs_root = d;10011001+10021002+ list_for_each_entry(c, &clocks, node) {10031003+ err = clk_debugfs_register(c);10041004+ if (err)10051005+ goto err_out;10061006+ }10071007+10081008+ d = debugfs_create_file("summary", S_IRUGO,10091009+ d, NULL, &debug_clock_fops);10101010+ if (!d)10111011+ return -ENOMEM;10121012+10131013+ return 0;10141014+err_out:10151015+ debugfs_remove_recursive(clk_debugfs_root);10161016+ return err;10171017+}10181018+late_initcall(clk_debugfs_init);10191019+10201020+#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */5271021
+316-1
arch/arm/mach-omap2/clock.h
···1717#define __ARCH_ARM_MACH_OMAP2_CLOCK_H18181919#include <linux/kernel.h>2020+#include <linux/list.h>20212121-#include <plat/clock.h>2222+#include <linux/clkdev.h>2323+2424+struct omap_clk {2525+ u16 cpu;2626+ struct clk_lookup lk;2727+};2828+2929+#define CLK(dev, con, ck, cp) \3030+ { \3131+ .cpu = cp, \3232+ .lk = { \3333+ .dev_id = dev, \3434+ .con_id = con, \3535+ .clk = ck, \3636+ }, \3737+ }3838+3939+/* Platform flags for the clkdev-OMAP integration code */4040+#define CK_242X (1 << 0)4141+#define CK_243X (1 << 1) /* 243x, 253x */4242+#define CK_3430ES1 (1 << 2) /* 34xxES1 only */4343+#define CK_3430ES2PLUS (1 << 3) /* 34xxES2, ES3, non-Sitara 35xx only */4444+#define CK_AM35XX (1 << 4) /* Sitara AM35xx */4545+#define CK_36XX (1 << 5) /* 36xx/37xx-specific clocks */4646+#define CK_443X (1 << 6)4747+#define CK_TI816X (1 << 7)4848+#define CK_446X (1 << 8)4949+#define CK_AM33XX (1 << 9) /* AM33xx specific clocks */5050+5151+5252+#define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS)5353+#define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX)5454+5555+struct module;5656+struct clk;5757+struct clockdomain;5858+5959+/* Temporary, needed during the common clock framework conversion */6060+#define __clk_get_name(clk) (clk->name)6161+#define __clk_get_parent(clk) (clk->parent)6262+#define __clk_get_rate(clk) (clk->rate)6363+6464+/**6565+ * struct clkops - some clock function pointers6666+ * @enable: fn ptr that enables the current clock in hardware6767+ * @disable: fn ptr that enables the current clock in hardware6868+ * @find_idlest: function returning the IDLEST register for the clock's IP blk6969+ * @find_companion: function returning the "companion" clk reg for the clock7070+ * @allow_idle: fn ptr that enables autoidle for the current clock in hardware7171+ * @deny_idle: fn ptr that disables autoidle for the current clock in hardware7272+ *7373+ * A "companion" clk is an accompanying clock to the one being queried7474+ * that must be enabled for the IP module connected to the clock to7575+ * become accessible by the hardware. Neither @find_idlest nor7676+ * @find_companion should be needed; that information is IP7777+ * block-specific; the hwmod code has been created to handle this, but7878+ * until hwmod data is ready and drivers have been converted to use PM7979+ * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and8080+ * @find_companion must, unfortunately, remain.8181+ */8282+struct clkops {8383+ int (*enable)(struct clk *);8484+ void (*disable)(struct clk *);8585+ void (*find_idlest)(struct clk *, void __iomem **,8686+ u8 *, u8 *);8787+ void (*find_companion)(struct clk *, void __iomem **,8888+ u8 *);8989+ void (*allow_idle)(struct clk *);9090+ void (*deny_idle)(struct clk *);9191+};9292+9393+/* struct clksel_rate.flags possibilities */9494+#define RATE_IN_242X (1 << 0)9595+#define RATE_IN_243X (1 << 1)9696+#define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */9797+#define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */9898+#define RATE_IN_36XX (1 << 4)9999+#define RATE_IN_4430 (1 << 5)100100+#define RATE_IN_TI816X (1 << 6)101101+#define RATE_IN_4460 (1 << 7)102102+#define RATE_IN_AM33XX (1 << 8)103103+#define RATE_IN_TI814X (1 << 9)104104+105105+#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)106106+#define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)107107+#define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX)108108+#define RATE_IN_44XX (RATE_IN_4430 | RATE_IN_4460)109109+110110+/* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */111111+#define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX)112112+113113+114114+/**115115+ * struct clksel_rate - register bitfield values corresponding to clk divisors116116+ * @val: register bitfield value (shifted to bit 0)117117+ * @div: clock divisor corresponding to @val118118+ * @flags: (see "struct clksel_rate.flags possibilities" above)119119+ *120120+ * @val should match the value of a read from struct clk.clksel_reg121121+ * AND'ed with struct clk.clksel_mask, shifted right to bit 0.122122+ *123123+ * @div is the divisor that should be applied to the parent clock's rate124124+ * to produce the current clock's rate.125125+ */126126+struct clksel_rate {127127+ u32 val;128128+ u8 div;129129+ u16 flags;130130+};131131+132132+/**133133+ * struct clksel - available parent clocks, and a pointer to their divisors134134+ * @parent: struct clk * to a possible parent clock135135+ * @rates: available divisors for this parent clock136136+ *137137+ * A struct clksel is always associated with one or more struct clks138138+ * and one or more struct clksel_rates.139139+ */140140+struct clksel {141141+ struct clk *parent;142142+ const struct clksel_rate *rates;143143+};144144+145145+/**146146+ * struct dpll_data - DPLL registers and integration data147147+ * @mult_div1_reg: register containing the DPLL M and N bitfields148148+ * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg149149+ * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg150150+ * @clk_bypass: struct clk pointer to the clock's bypass clock input151151+ * @clk_ref: struct clk pointer to the clock's reference clock input152152+ * @control_reg: register containing the DPLL mode bitfield153153+ * @enable_mask: mask of the DPLL mode bitfield in @control_reg154154+ * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()155155+ * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()156156+ * @max_multiplier: maximum valid non-bypass multiplier value (actual)157157+ * @last_rounded_n: cache of the last N result of omap2_dpll_round_rate()158158+ * @min_divider: minimum valid non-bypass divider value (actual)159159+ * @max_divider: maximum valid non-bypass divider value (actual)160160+ * @modes: possible values of @enable_mask161161+ * @autoidle_reg: register containing the DPLL autoidle mode bitfield162162+ * @idlest_reg: register containing the DPLL idle status bitfield163163+ * @autoidle_mask: mask of the DPLL autoidle mode bitfield in @autoidle_reg164164+ * @freqsel_mask: mask of the DPLL jitter correction bitfield in @control_reg165165+ * @idlest_mask: mask of the DPLL idle status bitfield in @idlest_reg166166+ * @auto_recal_bit: bitshift of the driftguard enable bit in @control_reg167167+ * @recal_en_bit: bitshift of the PRM_IRQENABLE_* bit for recalibration IRQs168168+ * @recal_st_bit: bitshift of the PRM_IRQSTATUS_* bit for recalibration IRQs169169+ * @flags: DPLL type/features (see below)170170+ *171171+ * Possible values for @flags:172172+ * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs)173173+ *174174+ * @freqsel_mask is only used on the OMAP34xx family and AM35xx.175175+ *176176+ * XXX Some DPLLs have multiple bypass inputs, so it's not technically177177+ * correct to only have one @clk_bypass pointer.178178+ *179179+ * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m,180180+ * @last_rounded_n) should be separated from the runtime-fixed fields181181+ * and placed into a different structure, so that the runtime-fixed data182182+ * can be placed into read-only space.183183+ */184184+struct dpll_data {185185+ void __iomem *mult_div1_reg;186186+ u32 mult_mask;187187+ u32 div1_mask;188188+ struct clk *clk_bypass;189189+ struct clk *clk_ref;190190+ void __iomem *control_reg;191191+ u32 enable_mask;192192+ unsigned long last_rounded_rate;193193+ u16 last_rounded_m;194194+ u16 max_multiplier;195195+ u8 last_rounded_n;196196+ u8 min_divider;197197+ u16 max_divider;198198+ u8 modes;199199+ void __iomem *autoidle_reg;200200+ void __iomem *idlest_reg;201201+ u32 autoidle_mask;202202+ u32 freqsel_mask;203203+ u32 idlest_mask;204204+ u32 dco_mask;205205+ u32 sddiv_mask;206206+ u8 auto_recal_bit;207207+ u8 recal_en_bit;208208+ u8 recal_st_bit;209209+ u8 flags;210210+};211211+212212+/*213213+ * struct clk.flags possibilities214214+ *215215+ * XXX document the rest of the clock flags here216216+ *217217+ * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL218218+ * bits share the same register. This flag allows the219219+ * omap4_dpllmx*() code to determine which GATE_CTRL bit field220220+ * should be used. This is a temporary solution - a better approach221221+ * would be to associate clock type-specific data with the clock,222222+ * similar to the struct dpll_data approach.223223+ */224224+#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */225225+#define CLOCK_IDLE_CONTROL (1 << 1)226226+#define CLOCK_NO_IDLE_PARENT (1 << 2)227227+#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */228228+#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */229229+#define CLOCK_CLKOUTX2 (1 << 5)230230+231231+/**232232+ * struct clk - OMAP struct clk233233+ * @node: list_head connecting this clock into the full clock list234234+ * @ops: struct clkops * for this clock235235+ * @name: the name of the clock in the hardware (used in hwmod data and debug)236236+ * @parent: pointer to this clock's parent struct clk237237+ * @children: list_head connecting to the child clks' @sibling list_heads238238+ * @sibling: list_head connecting this clk to its parent clk's @children239239+ * @rate: current clock rate240240+ * @enable_reg: register to write to enable the clock (see @enable_bit)241241+ * @recalc: fn ptr that returns the clock's current rate242242+ * @set_rate: fn ptr that can change the clock's current rate243243+ * @round_rate: fn ptr that can round the clock's current rate244244+ * @init: fn ptr to do clock-specific initialization245245+ * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)246246+ * @usecount: number of users that have requested this clock to be enabled247247+ * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div248248+ * @flags: see "struct clk.flags possibilities" above249249+ * @clksel_reg: for clksel clks, register va containing src/divisor select250250+ * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector251251+ * @clksel: for clksel clks, pointer to struct clksel for this clock252252+ * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock253253+ * @clkdm_name: clockdomain name that this clock is contained in254254+ * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime255255+ * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)256256+ * @src_offset: bitshift for source selection bitfield (OMAP1 only)257257+ *258258+ * XXX @rate_offset, @src_offset should probably be removed and OMAP1259259+ * clock code converted to use clksel.260260+ *261261+ * XXX @usecount is poorly named. It should be "enable_count" or262262+ * something similar. "users" in the description refers to kernel263263+ * code (core code or drivers) that have called clk_enable() and not264264+ * yet called clk_disable(); the usecount of parent clocks is also265265+ * incremented by the clock code when clk_enable() is called on child266266+ * clocks and decremented by the clock code when clk_disable() is267267+ * called on child clocks.268268+ *269269+ * XXX @clkdm, @usecount, @children, @sibling should be marked for270270+ * internal use only.271271+ *272272+ * @children and @sibling are used to optimize parent-to-child clock273273+ * tree traversals. (child-to-parent traversals use @parent.)274274+ *275275+ * XXX The notion of the clock's current rate probably needs to be276276+ * separated from the clock's target rate.277277+ */278278+struct clk {279279+ struct list_head node;280280+ const struct clkops *ops;281281+ const char *name;282282+ struct clk *parent;283283+ struct list_head children;284284+ struct list_head sibling; /* node for children */285285+ unsigned long rate;286286+ void __iomem *enable_reg;287287+ unsigned long (*recalc)(struct clk *);288288+ int (*set_rate)(struct clk *, unsigned long);289289+ long (*round_rate)(struct clk *, unsigned long);290290+ void (*init)(struct clk *);291291+ u8 enable_bit;292292+ s8 usecount;293293+ u8 fixed_div;294294+ u8 flags;295295+ void __iomem *clksel_reg;296296+ u32 clksel_mask;297297+ const struct clksel *clksel;298298+ struct dpll_data *dpll_data;299299+ const char *clkdm_name;300300+ struct clockdomain *clkdm;301301+#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)302302+ struct dentry *dent; /* For visible tree hierarchy */303303+#endif304304+};305305+306306+struct clk_functions {307307+ int (*clk_enable)(struct clk *clk);308308+ void (*clk_disable)(struct clk *clk);309309+ long (*clk_round_rate)(struct clk *clk, unsigned long rate);310310+ int (*clk_set_rate)(struct clk *clk, unsigned long rate);311311+ int (*clk_set_parent)(struct clk *clk, struct clk *parent);312312+ void (*clk_allow_idle)(struct clk *clk);313313+ void (*clk_deny_idle)(struct clk *clk);314314+ void (*clk_disable_unused)(struct clk *clk);315315+};316316+317317+extern int mpurate;318318+319319+extern int clk_init(struct clk_functions *custom_clocks);320320+extern void clk_preinit(struct clk *clk);321321+extern int clk_register(struct clk *clk);322322+extern void clk_reparent(struct clk *child, struct clk *parent);323323+extern void clk_unregister(struct clk *clk);324324+extern void propagate_rate(struct clk *clk);325325+extern void recalculate_root_clocks(void);326326+extern unsigned long followparent_recalc(struct clk *clk);327327+extern void clk_enable_init_clocks(void);328328+unsigned long omap_fixed_divisor_recalc(struct clk *clk);329329+extern struct clk *omap_clk_get_by_name(const char *name);330330+extern int omap_clk_enable_autoidle_all(void);331331+extern int omap_clk_disable_autoidle_all(void);332332+333333+extern const struct clkops clkops_null;334334+335335+extern struct clk dummy_ck;336336+2233723338/* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */24339#define CORE_CLK_SRC_32K 0x0
···2525#include <linux/spi/ads7846.h>26262727#include <linux/platform_data/spi-omap2-mcspi.h>2828-#include <linux/platform_data/mtd-nand-omap2.h>29283029#include "common.h"3130#include "common-board-devices.h"···9293#else9394void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,9495 struct ads7846_platform_data *board_pdata)9595-{9696-}9797-#endif9898-9999-#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)100100-static struct omap_nand_platform_data nand_data;101101-102102-void __init omap_nand_flash_init(int options, struct mtd_partition *parts,103103- int nr_parts)104104-{105105- u8 cs = 0;106106- u8 nandcs = GPMC_CS_NUM + 1;107107-108108- /* find out the chip-select on which NAND exists */109109- while (cs < GPMC_CS_NUM) {110110- u32 ret = 0;111111- ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);112112-113113- if ((ret & 0xC00) == 0x800) {114114- printk(KERN_INFO "Found NAND on CS%d\n", cs);115115- if (nandcs > GPMC_CS_NUM)116116- nandcs = cs;117117- }118118- cs++;119119- }120120-121121- if (nandcs > GPMC_CS_NUM) {122122- pr_info("NAND: Unable to find configuration in GPMC\n");123123- return;124124- }125125-126126- if (nandcs < GPMC_CS_NUM) {127127- nand_data.cs = nandcs;128128- nand_data.parts = parts;129129- nand_data.nr_parts = nr_parts;130130- nand_data.devsize = options;131131-132132- printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);133133- if (gpmc_nand_init(&nand_data) < 0)134134- printk(KERN_ERR "Unable to register NAND device\n");135135- }136136-}137137-#else138138-void __init omap_nand_flash_init(int options, struct mtd_partition *parts,139139- int nr_parts)14096{14197}14298#endif
-1
arch/arm/mach-omap2/common-board-devices.h
···10101111void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,1212 struct ads7846_platform_data *board_pdata);1313-void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);14131514#endif /* __OMAP_COMMON_BOARD_DEVICES__ */
+21-1
arch/arm/mach-omap2/common.c
···1616#include <linux/init.h>1717#include <linux/clk.h>1818#include <linux/io.h>1919+#include <linux/platform_data/dsp-omap.h>19202020-#include <plat/clock.h>2121+#include <plat/vram.h>21222223#include "soc.h"2324#include "iomap.h"2425#include "common.h"2626+#include "clock.h"2527#include "sdrc.h"2628#include "control.h"2929+#include "omap-secure.h"27302831/* Global address base setup code */2932···203200 omap5_map_common_io();204201}205202#endif203203+204204+/*205205+ * Stub function for OMAP2 so that common files206206+ * continue to build when custom builds are used207207+ */208208+int __weak omap_secure_ram_reserve_memblock(void)209209+{210210+ return 0;211211+}212212+213213+void __init omap_reserve(void)214214+{215215+ omap_vram_reserve_sdram_memblock();216216+ omap_dsp_reserve_sdram_memblock();217217+ omap_secure_ram_reserve_memblock();218218+ omap_barrier_reserve_memblock();219219+}
···11-#ifndef _OMAP_DEBUG_DEVICES_H22-#define _OMAP_DEBUG_DEVICES_H33-44-#include <linux/types.h>55-61/* for TI reference platforms sharing the same debug card */72extern int debug_card_init(u32 addr, unsigned gpio);88-99-#endif
···17171818#include <asm/mach/flash.h>19192020-#include <plat/gpmc.h>2121-2020+#include "gpmc.h"2221#include "soc.h"2222+#include "gpmc-nand.h"2323+2424+/* minimum size for IO mapping */2525+#define NAND_IO_SIZE 423262427static struct resource gpmc_nand_resource[] = {2528 {···4340 .resource = gpmc_nand_resource,4441};45424646-static int omap2_nand_gpmc_retime(struct omap_nand_platform_data *gpmc_nand_data)4343+static int omap2_nand_gpmc_retime(4444+ struct omap_nand_platform_data *gpmc_nand_data,4545+ struct gpmc_timings *gpmc_t)4746{4847 struct gpmc_timings t;4948 int err;50495151- if (!gpmc_nand_data->gpmc_t)5252- return 0;5353-5450 memset(&t, 0, sizeof(t));5555- t.sync_clk = gpmc_nand_data->gpmc_t->sync_clk;5656- t.cs_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_on);5757- t.adv_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->adv_on);5151+ t.sync_clk = gpmc_t->sync_clk;5252+ t.cs_on = gpmc_round_ns_to_ticks(gpmc_t->cs_on);5353+ t.adv_on = gpmc_round_ns_to_ticks(gpmc_t->adv_on);58545955 /* Read */6060- t.adv_rd_off = gpmc_round_ns_to_ticks(6161- gpmc_nand_data->gpmc_t->adv_rd_off);5656+ t.adv_rd_off = gpmc_round_ns_to_ticks(gpmc_t->adv_rd_off);6257 t.oe_on = t.adv_on;6363- t.access = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->access);6464- t.oe_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->oe_off);6565- t.cs_rd_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_rd_off);6666- t.rd_cycle = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->rd_cycle);5858+ t.access = gpmc_round_ns_to_ticks(gpmc_t->access);5959+ t.oe_off = gpmc_round_ns_to_ticks(gpmc_t->oe_off);6060+ t.cs_rd_off = gpmc_round_ns_to_ticks(gpmc_t->cs_rd_off);6161+ t.rd_cycle = gpmc_round_ns_to_ticks(gpmc_t->rd_cycle);67626863 /* Write */6969- t.adv_wr_off = gpmc_round_ns_to_ticks(7070- gpmc_nand_data->gpmc_t->adv_wr_off);6464+ t.adv_wr_off = gpmc_round_ns_to_ticks(gpmc_t->adv_wr_off);7165 t.we_on = t.oe_on;7266 if (cpu_is_omap34xx()) {7373- t.wr_data_mux_bus = gpmc_round_ns_to_ticks(7474- gpmc_nand_data->gpmc_t->wr_data_mux_bus);7575- t.wr_access = gpmc_round_ns_to_ticks(7676- gpmc_nand_data->gpmc_t->wr_access);6767+ t.wr_data_mux_bus = gpmc_round_ns_to_ticks(gpmc_t->wr_data_mux_bus);6868+ t.wr_access = gpmc_round_ns_to_ticks(gpmc_t->wr_access);7769 }7878- t.we_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->we_off);7979- t.cs_wr_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_wr_off);8080- t.wr_cycle = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->wr_cycle);7070+ t.we_off = gpmc_round_ns_to_ticks(gpmc_t->we_off);7171+ t.cs_wr_off = gpmc_round_ns_to_ticks(gpmc_t->cs_wr_off);7272+ t.wr_cycle = gpmc_round_ns_to_ticks(gpmc_t->wr_cycle);81738274 /* Configure GPMC */8375 if (gpmc_nand_data->devsize == NAND_BUSWIDTH_16)···8991 return 0;9092}91939292-int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data)9494+static bool __init gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt)9595+{9696+ /* support only OMAP3 class */9797+ if (!cpu_is_omap34xx()) {9898+ pr_err("BCH ecc is not supported on this CPU\n");9999+ return 0;100100+ }101101+102102+ /*103103+ * For now, assume 4-bit mode is only supported on OMAP3630 ES1.x, x>=1.104104+ * Other chips may be added if confirmed to work.105105+ */106106+ if ((ecc_opt == OMAP_ECC_BCH4_CODE_HW) &&107107+ (!cpu_is_omap3630() || (GET_OMAP_REVISION() == 0))) {108108+ pr_err("BCH 4-bit mode is not supported on this CPU\n");109109+ return 0;110110+ }111111+112112+ return 1;113113+}114114+115115+int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data,116116+ struct gpmc_timings *gpmc_t)93117{94118 int err = 0;95119 struct device *dev = &gpmc_nand_device.dev;···132112 gpmc_get_client_irq(GPMC_IRQ_FIFOEVENTENABLE);133113 gpmc_nand_resource[2].start =134114 gpmc_get_client_irq(GPMC_IRQ_COUNT_EVENT);135135- /* Set timings in GPMC */136136- err = omap2_nand_gpmc_retime(gpmc_nand_data);137137- if (err < 0) {138138- dev_err(dev, "Unable to set gpmc timings: %d\n", err);139139- return err;115115+116116+ if (gpmc_t) {117117+ err = omap2_nand_gpmc_retime(gpmc_nand_data, gpmc_t);118118+ if (err < 0) {119119+ dev_err(dev, "Unable to set gpmc timings: %d\n", err);120120+ return err;121121+ }140122 }141123142124 /* Enable RD PIN Monitoring Reg */···147125 }148126149127 gpmc_update_nand_reg(&gpmc_nand_data->reg, gpmc_nand_data->cs);128128+129129+ if (!gpmc_hwecc_bch_capable(gpmc_nand_data->ecc_opt))130130+ return -EINVAL;150131151132 err = platform_device_register(&gpmc_nand_device);152133 if (err < 0) {
+27
arch/arm/mach-omap2/gpmc-nand.h
···11+/*22+ * arch/arm/mach-omap2/gpmc-nand.h33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms of the GNU General Public License as published by the66+ * Free Software Foundation; either version 2 of the License, or (at your77+ * option) any later version.88+ */99+1010+#ifndef __OMAP2_GPMC_NAND_H1111+#define __OMAP2_GPMC_NAND_H1212+1313+#include "gpmc.h"1414+#include <linux/platform_data/mtd-nand-omap2.h>1515+1616+#if IS_ENABLED(CONFIG_MTD_NAND_OMAP2)1717+extern int gpmc_nand_init(struct omap_nand_platform_data *d,1818+ struct gpmc_timings *gpmc_t);1919+#else2020+static inline int gpmc_nand_init(struct omap_nand_platform_data *d,2121+ struct gpmc_timings *gpmc_t)2222+{2323+ return 0;2424+}2525+#endif2626+2727+#endif
+118-96
arch/arm/mach-omap2/gpmc-onenand.c
···1616#include <linux/mtd/onenand_regs.h>1717#include <linux/io.h>1818#include <linux/platform_data/mtd-onenand-omap2.h>1919+#include <linux/err.h>19202021#include <asm/mach/flash.h>21222222-#include <plat/gpmc.h>2323-2323+#include "gpmc.h"2424#include "soc.h"2525+#include "gpmc-onenand.h"25262627#define ONENAND_IO_SIZE SZ_128K2828+2929+#define ONENAND_FLAG_SYNCREAD (1 << 0)3030+#define ONENAND_FLAG_SYNCWRITE (1 << 1)3131+#define ONENAND_FLAG_HF (1 << 2)3232+#define ONENAND_FLAG_VHF (1 << 3)3333+3434+static unsigned onenand_flags;3535+static unsigned latency;3636+static int fclk_offset;27372838static struct omap_onenand_platform_data *gpmc_onenand_data;2939···4838 .resource = &gpmc_onenand_resource,4939};50405151-static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base)4141+static struct gpmc_timings omap2_onenand_calc_async_timings(void)5242{5343 struct gpmc_timings t;5454- u32 reg;5555- int err;56445745 const int t_cer = 15;5846 const int t_avdp = 12;···6254 const int t_ds = 30;6355 const int t_wpl = 40;6456 const int t_wph = 30;6565-6666- /* Ensure sync read and sync write are disabled */6767- reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);6868- reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE;6969- writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);70577158 memset(&t, 0, sizeof(t));7259 t.sync_clk = 0;···8986 t.cs_wr_off = t.we_off + gpmc_round_ns_to_ticks(t_wph);9087 t.wr_cycle = t.cs_wr_off + gpmc_round_ns_to_ticks(t_cez);91888989+ return t;9090+}9191+9292+static int gpmc_set_async_mode(int cs, struct gpmc_timings *t)9393+{9294 /* Configure GPMC for asynchronous read */9395 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1,9496 GPMC_CONFIG1_DEVICESIZE_16 |9597 GPMC_CONFIG1_MUXADDDATA);96989797- err = gpmc_cs_set_timings(cs, &t);9898- if (err)9999- return err;9999+ return gpmc_cs_set_timings(cs, t);100100+}101101+102102+static void omap2_onenand_set_async_mode(void __iomem *onenand_base)103103+{104104+ u32 reg;100105101106 /* Ensure sync read and sync write are disabled */102107 reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);103108 reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE;104109 writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);105105-106106- return 0;107110}108111109109-static void set_onenand_cfg(void __iomem *onenand_base, int latency,110110- int sync_read, int sync_write, int hf, int vhf)112112+static void set_onenand_cfg(void __iomem *onenand_base)111113{112114 u32 reg;113115···120112 reg &= ~((0x7 << ONENAND_SYS_CFG1_BRL_SHIFT) | (0x7 << 9));121113 reg |= (latency << ONENAND_SYS_CFG1_BRL_SHIFT) |122114 ONENAND_SYS_CFG1_BL_16;123123- if (sync_read)115115+ if (onenand_flags & ONENAND_FLAG_SYNCREAD)124116 reg |= ONENAND_SYS_CFG1_SYNC_READ;125117 else126118 reg &= ~ONENAND_SYS_CFG1_SYNC_READ;127127- if (sync_write)119119+ if (onenand_flags & ONENAND_FLAG_SYNCWRITE)128120 reg |= ONENAND_SYS_CFG1_SYNC_WRITE;129121 else130122 reg &= ~ONENAND_SYS_CFG1_SYNC_WRITE;131131- if (hf)123123+ if (onenand_flags & ONENAND_FLAG_HF)132124 reg |= ONENAND_SYS_CFG1_HF;133125 else134126 reg &= ~ONENAND_SYS_CFG1_HF;135135- if (vhf)127127+ if (onenand_flags & ONENAND_FLAG_VHF)136128 reg |= ONENAND_SYS_CFG1_VHF;137129 else138130 reg &= ~ONENAND_SYS_CFG1_VHF;···140132}141133142134static int omap2_onenand_get_freq(struct omap_onenand_platform_data *cfg,143143- void __iomem *onenand_base, bool *clk_dep)135135+ void __iomem *onenand_base)144136{145137 u16 ver = readw(onenand_base + ONENAND_REG_VERSION_ID);146146- int freq = 0;147147-148148- if (cfg->get_freq) {149149- struct onenand_freq_info fi;150150-151151- fi.maf_id = readw(onenand_base + ONENAND_REG_MANUFACTURER_ID);152152- fi.dev_id = readw(onenand_base + ONENAND_REG_DEVICE_ID);153153- fi.ver_id = ver;154154- freq = cfg->get_freq(&fi, clk_dep);155155- if (freq)156156- return freq;157157- }138138+ int freq;158139159140 switch ((ver >> 4) & 0xf) {160141 case 0:···169172 return freq;170173}171174172172-static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,173173- void __iomem *onenand_base,174174- int *freq_ptr)175175+static struct gpmc_timings176176+omap2_onenand_calc_sync_timings(struct omap_onenand_platform_data *cfg,177177+ int freq)175178{176179 struct gpmc_timings t;177180 const int t_cer = 15;···181184 const int t_wpl = 40;182185 const int t_wph = 30;183186 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;184184- int div, fclk_offset_ns, fclk_offset, gpmc_clk_ns, latency;185185- int first_time = 0, hf = 0, vhf = 0, sync_read = 0, sync_write = 0;186186- int err, ticks_cez;187187- int cs = cfg->cs, freq = *freq_ptr;188187 u32 reg;189189- bool clk_dep = false;188188+ int div, fclk_offset_ns, gpmc_clk_ns;189189+ int ticks_cez;190190+ int cs = cfg->cs;190191191191- if (cfg->flags & ONENAND_SYNC_READ) {192192- sync_read = 1;193193- } else if (cfg->flags & ONENAND_SYNC_READWRITE) {194194- sync_read = 1;195195- sync_write = 1;196196- } else197197- return omap2_onenand_set_async_mode(cs, onenand_base);198198-199199- if (!freq) {200200- /* Very first call freq is not known */201201- err = omap2_onenand_set_async_mode(cs, onenand_base);202202- if (err)203203- return err;204204- freq = omap2_onenand_get_freq(cfg, onenand_base, &clk_dep);205205- first_time = 1;206206- }192192+ if (cfg->flags & ONENAND_SYNC_READ)193193+ onenand_flags = ONENAND_FLAG_SYNCREAD;194194+ else if (cfg->flags & ONENAND_SYNC_READWRITE)195195+ onenand_flags = ONENAND_FLAG_SYNCREAD | ONENAND_FLAG_SYNCWRITE;207196208197 switch (freq) {209198 case 104:···227244 t_ach = 9;228245 t_aavdh = 7;229246 t_rdyo = 15;230230- sync_write = 0;247247+ onenand_flags &= ~ONENAND_FLAG_SYNCWRITE;231248 break;232249 }233250234234- div = gpmc_cs_calc_divider(cs, min_gpmc_clk_period);251251+ div = gpmc_calc_divider(min_gpmc_clk_period);235252 gpmc_clk_ns = gpmc_ticks_to_ns(div);236253 if (gpmc_clk_ns < 15) /* >66Mhz */237237- hf = 1;254254+ onenand_flags |= ONENAND_FLAG_HF;255255+ else256256+ onenand_flags &= ~ONENAND_FLAG_HF;238257 if (gpmc_clk_ns < 12) /* >83Mhz */239239- vhf = 1;240240- if (vhf)258258+ onenand_flags |= ONENAND_FLAG_VHF;259259+ else260260+ onenand_flags &= ~ONENAND_FLAG_VHF;261261+ if (onenand_flags & ONENAND_FLAG_VHF)241262 latency = 8;242242- else if (hf)263263+ else if (onenand_flags & ONENAND_FLAG_HF)243264 latency = 6;244265 else if (gpmc_clk_ns >= 25) /* 40 MHz*/245266 latency = 3;246267 else247268 latency = 4;248269249249- if (clk_dep) {250250- if (gpmc_clk_ns < 12) { /* >83Mhz */251251- t_ces = 3;252252- t_avds = 4;253253- } else if (gpmc_clk_ns < 15) { /* >66Mhz */254254- t_ces = 5;255255- t_avds = 4;256256- } else if (gpmc_clk_ns < 25) { /* >40Mhz */257257- t_ces = 6;258258- t_avds = 5;259259- } else {260260- t_ces = 7;261261- t_avds = 7;262262- }263263- }264264-265265- if (first_time)266266- set_onenand_cfg(onenand_base, latency,267267- sync_read, sync_write, hf, vhf);270270+ /* Set synchronous read timings */271271+ memset(&t, 0, sizeof(t));268272269273 if (div == 1) {270274 reg = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG2);···277307 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG4, reg);278308 }279309280280- /* Set synchronous read timings */281281- memset(&t, 0, sizeof(t));282310 t.sync_clk = min_gpmc_clk_period;283311 t.cs_on = 0;284312 t.adv_on = 0;···298330 ticks_cez);299331300332 /* Write */301301- if (sync_write) {333333+ if (onenand_flags & ONENAND_FLAG_SYNCWRITE) {302334 t.adv_wr_off = t.adv_rd_off;303335 t.we_on = 0;304336 t.we_off = t.cs_rd_off;···323355 }324356 }325357358358+ return t;359359+}360360+361361+static int gpmc_set_sync_mode(int cs, struct gpmc_timings *t)362362+{363363+ unsigned sync_read = onenand_flags & ONENAND_FLAG_SYNCREAD;364364+ unsigned sync_write = onenand_flags & ONENAND_FLAG_SYNCWRITE;365365+326366 /* Configure GPMC for synchronous read */327367 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1,328368 GPMC_CONFIG1_WRAPBURST_SUPP |···347371 GPMC_CONFIG1_DEVICETYPE_NOR |348372 GPMC_CONFIG1_MUXADDDATA);349373350350- err = gpmc_cs_set_timings(cs, &t);351351- if (err)352352- return err;374374+ return gpmc_cs_set_timings(cs, t);375375+}353376354354- set_onenand_cfg(onenand_base, latency, sync_read, sync_write, hf, vhf);377377+static int omap2_onenand_setup_async(void __iomem *onenand_base)378378+{379379+ struct gpmc_timings t;380380+ int ret;381381+382382+ omap2_onenand_set_async_mode(onenand_base);383383+384384+ t = omap2_onenand_calc_async_timings();385385+386386+ ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t);387387+ if (IS_ERR_VALUE(ret))388388+ return ret;389389+390390+ omap2_onenand_set_async_mode(onenand_base);391391+392392+ return 0;393393+}394394+395395+static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr)396396+{397397+ int ret, freq = *freq_ptr;398398+ struct gpmc_timings t;399399+400400+ if (!freq) {401401+ /* Very first call freq is not known */402402+ freq = omap2_onenand_get_freq(gpmc_onenand_data, onenand_base);403403+ set_onenand_cfg(onenand_base);404404+ }405405+406406+ t = omap2_onenand_calc_sync_timings(gpmc_onenand_data, freq);407407+408408+ ret = gpmc_set_sync_mode(gpmc_onenand_data->cs, &t);409409+ if (IS_ERR_VALUE(ret))410410+ return ret;411411+412412+ set_onenand_cfg(onenand_base);355413356414 *freq_ptr = freq;357415···395385static int gpmc_onenand_setup(void __iomem *onenand_base, int *freq_ptr)396386{397387 struct device *dev = &gpmc_onenand_device.dev;388388+ unsigned l = ONENAND_SYNC_READ | ONENAND_SYNC_READWRITE;389389+ int ret;398390399399- /* Set sync timings in GPMC */400400- if (omap2_onenand_set_sync_mode(gpmc_onenand_data, onenand_base,401401- freq_ptr) < 0) {402402- dev_err(dev, "Unable to set synchronous mode\n");403403- return -EINVAL;391391+ ret = omap2_onenand_setup_async(onenand_base);392392+ if (ret) {393393+ dev_err(dev, "unable to set to async mode\n");394394+ return ret;404395 }405396406406- return 0;397397+ if (!(gpmc_onenand_data->flags & l))398398+ return 0;399399+400400+ ret = omap2_onenand_setup_sync(onenand_base, freq_ptr);401401+ if (ret)402402+ dev_err(dev, "unable to set to sync mode\n");403403+ return ret;407404}408405409406void __init gpmc_onenand_init(struct omap_onenand_platform_data *_onenand_data)···427410 gpmc_onenand_data->flags &= ~ONENAND_SYNC_READWRITE;428411 gpmc_onenand_data->flags |= ONENAND_SYNC_READ;429412 }413413+414414+ if (cpu_is_omap34xx())415415+ gpmc_onenand_data->flags |= ONENAND_IN_OMAP34XX;416416+ else417417+ gpmc_onenand_data->flags &= ~ONENAND_IN_OMAP34XX;430418431419 err = gpmc_cs_request(gpmc_onenand_data->cs, ONENAND_IO_SIZE,432420 (unsigned long *)&gpmc_onenand_resource.start);
+24
arch/arm/mach-omap2/gpmc-onenand.h
···11+/*22+ * arch/arm/mach-omap2/gpmc-onenand.h33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms of the GNU General Public License as published by the66+ * Free Software Foundation; either version 2 of the License, or (at your77+ * option) any later version.88+ */99+1010+#ifndef __OMAP2_GPMC_ONENAND_H1111+#define __OMAP2_GPMC_ONENAND_H1212+1313+#include <linux/platform_data/mtd-onenand-omap2.h>1414+1515+#if IS_ENABLED(CONFIG_MTD_ONENAND_OMAP2)1616+extern void gpmc_onenand_init(struct omap_onenand_platform_data *d);1717+#else1818+#define board_onenand_data NULL1919+static inline void gpmc_onenand_init(struct omap_onenand_platform_data *d)2020+{2121+}2222+#endif2323+2424+#endif
···1919 *2020 */21212222-#include <plat/i2c.h>2222+#include "soc.h"2323#include "common.h"2424-#include <plat/omap_hwmod.h>2424+#include "omap_hwmod.h"2525+#include "omap_device.h"25262627#include "mux.h"2828+#include "i2c.h"27292830/* In register I2C_CON, Bit 15 is the I2C enable bit */2931#define I2C_EN BIT(15)···3533/* Maximum microseconds to wait for OMAP module to softreset */3634#define MAX_MODULE_SOFTRESET_WAIT 1000037353838-void __init omap2_i2c_mux_pins(int bus_id)3636+#define MAX_OMAP_I2C_HWMOD_NAME_LEN 163737+3838+static void __init omap2_i2c_mux_pins(int bus_id)3939{4040 char mux_name[sizeof("i2c2_scl.i2c2_scl")];4141···108104109105 return 0;110106}107107+108108+static int __init omap_i2c_nr_ports(void)109109+{110110+ int ports = 0;111111+112112+ if (cpu_is_omap24xx())113113+ ports = 2;114114+ else if (cpu_is_omap34xx())115115+ ports = 3;116116+ else if (cpu_is_omap44xx())117117+ ports = 4;118118+ return ports;119119+}120120+121121+static const char name[] = "omap_i2c";122122+123123+int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata,124124+ int bus_id)125125+{126126+ int l;127127+ struct omap_hwmod *oh;128128+ struct platform_device *pdev;129129+ char oh_name[MAX_OMAP_I2C_HWMOD_NAME_LEN];130130+ struct omap_i2c_bus_platform_data *pdata;131131+ struct omap_i2c_dev_attr *dev_attr;132132+133133+ if (bus_id > omap_i2c_nr_ports())134134+ return -EINVAL;135135+136136+ omap2_i2c_mux_pins(bus_id);137137+138138+ l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);139139+ WARN(l >= MAX_OMAP_I2C_HWMOD_NAME_LEN,140140+ "String buffer overflow in I2C%d device setup\n", bus_id);141141+ oh = omap_hwmod_lookup(oh_name);142142+ if (!oh) {143143+ pr_err("Could not look up %s\n", oh_name);144144+ return -EEXIST;145145+ }146146+147147+ pdata = i2c_pdata;148148+ /*149149+ * pass the hwmod class's CPU-specific knowledge of I2C IP revision in150150+ * use, and functionality implementation flags, up to the OMAP I2C151151+ * driver via platform data152152+ */153153+ pdata->rev = oh->class->rev;154154+155155+ dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;156156+ pdata->flags = dev_attr->flags;157157+158158+ pdev = omap_device_build(name, bus_id, oh, pdata,159159+ sizeof(struct omap_i2c_bus_platform_data),160160+ NULL, 0, 0);161161+ WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name);162162+163163+ return PTR_RET(pdev);164164+}165165+
+42
arch/arm/mach-omap2/i2c.h
···11+/*22+ * Helper module for board specific I2C bus registration33+ *44+ * Copyright (C) 2009 Nokia Corporation.55+ *66+ * This program is free software; you can redistribute it and/or77+ * modify it under the terms of the GNU General Public License88+ * version 2 as published by the Free Software Foundation.99+ *1010+ * This program is distributed in the hope that it will be useful, but1111+ * WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1313+ * General Public License for more details.1414+ *1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program; if not, write to the Free Software1717+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA1818+ * 02110-1301 USA1919+ *2020+ */2121+2222+#include <plat/i2c.h>2323+2424+#ifndef __MACH_OMAP2_I2C_H2525+#define __MACH_OMAP2_I2C_H2626+2727+/**2828+ * i2c_dev_attr - OMAP I2C controller device attributes for omap_hwmod2929+ * @fifo_depth: total controller FIFO size (in bytes)3030+ * @flags: differences in hardware support capability3131+ *3232+ * @fifo_depth represents what exists on the hardware, not what is3333+ * actually configured at runtime by the device driver.3434+ */3535+struct omap_i2c_dev_attr {3636+ u8 fifo_depth;3737+ u32 flags;3838+};3939+4040+int omap_i2c_reset(struct omap_hwmod *oh);4141+4242+#endif /* __MACH_OMAP2_I2C_H */
···1919#include <linux/platform_device.h>2020#include <linux/slab.h>2121#include <linux/platform_data/asoc-ti-mcbsp.h>2222-2323-#include <plat/dma.h>2424-#include <plat/omap_device.h>2522#include <linux/pm_runtime.h>2323+2424+#include <plat-omap/dma-omap.h>2525+2626+#include "omap_device.h"26272728/*2829 * FIXME: Find a mechanism to enable/disable runtime the McBSP ICLK autoidle.
+23
arch/arm/mach-omap2/mmc.h
···11+#include <linux/mmc/host.h>22+#include <linux/platform_data/mmc-omap.h>33+44+#define OMAP24XX_NR_MMC 255+#define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE66+#define OMAP2_MMC1_BASE 0x4809c00077+88+#define OMAP4_MMC_REG_OFFSET 0x10099+1010+#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)1111+void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data);1212+#else1313+static inline void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)1414+{1515+}1616+#endif1717+1818+struct omap_hwmod;1919+int omap_msdi_reset(struct omap_hwmod *oh);2020+2121+/* called from board-specific card detection service routine */2222+extern void omap_mmc_notify_cover_event(struct device *dev, int slot,2323+ int is_closed);
+3-4
arch/arm/mach-omap2/msdi.c
···2525#include <linux/err.h>2626#include <linux/platform_data/gpio-omap.h>27272828-#include <plat/omap_hwmod.h>2929-#include <plat/omap_device.h>3030-#include <plat/mmc.h>3131-3228#include "common.h"3329#include "control.h"3030+#include "omap_hwmod.h"3131+#include "omap_device.h"3432#include "mux.h"3333+#include "mmc.h"35343635/*3736 * MSDI_CON_OFFSET: offset in bytes of the MSDI IP block's CON register
···99 * it under the terms of the GNU General Public License version 2 as1010 * published by the Free Software Foundation.1111 */1212-#include <plat/omap_hwmod.h>1313-#include <plat/serial.h>1414-#include <plat/dma.h>1515-#include <plat/common.h>1212+1313+#include <plat-omap/dma-omap.h>1414+1515+#include "omap_hwmod.h"1616#include "hdq1w.h"17171818#include "omap_hwmod_common_data.h"1919+#include "dma.h"19202021/* UART */2122
···88 * it under the terms of the GNU General Public License version 2 as99 * published by the Free Software Foundation.1010 */1111-#include <plat/omap_hwmod.h>1212-#include <plat/serial.h>1111+1312#include <linux/platform_data/gpio-omap.h>1414-#include <plat/dma.h>1313+#include <plat-omap/dma-omap.h>1514#include <plat/dmtimer.h>1615#include <linux/platform_data/spi-omap2-mcspi.h>17161717+#include "omap_hwmod.h"1818#include "omap_hwmod_common_data.h"1919#include "cm-regbits-24xx.h"2020#include "prm-regbits-24xx.h"
+5-5
arch/arm/mach-omap2/omap_hwmod_33xx_data.c
···1414 * GNU General Public License for more details.1515 */16161717-#include <plat/omap_hwmod.h>1818-#include <plat/cpu.h>1717+#include <linux/i2c-omap.h>1818+1919+#include "omap_hwmod.h"1920#include <linux/platform_data/gpio-omap.h>2021#include <linux/platform_data/spi-omap2-mcspi.h>2121-#include <plat/dma.h>2222-#include <plat/mmc.h>2323-#include <plat/i2c.h>24222523#include "omap_hwmod_common_data.h"2624···2628#include "cm33xx.h"2729#include "prm33xx.h"2830#include "prm-regbits-33xx.h"3131+#include "i2c.h"3232+#include "mmc.h"29333034/*3135 * IP blocks
+9-5
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
···1414 *1515 * XXX these should be marked initdata for multi-OMAP kernels1616 */1717+1818+#include <linux/i2c-omap.h>1719#include <linux/power/smartreflex.h>1820#include <linux/platform_data/gpio-omap.h>19212020-#include <plat/omap_hwmod.h>2121-#include <plat/dma.h>2222-#include <plat/serial.h>2222+#include <plat-omap/dma-omap.h>2323#include "l3_3xxx.h"2424#include "l4_3xxx.h"2525-#include <plat/i2c.h>2626-#include <plat/mmc.h>2725#include <linux/platform_data/asoc-ti-mcbsp.h>2826#include <linux/platform_data/spi-omap2-mcspi.h>2927#include <plat/dmtimer.h>···3032#include "am35xx.h"31333234#include "soc.h"3535+#include "omap_hwmod.h"3336#include "omap_hwmod_common_data.h"3437#include "prm-regbits-34xx.h"3538#include "cm-regbits-34xx.h"3939+4040+#include "dma.h"4141+#include "i2c.h"4242+#include "mmc.h"3643#include "wd_timer.h"4444+#include "serial.h"37453846/*3947 * OMAP3xxx hardware module integration data
+6-5
arch/arm/mach-omap2/omap_hwmod_44xx_data.c
···2121#include <linux/io.h>2222#include <linux/platform_data/gpio-omap.h>2323#include <linux/power/smartreflex.h>2424+#include <linux/i2c-omap.h>24252525-#include <plat/omap_hwmod.h>2626-#include <plat/i2c.h>2727-#include <plat/dma.h>2626+#include <plat-omap/dma-omap.h>2727+2828#include <linux/platform_data/spi-omap2-mcspi.h>2929#include <linux/platform_data/asoc-ti-mcbsp.h>3030-#include <plat/mmc.h>3130#include <plat/dmtimer.h>3232-#include <plat/common.h>3331#include <plat/iommu.h>34323333+#include "omap_hwmod.h"3534#include "omap_hwmod_common_data.h"3635#include "cm1_44xx.h"3736#include "cm2_44xx.h"3837#include "prm44xx.h"3938#include "prm-regbits-44xx.h"3939+#include "i2c.h"4040+#include "mmc.h"4041#include "wd_timer.h"41424243/* Base offset for all OMAP4 interrupts external to MPUSS */
+1-1
arch/arm/mach-omap2/omap_hwmod_common_data.c
···1616 * data and their integration with other OMAP modules and Linux.1717 */18181919-#include <plat/omap_hwmod.h>1919+#include "omap_hwmod.h"20202121#include "omap_hwmod_common_data.h"2222
···1414#ifndef ARCH_ARM_MACH_OMAP2_SDRAM_MICRON_MT46H32M32LF1515#define ARCH_ARM_MACH_OMAP2_SDRAM_MICRON_MT46H32M32LF16161717-#include <plat/sdrc.h>1717+#include "sdrc.h"18181919/* Micron MT46H32M32LF-6 */2020/* XXX Using ARE = 0x1 (no autorefresh burst) -- can this be changed? */
+1-3
arch/arm/mach-omap2/sdram-nokia.c
···1818#include <linux/io.h>19192020#include "common.h"2121-#include <plat/clock.h>2222-#include <plat/sdrc.h>2323-2421#include "sdram-nokia.h"2222+#include "sdrc.h"25232624/* In picoseconds, except for tREF (ns), tXP, tCKE, tWTR (clks) */2725struct sdram_timings {
···22#define __ARCH_ARM_MACH_OMAP2_SDRC_H3344/*55- * OMAP2 SDRC register definitions55+ * OMAP2/3 SDRC/SMS macros and prototypes66 *77- * Copyright (C) 2007 Texas Instruments, Inc.88- * Copyright (C) 2007 Nokia Corporation77+ * Copyright (C) 2007-2008, 2012 Texas Instruments, Inc.88+ * Copyright (C) 2007-2008 Nokia Corporation99 *1010- * Written by Paul Walmsley1010+ * Paul Walmsley1111+ * Tony Lindgren1212+ * Richard Woodruff1113 *1214 * This program is free software; you can redistribute it and/or modify1315 * it under the terms of the GNU General Public License version 2 as1416 * published by the Free Software Foundation.1517 */1618#undef DEBUG1717-1818-#include <plat/sdrc.h>19192020#ifndef __ASSEMBLER__2121···5050{5151 return __raw_readl(OMAP_SMS_REGADDR(reg));5252}5353+5454+5555+/**5656+ * struct omap_sdrc_params - SDRC parameters for a given SDRC clock rate5757+ * @rate: SDRC clock rate (in Hz)5858+ * @actim_ctrla: Value to program to SDRC_ACTIM_CTRLA for this rate5959+ * @actim_ctrlb: Value to program to SDRC_ACTIM_CTRLB for this rate6060+ * @rfr_ctrl: Value to program to SDRC_RFR_CTRL for this rate6161+ * @mr: Value to program to SDRC_MR for this rate6262+ *6363+ * This structure holds a pre-computed set of register values for the6464+ * SDRC for a given SDRC clock rate and SDRAM chip. These are6565+ * intended to be pre-computed and specified in an array in the board-*.c6666+ * files. The structure is keyed off the 'rate' field.6767+ */6868+struct omap_sdrc_params {6969+ unsigned long rate;7070+ u32 actim_ctrla;7171+ u32 actim_ctrlb;7272+ u32 rfr_ctrl;7373+ u32 mr;7474+};7575+7676+#ifdef CONFIG_SOC_HAS_OMAP2_SDRC7777+void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,7878+ struct omap_sdrc_params *sdrc_cs1);7979+#else8080+static inline void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,8181+ struct omap_sdrc_params *sdrc_cs1) {};8282+#endif8383+8484+int omap2_sdrc_get_params(unsigned long r,8585+ struct omap_sdrc_params **sdrc_cs0,8686+ struct omap_sdrc_params **sdrc_cs1);8787+void omap2_sms_save_context(void);8888+void omap2_sms_restore_context(void);8989+9090+struct memory_timings {9191+ u32 m_type; /* ddr = 1, sdr = 0 */9292+ u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */9393+ u32 slow_dll_ctrl; /* unlock mode, dll value for slow speed */9494+ u32 fast_dll_ctrl; /* unlock mode, dll value for fast speed */9595+ u32 base_cs; /* base chip select to use for calculations */9696+};9797+9898+extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);9999+struct omap_sdrc_params *rx51_get_sdram_timings(void);100100+101101+u32 omap2xxx_sdrc_dll_is_unlocked(void);102102+u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);103103+104104+53105#else54106#define OMAP242X_SDRC_REGADDR(reg) \55107 OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE + (reg))···10957 OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE + (reg))11058#define OMAP34XX_SDRC_REGADDR(reg) \11159 OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE + (reg))6060+11261#endif /* __ASSEMBLER__ */1136211463/* Minimum frequency that the SDRC DLL can lock at */···12673 * 2^MPURATE_BASE_SHIFT MHz for SDRC to stabilize12774 */12875#define SDRC_MPURATE_LOOPS 967676+7777+/* SDRC register offsets - read/write with sdrc_{read,write}_reg() */7878+7979+#define SDRC_SYSCONFIG 0x0108080+#define SDRC_CS_CFG 0x0408181+#define SDRC_SHARING 0x0448282+#define SDRC_ERR_TYPE 0x04C8383+#define SDRC_DLLA_CTRL 0x0608484+#define SDRC_DLLA_STATUS 0x0648585+#define SDRC_DLLB_CTRL 0x0688686+#define SDRC_DLLB_STATUS 0x06C8787+#define SDRC_POWER 0x0708888+#define SDRC_MCFG_0 0x0808989+#define SDRC_MR_0 0x0849090+#define SDRC_EMR2_0 0x08c9191+#define SDRC_ACTIM_CTRL_A_0 0x09c9292+#define SDRC_ACTIM_CTRL_B_0 0x0a09393+#define SDRC_RFR_CTRL_0 0x0a49494+#define SDRC_MANUAL_0 0x0a89595+#define SDRC_MCFG_1 0x0B09696+#define SDRC_MR_1 0x0B49797+#define SDRC_EMR2_1 0x0BC9898+#define SDRC_ACTIM_CTRL_A_1 0x0C49999+#define SDRC_ACTIM_CTRL_B_1 0x0C8100100+#define SDRC_RFR_CTRL_1 0x0D4101101+#define SDRC_MANUAL_1 0x0D8102102+103103+#define SDRC_POWER_AUTOCOUNT_SHIFT 8104104+#define SDRC_POWER_AUTOCOUNT_MASK (0xffff << SDRC_POWER_AUTOCOUNT_SHIFT)105105+#define SDRC_POWER_CLKCTRL_SHIFT 4106106+#define SDRC_POWER_CLKCTRL_MASK (0x3 << SDRC_POWER_CLKCTRL_SHIFT)107107+#define SDRC_SELF_REFRESH_ON_AUTOCOUNT (0x2 << SDRC_POWER_CLKCTRL_SHIFT)108108+109109+/*110110+ * These values represent the number of memory clock cycles between111111+ * autorefresh initiation. They assume 1 refresh per 64 ms (JEDEC), 8192112112+ * rows per device, and include a subtraction of a 50 cycle window in the113113+ * event that the autorefresh command is delayed due to other SDRC activity.114114+ * The '| 1' sets the ARE field to send one autorefresh when the autorefresh115115+ * counter reaches 0.116116+ *117117+ * These represent optimal values for common parts, it won't work for all.118118+ * As long as you scale down, most parameters are still work, they just119119+ * become sub-optimal. The RFR value goes in the opposite direction. If you120120+ * don't adjust it down as your clock period increases the refresh interval121121+ * will not be met. Setting all parameters for complete worst case may work,122122+ * but may cut memory performance by 2x. Due to errata the DLLs need to be123123+ * unlocked and their value needs run time calibration. A dynamic call is124124+ * need for that as no single right value exists acorss production samples.125125+ *126126+ * Only the FULL speed values are given. Current code is such that rate127127+ * changes must be made at DPLLoutx2. The actual value adjustment for low128128+ * frequency operation will be handled by omap_set_performance()129129+ *130130+ * By having the boot loader boot up in the fastest L4 speed available likely131131+ * will result in something which you can switch between.132132+ */133133+#define SDRC_RFR_CTRL_165MHz (0x00044c00 | 1)134134+#define SDRC_RFR_CTRL_133MHz (0x0003de00 | 1)135135+#define SDRC_RFR_CTRL_100MHz (0x0002da01 | 1)136136+#define SDRC_RFR_CTRL_110MHz (0x0002da01 | 1) /* Need to calc */137137+#define SDRC_RFR_CTRL_BYPASS (0x00005000 | 1) /* Need to calc */138138+139139+140140+/*141141+ * SMS register access142142+ */143143+144144+#define OMAP242X_SMS_REGADDR(reg) \145145+ (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE + reg)146146+#define OMAP243X_SMS_REGADDR(reg) \147147+ (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE + reg)148148+#define OMAP343X_SMS_REGADDR(reg) \149149+ (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE + reg)150150+151151+/* SMS register offsets - read/write with sms_{read,write}_reg() */152152+153153+#define SMS_SYSCONFIG 0x010154154+/* REVISIT: fill in other SMS registers here */155155+156156+129157130158#endif
···1010#ifndef __ARCH_ARM_MACH_OMAP2_WD_TIMER_H1111#define __ARCH_ARM_MACH_OMAP2_WD_TIMER_H12121313-#include <plat/omap_hwmod.h>1313+#include "omap_hwmod.h"14141515extern int omap2_wd_timer_disable(struct omap_hwmod *oh);1616extern int omap2_wd_timer_reset(struct omap_hwmod *oh);
+1-3
arch/arm/plat-omap/Makefile
···33#4455# Common support66-obj-y := common.o sram.o clock.o dma.o fb.o counter_32k.o66+obj-y := sram.o dma.o fb.o counter_32k.o77obj-m :=88obj-n :=99obj- :=10101111# omap_device support (OMAP2+ only at the moment)1212-obj-$(CONFIG_ARCH_OMAP2PLUS) += omap_device.o13121413obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o1514obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o···1920# OMAP mailbox framework2021obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o21222222-obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
-544
arch/arm/plat-omap/clock.c
···11-/*22- * linux/arch/arm/plat-omap/clock.c33- *44- * Copyright (C) 2004 - 2008 Nokia corporation55- * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>66- *77- * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>88- *99- * This program is free software; you can redistribute it and/or modify1010- * it under the terms of the GNU General Public License version 2 as1111- * published by the Free Software Foundation.1212- */1313-#include <linux/kernel.h>1414-#include <linux/init.h>1515-#include <linux/list.h>1616-#include <linux/errno.h>1717-#include <linux/export.h>1818-#include <linux/err.h>1919-#include <linux/string.h>2020-#include <linux/clk.h>2121-#include <linux/mutex.h>2222-#include <linux/cpufreq.h>2323-#include <linux/io.h>2424-2525-#include <plat/clock.h>2626-2727-static LIST_HEAD(clocks);2828-static DEFINE_MUTEX(clocks_mutex);2929-static DEFINE_SPINLOCK(clockfw_lock);3030-3131-static struct clk_functions *arch_clock;3232-3333-/*3434- * Standard clock functions defined in include/linux/clk.h3535- */3636-3737-int clk_enable(struct clk *clk)3838-{3939- unsigned long flags;4040- int ret;4141-4242- if (clk == NULL || IS_ERR(clk))4343- return -EINVAL;4444-4545- if (!arch_clock || !arch_clock->clk_enable)4646- return -EINVAL;4747-4848- spin_lock_irqsave(&clockfw_lock, flags);4949- ret = arch_clock->clk_enable(clk);5050- spin_unlock_irqrestore(&clockfw_lock, flags);5151-5252- return ret;5353-}5454-EXPORT_SYMBOL(clk_enable);5555-5656-void clk_disable(struct clk *clk)5757-{5858- unsigned long flags;5959-6060- if (clk == NULL || IS_ERR(clk))6161- return;6262-6363- if (!arch_clock || !arch_clock->clk_disable)6464- return;6565-6666- spin_lock_irqsave(&clockfw_lock, flags);6767- if (clk->usecount == 0) {6868- pr_err("Trying disable clock %s with 0 usecount\n",6969- clk->name);7070- WARN_ON(1);7171- goto out;7272- }7373-7474- arch_clock->clk_disable(clk);7575-7676-out:7777- spin_unlock_irqrestore(&clockfw_lock, flags);7878-}7979-EXPORT_SYMBOL(clk_disable);8080-8181-unsigned long clk_get_rate(struct clk *clk)8282-{8383- unsigned long flags;8484- unsigned long ret;8585-8686- if (clk == NULL || IS_ERR(clk))8787- return 0;8888-8989- spin_lock_irqsave(&clockfw_lock, flags);9090- ret = clk->rate;9191- spin_unlock_irqrestore(&clockfw_lock, flags);9292-9393- return ret;9494-}9595-EXPORT_SYMBOL(clk_get_rate);9696-9797-/*9898- * Optional clock functions defined in include/linux/clk.h9999- */100100-101101-long clk_round_rate(struct clk *clk, unsigned long rate)102102-{103103- unsigned long flags;104104- long ret;105105-106106- if (clk == NULL || IS_ERR(clk))107107- return 0;108108-109109- if (!arch_clock || !arch_clock->clk_round_rate)110110- return 0;111111-112112- spin_lock_irqsave(&clockfw_lock, flags);113113- ret = arch_clock->clk_round_rate(clk, rate);114114- spin_unlock_irqrestore(&clockfw_lock, flags);115115-116116- return ret;117117-}118118-EXPORT_SYMBOL(clk_round_rate);119119-120120-int clk_set_rate(struct clk *clk, unsigned long rate)121121-{122122- unsigned long flags;123123- int ret = -EINVAL;124124-125125- if (clk == NULL || IS_ERR(clk))126126- return ret;127127-128128- if (!arch_clock || !arch_clock->clk_set_rate)129129- return ret;130130-131131- spin_lock_irqsave(&clockfw_lock, flags);132132- ret = arch_clock->clk_set_rate(clk, rate);133133- if (ret == 0)134134- propagate_rate(clk);135135- spin_unlock_irqrestore(&clockfw_lock, flags);136136-137137- return ret;138138-}139139-EXPORT_SYMBOL(clk_set_rate);140140-141141-int clk_set_parent(struct clk *clk, struct clk *parent)142142-{143143- unsigned long flags;144144- int ret = -EINVAL;145145-146146- if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))147147- return ret;148148-149149- if (!arch_clock || !arch_clock->clk_set_parent)150150- return ret;151151-152152- spin_lock_irqsave(&clockfw_lock, flags);153153- if (clk->usecount == 0) {154154- ret = arch_clock->clk_set_parent(clk, parent);155155- if (ret == 0)156156- propagate_rate(clk);157157- } else158158- ret = -EBUSY;159159- spin_unlock_irqrestore(&clockfw_lock, flags);160160-161161- return ret;162162-}163163-EXPORT_SYMBOL(clk_set_parent);164164-165165-struct clk *clk_get_parent(struct clk *clk)166166-{167167- return clk->parent;168168-}169169-EXPORT_SYMBOL(clk_get_parent);170170-171171-/*172172- * OMAP specific clock functions shared between omap1 and omap2173173- */174174-175175-int __initdata mpurate;176176-177177-/*178178- * By default we use the rate set by the bootloader.179179- * You can override this with mpurate= cmdline option.180180- */181181-static int __init omap_clk_setup(char *str)182182-{183183- get_option(&str, &mpurate);184184-185185- if (!mpurate)186186- return 1;187187-188188- if (mpurate < 1000)189189- mpurate *= 1000000;190190-191191- return 1;192192-}193193-__setup("mpurate=", omap_clk_setup);194194-195195-/* Used for clocks that always have same value as the parent clock */196196-unsigned long followparent_recalc(struct clk *clk)197197-{198198- return clk->parent->rate;199199-}200200-201201-/*202202- * Used for clocks that have the same value as the parent clock,203203- * divided by some factor204204- */205205-unsigned long omap_fixed_divisor_recalc(struct clk *clk)206206-{207207- WARN_ON(!clk->fixed_div);208208-209209- return clk->parent->rate / clk->fixed_div;210210-}211211-212212-void clk_reparent(struct clk *child, struct clk *parent)213213-{214214- list_del_init(&child->sibling);215215- if (parent)216216- list_add(&child->sibling, &parent->children);217217- child->parent = parent;218218-219219- /* now do the debugfs renaming to reattach the child220220- to the proper parent */221221-}222222-223223-/* Propagate rate to children */224224-void propagate_rate(struct clk *tclk)225225-{226226- struct clk *clkp;227227-228228- list_for_each_entry(clkp, &tclk->children, sibling) {229229- if (clkp->recalc)230230- clkp->rate = clkp->recalc(clkp);231231- propagate_rate(clkp);232232- }233233-}234234-235235-static LIST_HEAD(root_clks);236236-237237-/**238238- * recalculate_root_clocks - recalculate and propagate all root clocks239239- *240240- * Recalculates all root clocks (clocks with no parent), which if the241241- * clock's .recalc is set correctly, should also propagate their rates.242242- * Called at init.243243- */244244-void recalculate_root_clocks(void)245245-{246246- struct clk *clkp;247247-248248- list_for_each_entry(clkp, &root_clks, sibling) {249249- if (clkp->recalc)250250- clkp->rate = clkp->recalc(clkp);251251- propagate_rate(clkp);252252- }253253-}254254-255255-/**256256- * clk_preinit - initialize any fields in the struct clk before clk init257257- * @clk: struct clk * to initialize258258- *259259- * Initialize any struct clk fields needed before normal clk initialization260260- * can run. No return value.261261- */262262-void clk_preinit(struct clk *clk)263263-{264264- INIT_LIST_HEAD(&clk->children);265265-}266266-267267-int clk_register(struct clk *clk)268268-{269269- if (clk == NULL || IS_ERR(clk))270270- return -EINVAL;271271-272272- /*273273- * trap out already registered clocks274274- */275275- if (clk->node.next || clk->node.prev)276276- return 0;277277-278278- mutex_lock(&clocks_mutex);279279- if (clk->parent)280280- list_add(&clk->sibling, &clk->parent->children);281281- else282282- list_add(&clk->sibling, &root_clks);283283-284284- list_add(&clk->node, &clocks);285285- if (clk->init)286286- clk->init(clk);287287- mutex_unlock(&clocks_mutex);288288-289289- return 0;290290-}291291-EXPORT_SYMBOL(clk_register);292292-293293-void clk_unregister(struct clk *clk)294294-{295295- if (clk == NULL || IS_ERR(clk))296296- return;297297-298298- mutex_lock(&clocks_mutex);299299- list_del(&clk->sibling);300300- list_del(&clk->node);301301- mutex_unlock(&clocks_mutex);302302-}303303-EXPORT_SYMBOL(clk_unregister);304304-305305-void clk_enable_init_clocks(void)306306-{307307- struct clk *clkp;308308-309309- list_for_each_entry(clkp, &clocks, node) {310310- if (clkp->flags & ENABLE_ON_INIT)311311- clk_enable(clkp);312312- }313313-}314314-315315-int omap_clk_enable_autoidle_all(void)316316-{317317- struct clk *c;318318- unsigned long flags;319319-320320- spin_lock_irqsave(&clockfw_lock, flags);321321-322322- list_for_each_entry(c, &clocks, node)323323- if (c->ops->allow_idle)324324- c->ops->allow_idle(c);325325-326326- spin_unlock_irqrestore(&clockfw_lock, flags);327327-328328- return 0;329329-}330330-331331-int omap_clk_disable_autoidle_all(void)332332-{333333- struct clk *c;334334- unsigned long flags;335335-336336- spin_lock_irqsave(&clockfw_lock, flags);337337-338338- list_for_each_entry(c, &clocks, node)339339- if (c->ops->deny_idle)340340- c->ops->deny_idle(c);341341-342342- spin_unlock_irqrestore(&clockfw_lock, flags);343343-344344- return 0;345345-}346346-347347-/*348348- * Low level helpers349349- */350350-static int clkll_enable_null(struct clk *clk)351351-{352352- return 0;353353-}354354-355355-static void clkll_disable_null(struct clk *clk)356356-{357357-}358358-359359-const struct clkops clkops_null = {360360- .enable = clkll_enable_null,361361- .disable = clkll_disable_null,362362-};363363-364364-/*365365- * Dummy clock366366- *367367- * Used for clock aliases that are needed on some OMAPs, but not others368368- */369369-struct clk dummy_ck = {370370- .name = "dummy",371371- .ops = &clkops_null,372372-};373373-374374-/*375375- *376376- */377377-378378-#ifdef CONFIG_OMAP_RESET_CLOCKS379379-/*380380- * Disable any unused clocks left on by the bootloader381381- */382382-static int __init clk_disable_unused(void)383383-{384384- struct clk *ck;385385- unsigned long flags;386386-387387- if (!arch_clock || !arch_clock->clk_disable_unused)388388- return 0;389389-390390- pr_info("clock: disabling unused clocks to save power\n");391391-392392- spin_lock_irqsave(&clockfw_lock, flags);393393- list_for_each_entry(ck, &clocks, node) {394394- if (ck->ops == &clkops_null)395395- continue;396396-397397- if (ck->usecount > 0 || !ck->enable_reg)398398- continue;399399-400400- arch_clock->clk_disable_unused(ck);401401- }402402- spin_unlock_irqrestore(&clockfw_lock, flags);403403-404404- return 0;405405-}406406-late_initcall(clk_disable_unused);407407-late_initcall(omap_clk_enable_autoidle_all);408408-#endif409409-410410-int __init clk_init(struct clk_functions * custom_clocks)411411-{412412- if (!custom_clocks) {413413- pr_err("No custom clock functions registered\n");414414- BUG();415415- }416416-417417- arch_clock = custom_clocks;418418-419419- return 0;420420-}421421-422422-#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)423423-/*424424- * debugfs support to trace clock tree hierarchy and attributes425425- */426426-427427-#include <linux/debugfs.h>428428-#include <linux/seq_file.h>429429-430430-static struct dentry *clk_debugfs_root;431431-432432-static int clk_dbg_show_summary(struct seq_file *s, void *unused)433433-{434434- struct clk *c;435435- struct clk *pa;436436-437437- mutex_lock(&clocks_mutex);438438- seq_printf(s, "%-30s %-30s %-10s %s\n",439439- "clock-name", "parent-name", "rate", "use-count");440440-441441- list_for_each_entry(c, &clocks, node) {442442- pa = c->parent;443443- seq_printf(s, "%-30s %-30s %-10lu %d\n",444444- c->name, pa ? pa->name : "none", c->rate, c->usecount);445445- }446446- mutex_unlock(&clocks_mutex);447447-448448- return 0;449449-}450450-451451-static int clk_dbg_open(struct inode *inode, struct file *file)452452-{453453- return single_open(file, clk_dbg_show_summary, inode->i_private);454454-}455455-456456-static const struct file_operations debug_clock_fops = {457457- .open = clk_dbg_open,458458- .read = seq_read,459459- .llseek = seq_lseek,460460- .release = single_release,461461-};462462-463463-static int clk_debugfs_register_one(struct clk *c)464464-{465465- int err;466466- struct dentry *d;467467- struct clk *pa = c->parent;468468-469469- d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);470470- if (!d)471471- return -ENOMEM;472472- c->dent = d;473473-474474- d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);475475- if (!d) {476476- err = -ENOMEM;477477- goto err_out;478478- }479479- d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);480480- if (!d) {481481- err = -ENOMEM;482482- goto err_out;483483- }484484- d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);485485- if (!d) {486486- err = -ENOMEM;487487- goto err_out;488488- }489489- return 0;490490-491491-err_out:492492- debugfs_remove_recursive(c->dent);493493- return err;494494-}495495-496496-static int clk_debugfs_register(struct clk *c)497497-{498498- int err;499499- struct clk *pa = c->parent;500500-501501- if (pa && !pa->dent) {502502- err = clk_debugfs_register(pa);503503- if (err)504504- return err;505505- }506506-507507- if (!c->dent) {508508- err = clk_debugfs_register_one(c);509509- if (err)510510- return err;511511- }512512- return 0;513513-}514514-515515-static int __init clk_debugfs_init(void)516516-{517517- struct clk *c;518518- struct dentry *d;519519- int err;520520-521521- d = debugfs_create_dir("clock", NULL);522522- if (!d)523523- return -ENOMEM;524524- clk_debugfs_root = d;525525-526526- list_for_each_entry(c, &clocks, node) {527527- err = clk_debugfs_register(c);528528- if (err)529529- goto err_out;530530- }531531-532532- d = debugfs_create_file("summary", S_IRUGO,533533- d, NULL, &debug_clock_fops);534534- if (!d)535535- return -ENOMEM;536536-537537- return 0;538538-err_out:539539- debugfs_remove_recursive(clk_debugfs_root);540540- return err;541541-}542542-late_initcall(clk_debugfs_init);543543-544544-#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
-48
arch/arm/plat-omap/common.c
···11-/*22- * linux/arch/arm/plat-omap/common.c33- *44- * Code common to all OMAP machines.55- * The file is created by Tony Lindgren <tony@atomide.com>66- *77- * Copyright (C) 2009 Texas Instruments88- * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>99- *1010- * This program is free software; you can redistribute it and/or modify1111- * it under the terms of the GNU General Public License version 2 as1212- * published by the Free Software Foundation.1313- */1414-#include <linux/kernel.h>1515-#include <linux/init.h>1616-#include <linux/io.h>1717-#include <linux/dma-mapping.h>1818-1919-#include <plat/common.h>2020-#include <plat/vram.h>2121-#include <linux/platform_data/dsp-omap.h>2222-#include <plat/dma.h>2323-2424-#include <plat/omap-secure.h>2525-2626-void __init omap_reserve(void)2727-{2828- omap_vram_reserve_sdram_memblock();2929- omap_dsp_reserve_sdram_memblock();3030- omap_secure_ram_reserve_memblock();3131- omap_barrier_reserve_memblock();3232-}3333-3434-void __init omap_init_consistent_dma_size(void)3535-{3636-#ifdef CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE3737- init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20);3838-#endif3939-}4040-4141-/*4242- * Stub function for OMAP2 so that common files4343- * continue to build when custom builds are used4444- */4545-int __weak omap_secure_ram_reserve_memblock(void)4646-{4747- return 0;4848-}
···1515#include <linux/io.h>1616#include <linux/smc91x.h>17171818-#include <mach/hardware.h>1919-#include "../mach-omap2/debug-devices.h"1818+#include <plat/debug-devices.h>20192120/* Many OMAP development platforms reuse the same "debug board"; these2221 * platforms include H2, H3, H4, and Perseus2.
+20-3
arch/arm/plat-omap/debug-leds.c
···1717#include <linux/platform_data/gpio-omap.h>1818#include <linux/slab.h>19192020-#include <mach/hardware.h>2120#include <asm/mach-types.h>2222-2323-#include <plat/fpga.h>24212522/* Many OMAP development platforms reuse the same "debug board"; these2623 * platforms include H2, H3, H4, and Perseus2. There are 16 LEDs on the2724 * debug board (all green), accessed through FPGA registers.2825 */2626+2727+/* NOTE: most boards don't have a static mapping for the FPGA ... */2828+struct h2p2_dbg_fpga {2929+ /* offset 0x00 */3030+ u16 smc91x[8];3131+ /* offset 0x10 */3232+ u16 fpga_rev;3333+ u16 board_rev;3434+ u16 gpio_outputs;3535+ u16 leds;3636+ /* offset 0x18 */3737+ u16 misc_inputs;3838+ u16 lan_status;3939+ u16 lan_reset;4040+ u16 reserved0;4141+ /* offset 0x20 */4242+ u16 ps2_data;4343+ u16 ps2_ctrl;4444+ /* plus also 4 rs232 ports ... */4545+};29463047static struct h2p2_dbg_fpga __iomem *fpga;3148
+69-67
arch/arm/plat-omap/dma.c
···3636#include <linux/slab.h>3737#include <linux/delay.h>38383939-#include <plat/cpu.h>4040-#include <plat/dma.h>4141-#include <plat/tc.h>3939+#include <plat-omap/dma-omap.h>42404341/*4442 * MAX_LOGICAL_DMA_CH_COUNT: the maximum number of logical DMA···173175#define omap_writel(val, reg) do {} while (0)174176#endif175177178178+#ifdef CONFIG_ARCH_OMAP1176179void omap_set_dma_priority(int lch, int dst_port, int priority)177180{178181 unsigned long reg;179182 u32 l;180183181181- if (cpu_class_is_omap1()) {184184+ if (dma_omap1()) {182185 switch (dst_port) {183186 case OMAP_DMA_PORT_OCP_T1: /* FFFECC00 */184187 reg = OMAP_TC_OCPT1_PRIOR;···202203 l |= (priority & 0xf) << 8;203204 omap_writel(l, reg);204205 }205205-206206- if (cpu_class_is_omap2()) {207207- u32 ccr;208208-209209- ccr = p->dma_read(CCR, lch);210210- if (priority)211211- ccr |= (1 << 6);212212- else213213- ccr &= ~(1 << 6);214214- p->dma_write(ccr, CCR, lch);215215- }216206}207207+#endif208208+209209+#ifdef CONFIG_ARCH_OMAP2PLUS210210+void omap_set_dma_priority(int lch, int dst_port, int priority)211211+{212212+ u32 ccr;213213+214214+ ccr = p->dma_read(CCR, lch);215215+ if (priority)216216+ ccr |= (1 << 6);217217+ else218218+ ccr &= ~(1 << 6);219219+ p->dma_write(ccr, CCR, lch);220220+}221221+#endif217222EXPORT_SYMBOL(omap_set_dma_priority);218223219224void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,···231228 l |= data_type;232229 p->dma_write(l, CSDP, lch);233230234234- if (cpu_class_is_omap1()) {231231+ if (dma_omap1()) {235232 u16 ccr;236233237234 ccr = p->dma_read(CCR, lch);···247244 p->dma_write(ccr, CCR2, lch);248245 }249246250250- if (cpu_class_is_omap2() && dma_trigger) {247247+ if (dma_omap2plus() && dma_trigger) {251248 u32 val;252249253250 val = p->dma_read(CCR, lch);···287284{288285 BUG_ON(omap_dma_in_1510_mode());289286290290- if (cpu_class_is_omap1()) {287287+ if (dma_omap1()) {291288 u16 w;292289293290 w = p->dma_read(CCR2, lch);···317314 p->dma_write(w, LCH_CTRL, lch);318315 }319316320320- if (cpu_class_is_omap2()) {317317+ if (dma_omap2plus()) {321318 u32 val;322319323320 val = p->dma_read(CCR, lch);···345342346343void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)347344{348348- if (cpu_class_is_omap2()) {345345+ if (dma_omap2plus()) {349346 u32 csdp;350347351348 csdp = p->dma_read(CSDP, lch);···358355359356void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode)360357{361361- if (cpu_class_is_omap1() && !cpu_is_omap15xx()) {358358+ if (dma_omap1() && !dma_omap15xx()) {362359 u32 l;363360364361 l = p->dma_read(LCH_CTRL, lch);···376373{377374 u32 l;378375379379- if (cpu_class_is_omap1()) {376376+ if (dma_omap1()) {380377 u16 w;381378382379 w = p->dma_read(CSDP, lch);···418415419416void omap_set_dma_src_index(int lch, int eidx, int fidx)420417{421421- if (cpu_class_is_omap2())418418+ if (dma_omap2plus())422419 return;423420424421 p->dma_write(eidx, CSEI, lch);···450447 case OMAP_DMA_DATA_BURST_DIS:451448 break;452449 case OMAP_DMA_DATA_BURST_4:453453- if (cpu_class_is_omap2())450450+ if (dma_omap2plus())454451 burst = 0x1;455452 else456453 burst = 0x2;457454 break;458455 case OMAP_DMA_DATA_BURST_8:459459- if (cpu_class_is_omap2()) {456456+ if (dma_omap2plus()) {460457 burst = 0x2;461458 break;462459 }···466463 * fall through467464 */468465 case OMAP_DMA_DATA_BURST_16:469469- if (cpu_class_is_omap2()) {466466+ if (dma_omap2plus()) {470467 burst = 0x3;471468 break;472469 }···490487{491488 u32 l;492489493493- if (cpu_class_is_omap1()) {490490+ if (dma_omap1()) {494491 l = p->dma_read(CSDP, lch);495492 l &= ~(0x1f << 9);496493 l |= dest_port << 9;···511508512509void omap_set_dma_dest_index(int lch, int eidx, int fidx)513510{514514- if (cpu_class_is_omap2())511511+ if (dma_omap2plus())515512 return;516513517514 p->dma_write(eidx, CDEI, lch);···543540 case OMAP_DMA_DATA_BURST_DIS:544541 break;545542 case OMAP_DMA_DATA_BURST_4:546546- if (cpu_class_is_omap2())543543+ if (dma_omap2plus())547544 burst = 0x1;548545 else549546 burst = 0x2;550547 break;551548 case OMAP_DMA_DATA_BURST_8:552552- if (cpu_class_is_omap2())549549+ if (dma_omap2plus())553550 burst = 0x2;554551 else555552 burst = 0x3;556553 break;557554 case OMAP_DMA_DATA_BURST_16:558558- if (cpu_class_is_omap2()) {555555+ if (dma_omap2plus()) {559556 burst = 0x3;560557 break;561558 }···576573static inline void omap_enable_channel_irq(int lch)577574{578575 /* Clear CSR */579579- if (cpu_class_is_omap1())576576+ if (dma_omap1())580577 p->dma_read(CSR, lch);581578 else582579 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);···590587 /* disable channel interrupts */591588 p->dma_write(0, CICR, lch);592589 /* Clear CSR */593593- if (cpu_class_is_omap1())590590+ if (dma_omap1())594591 p->dma_read(CSR, lch);595592 else596593 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);···614611615612 l = p->dma_read(CLNK_CTRL, lch);616613617617- if (cpu_class_is_omap1())614614+ if (dma_omap1())618615 l &= ~(1 << 14);619616620617 /* Set the ENABLE_LNK bits */···622619 l = dma_chan[lch].next_lch | (1 << 15);623620624621#ifndef CONFIG_ARCH_OMAP1625625- if (cpu_class_is_omap2())622622+ if (dma_omap2plus())626623 if (dma_chan[lch].next_linked_ch != -1)627624 l = dma_chan[lch].next_linked_ch | (1 << 15);628625#endif···639636 /* Disable interrupts */640637 omap_disable_channel_irq(lch);641638642642- if (cpu_class_is_omap1()) {639639+ if (dma_omap1()) {643640 /* Set the STOP_LNK bit */644641 l |= 1 << 14;645642 }646643647647- if (cpu_class_is_omap2()) {644644+ if (dma_omap2plus()) {648645 /* Clear the ENABLE_LNK bit */649646 l &= ~(1 << 15);650647 }···658655 u32 val;659656 unsigned long flags;660657661661- if (!cpu_class_is_omap2())658658+ if (dma_omap1())662659 return;663660664661 spin_lock_irqsave(&dma_chan_lock, flags);···676673 u32 val;677674 unsigned long flags;678675679679- if (!cpu_class_is_omap2())676676+ if (dma_omap1())680677 return;681678682679 spin_lock_irqsave(&dma_chan_lock, flags);···715712 if (p->clear_lch_regs)716713 p->clear_lch_regs(free_ch);717714718718- if (cpu_class_is_omap2())715715+ if (dma_omap2plus())719716 omap_clear_dma(free_ch);720717721718 spin_unlock_irqrestore(&dma_chan_lock, flags);···726723 chan->flags = 0;727724728725#ifndef CONFIG_ARCH_OMAP1729729- if (cpu_class_is_omap2()) {726726+ if (dma_omap2plus()) {730727 chan->chain_id = -1;731728 chan->next_linked_ch = -1;732729 }···734731735732 chan->enabled_irqs = OMAP_DMA_DROP_IRQ | OMAP_DMA_BLOCK_IRQ;736733737737- if (cpu_class_is_omap1())734734+ if (dma_omap1())738735 chan->enabled_irqs |= OMAP1_DMA_TOUT_IRQ;739739- else if (cpu_class_is_omap2())736736+ else if (dma_omap2plus())740737 chan->enabled_irqs |= OMAP2_DMA_MISALIGNED_ERR_IRQ |741738 OMAP2_DMA_TRANS_ERR_IRQ;742739743743- if (cpu_is_omap16xx()) {740740+ if (dma_omap16xx()) {744741 /* If the sync device is set, configure it dynamically. */745742 if (dev_id != 0) {746743 set_gdma_dev(free_ch + 1, dev_id);···751748 * id.752749 */753750 p->dma_write(dev_id | (1 << 10), CCR, free_ch);754754- } else if (cpu_is_omap7xx() || cpu_is_omap15xx()) {751751+ } else if (dma_omap1()) {755752 p->dma_write(dev_id, CCR, free_ch);756753 }757754758758- if (cpu_class_is_omap2()) {755755+ if (dma_omap2plus()) {759756 omap_enable_channel_irq(free_ch);760757 omap2_enable_irq_lch(free_ch);761758 }···777774 }778775779776 /* Disable interrupt for logical channel */780780- if (cpu_class_is_omap2())777777+ if (dma_omap2plus())781778 omap2_disable_irq_lch(lch);782779783780 /* Disable all DMA interrupts for the channel. */···787784 p->dma_write(0, CCR, lch);788785789786 /* Clear registers */790790- if (cpu_class_is_omap2())787787+ if (dma_omap2plus())791788 omap_clear_dma(lch);792789793790 spin_lock_irqsave(&dma_chan_lock, flags);···813810{814811 u32 reg;815812816816- if (!cpu_class_is_omap2()) {813813+ if (dma_omap1()) {817814 printk(KERN_ERR "FIXME: no %s on 15xx/16xx\n", __func__);818815 return;819816 }···852849 }853850 l = p->dma_read(CCR, lch);854851 l &= ~((1 << 6) | (1 << 26));855855- if (cpu_class_is_omap2() && !cpu_is_omap242x())852852+ if (d->dev_caps & IS_RW_PRIORITY)856853 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26);857854 else858855 l |= ((read_prio & 0x1) << 6);···885882 * The CPC/CDAC register needs to be initialized to zero886883 * before starting dma transfer.887884 */888888- if (cpu_is_omap15xx())885885+ if (dma_omap15xx())889886 p->dma_write(0, CPC, lch);890887 else891888 p->dma_write(0, CDAC, lch);···10481045{10491046 dma_addr_t offset = 0;1050104710511051- if (cpu_is_omap15xx())10481048+ if (dma_omap15xx())10521049 offset = p->dma_read(CPC, lch);10531050 else10541051 offset = p->dma_read(CSAC, lch);···10561053 if (IS_DMA_ERRATA(DMA_ERRATA_3_3) && offset == 0)10571054 offset = p->dma_read(CSAC, lch);1058105510591059- if (!cpu_is_omap15xx()) {10561056+ if (!dma_omap15xx()) {10601057 /*10611058 * CDAC == 0 indicates that the DMA transfer on the channel has10621059 * not been started (no data has been transferred so far).···10681065 offset = p->dma_read(CSSA, lch);10691066 }1070106710711071- if (cpu_class_is_omap1())10681068+ if (dma_omap1())10721069 offset |= (p->dma_read(CSSA, lch) & 0xFFFF0000);1073107010741071 return offset;···10871084{10881085 dma_addr_t offset = 0;1089108610901090- if (cpu_is_omap15xx())10871087+ if (dma_omap15xx())10911088 offset = p->dma_read(CPC, lch);10921089 else10931090 offset = p->dma_read(CDAC, lch);···10961093 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is10971094 * read before the DMA controller finished disabling the channel.10981095 */10991099- if (!cpu_is_omap15xx() && offset == 0) {10961096+ if (!dma_omap15xx() && offset == 0) {11001097 offset = p->dma_read(CDAC, lch);11011098 /*11021099 * CDAC == 0 indicates that the DMA transfer on the channel has···11071104 offset = p->dma_read(CDSA, lch);11081105 }1109110611101110- if (cpu_class_is_omap1())11071107+ if (dma_omap1())11111108 offset |= (p->dma_read(CDSA, lch) & 0xFFFF0000);1112110911131110 return offset;···11241121{11251122 int lch;1126112311271127- if (cpu_class_is_omap1())11241124+ if (dma_omap1())11281125 if (omap_lcd_dma_running())11291126 return 1;11301127···20272024 dma_chan = d->chan;20282025 enable_1510_mode = d->dev_caps & ENABLE_1510_MODE;2029202620302030- if (cpu_class_is_omap2()) {20272027+ if (dma_omap2plus()) {20312028 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) *20322029 dma_lch_count, GFP_KERNEL);20332030 if (!dma_linked_lch) {···20392036 spin_lock_init(&dma_chan_lock);20402037 for (ch = 0; ch < dma_chan_count; ch++) {20412038 omap_clear_dma(ch);20422042- if (cpu_class_is_omap2())20392039+ if (dma_omap2plus())20432040 omap2_disable_irq_lch(ch);2044204120452042 dma_chan[ch].dev_id = -1;···20482045 if (ch >= 6 && enable_1510_mode)20492046 continue;2050204720512051- if (cpu_class_is_omap1()) {20482048+ if (dma_omap1()) {20522049 /*20532050 * request_irq() doesn't like dev_id (ie. ch) being20542051 * zero, so we have to kludge around this.···20732070 }20742071 }2075207220762076- if (cpu_class_is_omap2() && !cpu_is_omap242x())20732073+ if (d->dev_caps & IS_RW_PRIORITY)20772074 omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE,20782075 DMA_DEFAULT_FIFO_DEPTH, 0);2079207620802080- if (cpu_class_is_omap2()) {20772077+ if (dma_omap2plus()) {20812078 strcpy(irq_name, "0");20822079 dma_irq = platform_get_irq_byname(pdev, irq_name);20832080 if (dma_irq < 0) {···20922089 }20932090 }2094209120952095- /* reserve dma channels 0 and 1 in high security devices */20962096- if (cpu_is_omap34xx() &&20972097- (omap_type() != OMAP2_DEVICE_TYPE_GP)) {20922092+ /* reserve dma channels 0 and 1 in high security devices on 34xx */20932093+ if (d->dev_caps & HS_CHANNELS_RESERVED) {20982094 pr_info("Reserving DMA channels 0 and 1 for HS ROM code\n");20992095 dma_chan[0].dev_id = 0;21002096 dma_chan[1].dev_id = 1;···21202118{21212119 int dma_irq;2122212021232123- if (cpu_class_is_omap2()) {21212121+ if (dma_omap2plus()) {21242122 char irq_name[4];21252123 strcpy(irq_name, "0");21262124 dma_irq = platform_get_irq_byname(pdev, irq_name);
+11-9
arch/arm/plat-omap/dmtimer.c
···4242#include <linux/pm_runtime.h>43434444#include <plat/dmtimer.h>4545-#include <plat/omap-pm.h>4646-4747-#include <mach/hardware.h>48454946static u32 omap_reserved_systimers;5047static LIST_HEAD(omap_timer_list);···268271EXPORT_SYMBOL_GPL(omap_dm_timer_get_irq);269272270273#if defined(CONFIG_ARCH_OMAP1)271271-274274+#include <mach/hardware.h>272275/**273276 * omap_dm_timer_modify_idlect_mask - Check if any running timers use ARMXOR274277 * @inputmask: current value of idlect mask···345348 omap_dm_timer_enable(timer);346349347350 if (!(timer->capability & OMAP_TIMER_ALWON)) {348348- if (omap_pm_get_dev_context_loss_count(&timer->pdev->dev) !=351351+ if (timer->get_context_loss_count &&352352+ timer->get_context_loss_count(&timer->pdev->dev) !=349353 timer->ctx_loss_count)350354 omap_timer_restore_context(timer);351355 }···375377376378 __omap_dm_timer_stop(timer, timer->posted, rate);377379378378- if (!(timer->capability & OMAP_TIMER_ALWON))379379- timer->ctx_loss_count =380380- omap_pm_get_dev_context_loss_count(&timer->pdev->dev);380380+ if (!(timer->capability & OMAP_TIMER_ALWON)) {381381+ if (timer->get_context_loss_count)382382+ timer->ctx_loss_count =383383+ timer->get_context_loss_count(&timer->pdev->dev);384384+ }381385382386 /*383387 * Since the register values are computed and written within···495495 omap_dm_timer_enable(timer);496496497497 if (!(timer->capability & OMAP_TIMER_ALWON)) {498498- if (omap_pm_get_dev_context_loss_count(&timer->pdev->dev) !=498498+ if (timer->get_context_loss_count &&499499+ timer->get_context_loss_count(&timer->pdev->dev) !=499500 timer->ctx_loss_count)500501 omap_timer_restore_context(timer);501502 }···730729 timer->reserved = omap_dm_timer_reserved_systimer(timer->id);731730 timer->pdev = pdev;732731 timer->capability = pdata->timer_capability;732732+ timer->get_context_loss_count = pdata->get_context_loss_count;733733734734 /* Skip pm_runtime_enable for OMAP1 */735735 if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) {
+61-1
arch/arm/plat-omap/fb.c
···3030#include <linux/io.h>3131#include <linux/omapfb.h>32323333-#include <mach/hardware.h>3433#include <asm/mach/map.h>3434+3535+#include <plat/cpu.h>3636+3737+#ifdef CONFIG_OMAP2_VRFB3838+3939+/*4040+ * The first memory resource is the register region for VRFB,4141+ * the rest are VRFB virtual memory areas for each VRFB context.4242+ */4343+4444+static const struct resource omap2_vrfb_resources[] = {4545+ DEFINE_RES_MEM_NAMED(0x68008000u, 0x40, "vrfb-regs"),4646+ DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),4747+ DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),4848+ DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),4949+ DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),5050+};5151+5252+static const struct resource omap3_vrfb_resources[] = {5353+ DEFINE_RES_MEM_NAMED(0x6C000180u, 0xc0, "vrfb-regs"),5454+ DEFINE_RES_MEM_NAMED(0x70000000u, 0x4000000, "vrfb-area-0"),5555+ DEFINE_RES_MEM_NAMED(0x74000000u, 0x4000000, "vrfb-area-1"),5656+ DEFINE_RES_MEM_NAMED(0x78000000u, 0x4000000, "vrfb-area-2"),5757+ DEFINE_RES_MEM_NAMED(0x7c000000u, 0x4000000, "vrfb-area-3"),5858+ DEFINE_RES_MEM_NAMED(0xe0000000u, 0x4000000, "vrfb-area-4"),5959+ DEFINE_RES_MEM_NAMED(0xe4000000u, 0x4000000, "vrfb-area-5"),6060+ DEFINE_RES_MEM_NAMED(0xe8000000u, 0x4000000, "vrfb-area-6"),6161+ DEFINE_RES_MEM_NAMED(0xec000000u, 0x4000000, "vrfb-area-7"),6262+ DEFINE_RES_MEM_NAMED(0xf0000000u, 0x4000000, "vrfb-area-8"),6363+ DEFINE_RES_MEM_NAMED(0xf4000000u, 0x4000000, "vrfb-area-9"),6464+ DEFINE_RES_MEM_NAMED(0xf8000000u, 0x4000000, "vrfb-area-10"),6565+ DEFINE_RES_MEM_NAMED(0xfc000000u, 0x4000000, "vrfb-area-11"),6666+};6767+6868+static int __init omap_init_vrfb(void)6969+{7070+ struct platform_device *pdev;7171+ const struct resource *res;7272+ unsigned int num_res;7373+7474+ if (cpu_is_omap24xx()) {7575+ res = omap2_vrfb_resources;7676+ num_res = ARRAY_SIZE(omap2_vrfb_resources);7777+ } else if (cpu_is_omap34xx()) {7878+ res = omap3_vrfb_resources;7979+ num_res = ARRAY_SIZE(omap3_vrfb_resources);8080+ } else {8181+ return 0;8282+ }8383+8484+ pdev = platform_device_register_resndata(NULL, "omapvrfb", -1,8585+ res, num_res, NULL, 0);8686+8787+ if (IS_ERR(pdev))8888+ return PTR_ERR(pdev);8989+ else9090+ return 0;9191+}9292+9393+arch_initcall(omap_init_vrfb);9494+#endif35953696#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)3797
+6-149
arch/arm/plat-omap/i2c.c
···2626#include <linux/kernel.h>2727#include <linux/platform_device.h>2828#include <linux/i2c.h>2929+#include <linux/i2c-omap.h>2930#include <linux/slab.h>3031#include <linux/err.h>3132#include <linux/clk.h>32333333-#include <mach/irqs.h>3434#include <plat/i2c.h>3535-#include <plat/omap_device.h>36353737-#define OMAP_I2C_SIZE 0x3f3838-#define OMAP1_I2C_BASE 0xfffb38003939-#define OMAP1_INT_I2C (32 + 4)4040-4141-static const char name[] = "omap_i2c";4242-4343-#define I2C_RESOURCE_BUILDER(base, irq) \4444- { \4545- .start = (base), \4646- .end = (base) + OMAP_I2C_SIZE, \4747- .flags = IORESOURCE_MEM, \4848- }, \4949- { \5050- .start = (irq), \5151- .flags = IORESOURCE_IRQ, \5252- },5353-5454-static struct resource i2c_resources[][2] = {5555- { I2C_RESOURCE_BUILDER(0, 0) },5656-};5757-5858-#define I2C_DEV_BUILDER(bus_id, res, data) \5959- { \6060- .id = (bus_id), \6161- .name = name, \6262- .num_resources = ARRAY_SIZE(res), \6363- .resource = (res), \6464- .dev = { \6565- .platform_data = (data), \6666- }, \6767- }6868-6969-#define MAX_OMAP_I2C_HWMOD_NAME_LEN 167036#define OMAP_I2C_MAX_CONTROLLERS 47137static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS];7272-static struct platform_device omap_i2c_devices[] = {7373- I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_pdata[0]),7474-};75387639#define OMAP_I2C_CMDLINE_SETUP (BIT(31))7777-7878-static int __init omap_i2c_nr_ports(void)7979-{8080- int ports = 0;8181-8282- if (cpu_class_is_omap1())8383- ports = 1;8484- else if (cpu_is_omap24xx())8585- ports = 2;8686- else if (cpu_is_omap34xx())8787- ports = 3;8888- else if (cpu_is_omap44xx())8989- ports = 4;9090-9191- return ports;9292-}9393-9494-static inline int omap1_i2c_add_bus(int bus_id)9595-{9696- struct platform_device *pdev;9797- struct omap_i2c_bus_platform_data *pdata;9898- struct resource *res;9999-100100- omap1_i2c_mux_pins(bus_id);101101-102102- pdev = &omap_i2c_devices[bus_id - 1];103103- res = pdev->resource;104104- res[0].start = OMAP1_I2C_BASE;105105- res[0].end = res[0].start + OMAP_I2C_SIZE;106106- res[1].start = OMAP1_INT_I2C;107107- pdata = &i2c_pdata[bus_id - 1];108108-109109- /* all OMAP1 have IP version 1 register set */110110- pdata->rev = OMAP_I2C_IP_VERSION_1;111111-112112- /* all OMAP1 I2C are implemented like this */113113- pdata->flags = OMAP_I2C_FLAG_NO_FIFO |114114- OMAP_I2C_FLAG_SIMPLE_CLOCK |115115- OMAP_I2C_FLAG_16BIT_DATA_REG |116116- OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK;117117-118118- /* how the cpu bus is wired up differs for 7xx only */119119-120120- if (cpu_is_omap7xx())121121- pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_1;122122- else123123- pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_2;124124-125125- return platform_device_register(pdev);126126-}127127-128128-129129-#ifdef CONFIG_ARCH_OMAP2PLUS130130-static inline int omap2_i2c_add_bus(int bus_id)131131-{132132- int l;133133- struct omap_hwmod *oh;134134- struct platform_device *pdev;135135- char oh_name[MAX_OMAP_I2C_HWMOD_NAME_LEN];136136- struct omap_i2c_bus_platform_data *pdata;137137- struct omap_i2c_dev_attr *dev_attr;138138-139139- omap2_i2c_mux_pins(bus_id);140140-141141- l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);142142- WARN(l >= MAX_OMAP_I2C_HWMOD_NAME_LEN,143143- "String buffer overflow in I2C%d device setup\n", bus_id);144144- oh = omap_hwmod_lookup(oh_name);145145- if (!oh) {146146- pr_err("Could not look up %s\n", oh_name);147147- return -EEXIST;148148- }149149-150150- pdata = &i2c_pdata[bus_id - 1];151151- /*152152- * pass the hwmod class's CPU-specific knowledge of I2C IP revision in153153- * use, and functionality implementation flags, up to the OMAP I2C154154- * driver via platform data155155- */156156- pdata->rev = oh->class->rev;157157-158158- dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;159159- pdata->flags = dev_attr->flags;160160-161161- pdev = omap_device_build(name, bus_id, oh, pdata,162162- sizeof(struct omap_i2c_bus_platform_data),163163- NULL, 0, 0);164164- WARN(IS_ERR(pdev), "Could not build omap_device for %s\n", name);165165-166166- return PTR_RET(pdev);167167-}168168-#else169169-static inline int omap2_i2c_add_bus(int bus_id)170170-{171171- return 0;172172-}173173-#endif174174-175175-static int __init omap_i2c_add_bus(int bus_id)176176-{177177- if (cpu_class_is_omap1())178178- return omap1_i2c_add_bus(bus_id);179179- else180180- return omap2_i2c_add_bus(bus_id);181181-}1824018341/**18442 * omap_i2c_bus_setup - Process command line options for the I2C bus speed···51193 */52194static int __init omap_i2c_bus_setup(char *str)53195{5454- int ports;55196 int ints[3];561975757- ports = omap_i2c_nr_ports();58198 get_options(str, 3, ints);5959- if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)199199+ if (ints[0] < 2 || ints[1] < 1 ||200200+ ints[1] > OMAP_I2C_MAX_CONTROLLERS)60201 return 0;61202 i2c_pdata[ints[1] - 1].clkrate = ints[2];62203 i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP;···75218 for (i = 0; i < ARRAY_SIZE(i2c_pdata); i++)76219 if (i2c_pdata[i].clkrate & OMAP_I2C_CMDLINE_SETUP) {77220 i2c_pdata[i].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;7878- err = omap_i2c_add_bus(i + 1);221221+ err = omap_i2c_add_bus(&i2c_pdata[i], i + 1);79222 if (err)80223 goto out;81224 }···100243{101244 int err;102245103103- BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());246246+ BUG_ON(bus_id < 1 || bus_id > OMAP_I2C_MAX_CONTROLLERS);104247105248 if (info) {106249 err = i2c_register_board_info(bus_id, info, len);···113256114257 i2c_pdata[bus_id - 1].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;115258116116- return omap_i2c_add_bus(bus_id);259259+ return omap_i2c_add_bus(&i2c_pdata[bus_id - 1], bus_id);117260}
···11-/*22- * OMAP clock: data structure definitions, function prototypes, shared macros33- *44- * Copyright (C) 2004-2005, 2008-2010 Nokia Corporation55- * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>66- * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc77- *88- * This program is free software; you can redistribute it and/or modify99- * it under the terms of the GNU General Public License version 2 as1010- * published by the Free Software Foundation.1111- */1212-1313-#ifndef __ARCH_ARM_OMAP_CLOCK_H1414-#define __ARCH_ARM_OMAP_CLOCK_H1515-1616-#include <linux/list.h>1717-1818-struct module;1919-struct clk;2020-struct clockdomain;2121-2222-/* Temporary, needed during the common clock framework conversion */2323-#define __clk_get_name(clk) (clk->name)2424-#define __clk_get_parent(clk) (clk->parent)2525-#define __clk_get_rate(clk) (clk->rate)2626-2727-/**2828- * struct clkops - some clock function pointers2929- * @enable: fn ptr that enables the current clock in hardware3030- * @disable: fn ptr that enables the current clock in hardware3131- * @find_idlest: function returning the IDLEST register for the clock's IP blk3232- * @find_companion: function returning the "companion" clk reg for the clock3333- * @allow_idle: fn ptr that enables autoidle for the current clock in hardware3434- * @deny_idle: fn ptr that disables autoidle for the current clock in hardware3535- *3636- * A "companion" clk is an accompanying clock to the one being queried3737- * that must be enabled for the IP module connected to the clock to3838- * become accessible by the hardware. Neither @find_idlest nor3939- * @find_companion should be needed; that information is IP4040- * block-specific; the hwmod code has been created to handle this, but4141- * until hwmod data is ready and drivers have been converted to use PM4242- * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and4343- * @find_companion must, unfortunately, remain.4444- */4545-struct clkops {4646- int (*enable)(struct clk *);4747- void (*disable)(struct clk *);4848- void (*find_idlest)(struct clk *, void __iomem **,4949- u8 *, u8 *);5050- void (*find_companion)(struct clk *, void __iomem **,5151- u8 *);5252- void (*allow_idle)(struct clk *);5353- void (*deny_idle)(struct clk *);5454-};5555-5656-#ifdef CONFIG_ARCH_OMAP2PLUS5757-5858-/* struct clksel_rate.flags possibilities */5959-#define RATE_IN_242X (1 << 0)6060-#define RATE_IN_243X (1 << 1)6161-#define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */6262-#define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */6363-#define RATE_IN_36XX (1 << 4)6464-#define RATE_IN_4430 (1 << 5)6565-#define RATE_IN_TI816X (1 << 6)6666-#define RATE_IN_4460 (1 << 7)6767-#define RATE_IN_AM33XX (1 << 8)6868-#define RATE_IN_TI814X (1 << 9)6969-7070-#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)7171-#define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)7272-#define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX)7373-#define RATE_IN_44XX (RATE_IN_4430 | RATE_IN_4460)7474-7575-/* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */7676-#define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX)7777-7878-7979-/**8080- * struct clksel_rate - register bitfield values corresponding to clk divisors8181- * @val: register bitfield value (shifted to bit 0)8282- * @div: clock divisor corresponding to @val8383- * @flags: (see "struct clksel_rate.flags possibilities" above)8484- *8585- * @val should match the value of a read from struct clk.clksel_reg8686- * AND'ed with struct clk.clksel_mask, shifted right to bit 0.8787- *8888- * @div is the divisor that should be applied to the parent clock's rate8989- * to produce the current clock's rate.9090- */9191-struct clksel_rate {9292- u32 val;9393- u8 div;9494- u16 flags;9595-};9696-9797-/**9898- * struct clksel - available parent clocks, and a pointer to their divisors9999- * @parent: struct clk * to a possible parent clock100100- * @rates: available divisors for this parent clock101101- *102102- * A struct clksel is always associated with one or more struct clks103103- * and one or more struct clksel_rates.104104- */105105-struct clksel {106106- struct clk *parent;107107- const struct clksel_rate *rates;108108-};109109-110110-/**111111- * struct dpll_data - DPLL registers and integration data112112- * @mult_div1_reg: register containing the DPLL M and N bitfields113113- * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg114114- * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg115115- * @clk_bypass: struct clk pointer to the clock's bypass clock input116116- * @clk_ref: struct clk pointer to the clock's reference clock input117117- * @control_reg: register containing the DPLL mode bitfield118118- * @enable_mask: mask of the DPLL mode bitfield in @control_reg119119- * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()120120- * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()121121- * @max_multiplier: maximum valid non-bypass multiplier value (actual)122122- * @last_rounded_n: cache of the last N result of omap2_dpll_round_rate()123123- * @min_divider: minimum valid non-bypass divider value (actual)124124- * @max_divider: maximum valid non-bypass divider value (actual)125125- * @modes: possible values of @enable_mask126126- * @autoidle_reg: register containing the DPLL autoidle mode bitfield127127- * @idlest_reg: register containing the DPLL idle status bitfield128128- * @autoidle_mask: mask of the DPLL autoidle mode bitfield in @autoidle_reg129129- * @freqsel_mask: mask of the DPLL jitter correction bitfield in @control_reg130130- * @idlest_mask: mask of the DPLL idle status bitfield in @idlest_reg131131- * @auto_recal_bit: bitshift of the driftguard enable bit in @control_reg132132- * @recal_en_bit: bitshift of the PRM_IRQENABLE_* bit for recalibration IRQs133133- * @recal_st_bit: bitshift of the PRM_IRQSTATUS_* bit for recalibration IRQs134134- * @flags: DPLL type/features (see below)135135- *136136- * Possible values for @flags:137137- * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs)138138- *139139- * @freqsel_mask is only used on the OMAP34xx family and AM35xx.140140- *141141- * XXX Some DPLLs have multiple bypass inputs, so it's not technically142142- * correct to only have one @clk_bypass pointer.143143- *144144- * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m,145145- * @last_rounded_n) should be separated from the runtime-fixed fields146146- * and placed into a different structure, so that the runtime-fixed data147147- * can be placed into read-only space.148148- */149149-struct dpll_data {150150- void __iomem *mult_div1_reg;151151- u32 mult_mask;152152- u32 div1_mask;153153- struct clk *clk_bypass;154154- struct clk *clk_ref;155155- void __iomem *control_reg;156156- u32 enable_mask;157157- unsigned long last_rounded_rate;158158- u16 last_rounded_m;159159- u16 max_multiplier;160160- u8 last_rounded_n;161161- u8 min_divider;162162- u16 max_divider;163163- u8 modes;164164- void __iomem *autoidle_reg;165165- void __iomem *idlest_reg;166166- u32 autoidle_mask;167167- u32 freqsel_mask;168168- u32 idlest_mask;169169- u32 dco_mask;170170- u32 sddiv_mask;171171- u8 auto_recal_bit;172172- u8 recal_en_bit;173173- u8 recal_st_bit;174174- u8 flags;175175-};176176-177177-#endif178178-179179-/*180180- * struct clk.flags possibilities181181- *182182- * XXX document the rest of the clock flags here183183- *184184- * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL185185- * bits share the same register. This flag allows the186186- * omap4_dpllmx*() code to determine which GATE_CTRL bit field187187- * should be used. This is a temporary solution - a better approach188188- * would be to associate clock type-specific data with the clock,189189- * similar to the struct dpll_data approach.190190- */191191-#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */192192-#define CLOCK_IDLE_CONTROL (1 << 1)193193-#define CLOCK_NO_IDLE_PARENT (1 << 2)194194-#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */195195-#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */196196-#define CLOCK_CLKOUTX2 (1 << 5)197197-198198-/**199199- * struct clk - OMAP struct clk200200- * @node: list_head connecting this clock into the full clock list201201- * @ops: struct clkops * for this clock202202- * @name: the name of the clock in the hardware (used in hwmod data and debug)203203- * @parent: pointer to this clock's parent struct clk204204- * @children: list_head connecting to the child clks' @sibling list_heads205205- * @sibling: list_head connecting this clk to its parent clk's @children206206- * @rate: current clock rate207207- * @enable_reg: register to write to enable the clock (see @enable_bit)208208- * @recalc: fn ptr that returns the clock's current rate209209- * @set_rate: fn ptr that can change the clock's current rate210210- * @round_rate: fn ptr that can round the clock's current rate211211- * @init: fn ptr to do clock-specific initialization212212- * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)213213- * @usecount: number of users that have requested this clock to be enabled214214- * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div215215- * @flags: see "struct clk.flags possibilities" above216216- * @clksel_reg: for clksel clks, register va containing src/divisor select217217- * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector218218- * @clksel: for clksel clks, pointer to struct clksel for this clock219219- * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock220220- * @clkdm_name: clockdomain name that this clock is contained in221221- * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime222222- * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)223223- * @src_offset: bitshift for source selection bitfield (OMAP1 only)224224- *225225- * XXX @rate_offset, @src_offset should probably be removed and OMAP1226226- * clock code converted to use clksel.227227- *228228- * XXX @usecount is poorly named. It should be "enable_count" or229229- * something similar. "users" in the description refers to kernel230230- * code (core code or drivers) that have called clk_enable() and not231231- * yet called clk_disable(); the usecount of parent clocks is also232232- * incremented by the clock code when clk_enable() is called on child233233- * clocks and decremented by the clock code when clk_disable() is234234- * called on child clocks.235235- *236236- * XXX @clkdm, @usecount, @children, @sibling should be marked for237237- * internal use only.238238- *239239- * @children and @sibling are used to optimize parent-to-child clock240240- * tree traversals. (child-to-parent traversals use @parent.)241241- *242242- * XXX The notion of the clock's current rate probably needs to be243243- * separated from the clock's target rate.244244- */245245-struct clk {246246- struct list_head node;247247- const struct clkops *ops;248248- const char *name;249249- struct clk *parent;250250- struct list_head children;251251- struct list_head sibling; /* node for children */252252- unsigned long rate;253253- void __iomem *enable_reg;254254- unsigned long (*recalc)(struct clk *);255255- int (*set_rate)(struct clk *, unsigned long);256256- long (*round_rate)(struct clk *, unsigned long);257257- void (*init)(struct clk *);258258- u8 enable_bit;259259- s8 usecount;260260- u8 fixed_div;261261- u8 flags;262262-#ifdef CONFIG_ARCH_OMAP2PLUS263263- void __iomem *clksel_reg;264264- u32 clksel_mask;265265- const struct clksel *clksel;266266- struct dpll_data *dpll_data;267267- const char *clkdm_name;268268- struct clockdomain *clkdm;269269-#else270270- u8 rate_offset;271271- u8 src_offset;272272-#endif273273-#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)274274- struct dentry *dent; /* For visible tree hierarchy */275275-#endif276276-};277277-278278-struct clk_functions {279279- int (*clk_enable)(struct clk *clk);280280- void (*clk_disable)(struct clk *clk);281281- long (*clk_round_rate)(struct clk *clk, unsigned long rate);282282- int (*clk_set_rate)(struct clk *clk, unsigned long rate);283283- int (*clk_set_parent)(struct clk *clk, struct clk *parent);284284- void (*clk_allow_idle)(struct clk *clk);285285- void (*clk_deny_idle)(struct clk *clk);286286- void (*clk_disable_unused)(struct clk *clk);287287-};288288-289289-extern int mpurate;290290-291291-extern int clk_init(struct clk_functions *custom_clocks);292292-extern void clk_preinit(struct clk *clk);293293-extern int clk_register(struct clk *clk);294294-extern void clk_reparent(struct clk *child, struct clk *parent);295295-extern void clk_unregister(struct clk *clk);296296-extern void propagate_rate(struct clk *clk);297297-extern void recalculate_root_clocks(void);298298-extern unsigned long followparent_recalc(struct clk *clk);299299-extern void clk_enable_init_clocks(void);300300-unsigned long omap_fixed_divisor_recalc(struct clk *clk);301301-extern struct clk *omap_clk_get_by_name(const char *name);302302-extern int omap_clk_enable_autoidle_all(void);303303-extern int omap_clk_disable_autoidle_all(void);304304-305305-extern const struct clkops clkops_null;306306-307307-extern struct clk dummy_ck;308308-309309-#endif
-42
arch/arm/plat-omap/include/plat/common.h
···11-/*22- * arch/arm/plat-omap/include/mach/common.h33- *44- * Header for code common to all OMAP machines.55- *66- * This program is free software; you can redistribute it and/or modify it77- * under the terms of the GNU General Public License as published by the88- * Free Software Foundation; either version 2 of the License, or (at your99- * option) any later version.1010- *1111- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED1212- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF1313- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN1414- * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,1515- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT1616- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF1717- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON1818- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT1919- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF2020- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2121- *2222- * You should have received a copy of the GNU General Public License along2323- * with this program; if not, write to the Free Software Foundation, Inc.,2424- * 675 Mass Ave, Cambridge, MA 02139, USA.2525- */2626-2727-#ifndef __ARCH_ARM_MACH_OMAP_COMMON_H2828-#define __ARCH_ARM_MACH_OMAP_COMMON_H2929-3030-#include <plat/i2c.h>3131-#include <plat/omap_hwmod.h>3232-3333-extern int __init omap_init_clocksource_32k(void __iomem *vbase);3434-3535-extern void __init omap_check_revision(void);3636-3737-extern void omap_reserve(void);3838-extern int omap_dss_reset(struct omap_hwmod *);3939-4040-void omap_sram_init(void);4141-4242-#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
···9494 /* set_timer_src - Only used for OMAP1 devices */9595 int (*set_timer_src)(struct platform_device *pdev, int source);9696 u32 timer_capability;9797+ int (*get_context_loss_count)(struct device *);9798};989999100int omap_dm_timer_reserve_systimer(int id);···264263 unsigned reserved:1;265264 unsigned posted:1;266265 struct timer_regs context;266266+ int (*get_context_loss_count)(struct device *);267267 int ctx_loss_count;268268 int revision;269269 u32 capability;
···88 * published by the Free Software Foundation.99 */10101111-#ifndef __OMAP2_MMC_H1212-#define __OMAP2_MMC_H1313-1414-#include <linux/types.h>1515-#include <linux/device.h>1616-#include <linux/mmc/host.h>1717-1818-#include <plat/omap_hwmod.h>1919-2020-#define OMAP15XX_NR_MMC 12121-#define OMAP16XX_NR_MMC 22222-#define OMAP1_MMC_SIZE 0x0802323-#define OMAP1_MMC1_BASE 0xfffb78002424-#define OMAP1_MMC2_BASE 0xfffb7c00 /* omap16xx only */2525-2626-#define OMAP24XX_NR_MMC 22727-#define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE2828-#define OMAP2_MMC1_BASE 0x4809c0002929-3030-#define OMAP4_MMC_REG_OFFSET 0x1003131-3211#define OMAP_MMC_MAX_SLOTS 233123413/*···2849 */2950#define OMAP_HSMMC_SUPPORTS_DUAL_VOLT BIT(0)3051#define OMAP_HSMMC_BROKEN_MULTIBLOCK_READ BIT(1)5252+5353+struct mmc_card;31543255struct omap_mmc_dev_attr {3356 u8 flags;···107126 /* we can put the features above into this variable */108127#define HSMMC_HAS_PBIAS (1 << 0)109128#define HSMMC_HAS_UPDATED_RESET (1 << 1)129129+#define MMC_OMAP7XX (1 << 2)130130+#define MMC_OMAP15XX (1 << 3)131131+#define MMC_OMAP16XX (1 << 4)110132 unsigned features;111133112134 int switch_pin; /* gpio (card detect) */···148164149165 } slots[OMAP_MMC_MAX_SLOTS];150166};151151-152152-/* called from board-specific card detection service routine */153153-extern void omap_mmc_notify_cover_event(struct device *dev, int slot,154154- int is_closed);155155-156156-#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)157157-void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,158158- int nr_controllers);159159-void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data);160160-#else161161-static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,162162- int nr_controllers)163163-{164164-}165165-static inline void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)166166-{167167-}168168-#endif169169-170170-extern int omap_msdi_reset(struct omap_hwmod *oh);171171-172172-#endif
-120
arch/arm/plat-omap/include/plat/multi.h
···11-/*22- * Support for compiling in multiple OMAP processors33- *44- * Copyright (C) 2010 Nokia Corporation55- *66- * This program is free software; you can redistribute it and/or modify77- * it under the terms of the GNU General Public License as published by88- * the Free Software Foundation; either version 2 of the License, or99- * (at your option) any later version.1010- *1111- * This program is distributed in the hope that it will be useful,1212- * but WITHOUT ANY WARRANTY; without even the implied warranty of1313- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414- * GNU General Public License for more details.1515- *1616- * You should have received a copy of the GNU General Public License1717- * along with this program; if not, write to the Free Software1818- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1919- *2020- */2121-2222-#ifndef __PLAT_OMAP_MULTI_H2323-#define __PLAT_OMAP_MULTI_H2424-2525-/*2626- * Test if multicore OMAP support is needed2727- */2828-#undef MULTI_OMAP12929-#undef MULTI_OMAP23030-#undef OMAP_NAME3131-3232-#ifdef CONFIG_ARCH_OMAP7303333-# ifdef OMAP_NAME3434-# undef MULTI_OMAP13535-# define MULTI_OMAP13636-# else3737-# define OMAP_NAME omap7303838-# endif3939-#endif4040-#ifdef CONFIG_ARCH_OMAP8504141-# ifdef OMAP_NAME4242-# undef MULTI_OMAP14343-# define MULTI_OMAP14444-# else4545-# define OMAP_NAME omap8504646-# endif4747-#endif4848-#ifdef CONFIG_ARCH_OMAP15XX4949-# ifdef OMAP_NAME5050-# undef MULTI_OMAP15151-# define MULTI_OMAP15252-# else5353-# define OMAP_NAME omap15105454-# endif5555-#endif5656-#ifdef CONFIG_ARCH_OMAP16XX5757-# ifdef OMAP_NAME5858-# undef MULTI_OMAP15959-# define MULTI_OMAP16060-# else6161-# define OMAP_NAME omap16xx6262-# endif6363-#endif6464-#ifdef CONFIG_ARCH_OMAP2PLUS6565-# if (defined(OMAP_NAME) || defined(MULTI_OMAP1))6666-# error "OMAP1 and OMAP2PLUS can't be selected at the same time"6767-# endif6868-#endif6969-#ifdef CONFIG_SOC_OMAP24207070-# ifdef OMAP_NAME7171-# undef MULTI_OMAP27272-# define MULTI_OMAP27373-# else7474-# define OMAP_NAME omap24207575-# endif7676-#endif7777-#ifdef CONFIG_SOC_OMAP24307878-# ifdef OMAP_NAME7979-# undef MULTI_OMAP28080-# define MULTI_OMAP28181-# else8282-# define OMAP_NAME omap24308383-# endif8484-#endif8585-#ifdef CONFIG_ARCH_OMAP38686-# ifdef OMAP_NAME8787-# undef MULTI_OMAP28888-# define MULTI_OMAP28989-# else9090-# define OMAP_NAME omap39191-# endif9292-#endif9393-#ifdef CONFIG_ARCH_OMAP49494-# ifdef OMAP_NAME9595-# undef MULTI_OMAP29696-# define MULTI_OMAP29797-# else9898-# define OMAP_NAME omap49999-# endif100100-#endif101101-102102-#ifdef CONFIG_SOC_OMAP5103103-# ifdef OMAP_NAME104104-# undef MULTI_OMAP2105105-# define MULTI_OMAP2106106-# else107107-# define OMAP_NAME omap5108108-# endif109109-#endif110110-111111-#ifdef CONFIG_SOC_AM33XX112112-# ifdef OMAP_NAME113113-# undef MULTI_OMAP2114114-# define MULTI_OMAP2115115-# else116116-# define OMAP_NAME am33xx117117-# endif118118-#endif119119-120120-#endif /* __PLAT_OMAP_MULTI_H */
···11-#ifndef ____ASM_ARCH_SDRC_H22-#define ____ASM_ARCH_SDRC_H33-44-/*55- * OMAP2/3 SDRC/SMS register definitions66- *77- * Copyright (C) 2007-2008 Texas Instruments, Inc.88- * Copyright (C) 2007-2008 Nokia Corporation99- *1010- * Tony Lindgren1111- * Paul Walmsley1212- * Richard Woodruff1313- *1414- * This program is free software; you can redistribute it and/or modify1515- * it under the terms of the GNU General Public License version 2 as1616- * published by the Free Software Foundation.1717- */1818-1919-2020-/* SDRC register offsets - read/write with sdrc_{read,write}_reg() */2121-2222-#define SDRC_SYSCONFIG 0x0102323-#define SDRC_CS_CFG 0x0402424-#define SDRC_SHARING 0x0442525-#define SDRC_ERR_TYPE 0x04C2626-#define SDRC_DLLA_CTRL 0x0602727-#define SDRC_DLLA_STATUS 0x0642828-#define SDRC_DLLB_CTRL 0x0682929-#define SDRC_DLLB_STATUS 0x06C3030-#define SDRC_POWER 0x0703131-#define SDRC_MCFG_0 0x0803232-#define SDRC_MR_0 0x0843333-#define SDRC_EMR2_0 0x08c3434-#define SDRC_ACTIM_CTRL_A_0 0x09c3535-#define SDRC_ACTIM_CTRL_B_0 0x0a03636-#define SDRC_RFR_CTRL_0 0x0a43737-#define SDRC_MANUAL_0 0x0a83838-#define SDRC_MCFG_1 0x0B03939-#define SDRC_MR_1 0x0B44040-#define SDRC_EMR2_1 0x0BC4141-#define SDRC_ACTIM_CTRL_A_1 0x0C44242-#define SDRC_ACTIM_CTRL_B_1 0x0C84343-#define SDRC_RFR_CTRL_1 0x0D44444-#define SDRC_MANUAL_1 0x0D84545-4646-#define SDRC_POWER_AUTOCOUNT_SHIFT 84747-#define SDRC_POWER_AUTOCOUNT_MASK (0xffff << SDRC_POWER_AUTOCOUNT_SHIFT)4848-#define SDRC_POWER_CLKCTRL_SHIFT 44949-#define SDRC_POWER_CLKCTRL_MASK (0x3 << SDRC_POWER_CLKCTRL_SHIFT)5050-#define SDRC_SELF_REFRESH_ON_AUTOCOUNT (0x2 << SDRC_POWER_CLKCTRL_SHIFT)5151-5252-/*5353- * These values represent the number of memory clock cycles between5454- * autorefresh initiation. They assume 1 refresh per 64 ms (JEDEC), 81925555- * rows per device, and include a subtraction of a 50 cycle window in the5656- * event that the autorefresh command is delayed due to other SDRC activity.5757- * The '| 1' sets the ARE field to send one autorefresh when the autorefresh5858- * counter reaches 0.5959- *6060- * These represent optimal values for common parts, it won't work for all.6161- * As long as you scale down, most parameters are still work, they just6262- * become sub-optimal. The RFR value goes in the opposite direction. If you6363- * don't adjust it down as your clock period increases the refresh interval6464- * will not be met. Setting all parameters for complete worst case may work,6565- * but may cut memory performance by 2x. Due to errata the DLLs need to be6666- * unlocked and their value needs run time calibration. A dynamic call is6767- * need for that as no single right value exists acorss production samples.6868- *6969- * Only the FULL speed values are given. Current code is such that rate7070- * changes must be made at DPLLoutx2. The actual value adjustment for low7171- * frequency operation will be handled by omap_set_performance()7272- *7373- * By having the boot loader boot up in the fastest L4 speed available likely7474- * will result in something which you can switch between.7575- */7676-#define SDRC_RFR_CTRL_165MHz (0x00044c00 | 1)7777-#define SDRC_RFR_CTRL_133MHz (0x0003de00 | 1)7878-#define SDRC_RFR_CTRL_100MHz (0x0002da01 | 1)7979-#define SDRC_RFR_CTRL_110MHz (0x0002da01 | 1) /* Need to calc */8080-#define SDRC_RFR_CTRL_BYPASS (0x00005000 | 1) /* Need to calc */8181-8282-8383-/*8484- * SMS register access8585- */8686-8787-#define OMAP242X_SMS_REGADDR(reg) \8888- (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE + reg)8989-#define OMAP243X_SMS_REGADDR(reg) \9090- (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE + reg)9191-#define OMAP343X_SMS_REGADDR(reg) \9292- (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE + reg)9393-9494-/* SMS register offsets - read/write with sms_{read,write}_reg() */9595-9696-#define SMS_SYSCONFIG 0x0109797-#define SMS_ROT_CONTROL(context) (0x180 + 0x10 * context)9898-#define SMS_ROT_SIZE(context) (0x184 + 0x10 * context)9999-#define SMS_ROT_PHYSICAL_BA(context) (0x188 + 0x10 * context)100100-/* REVISIT: fill in other SMS registers here */101101-102102-103103-#ifndef __ASSEMBLER__104104-105105-/**106106- * struct omap_sdrc_params - SDRC parameters for a given SDRC clock rate107107- * @rate: SDRC clock rate (in Hz)108108- * @actim_ctrla: Value to program to SDRC_ACTIM_CTRLA for this rate109109- * @actim_ctrlb: Value to program to SDRC_ACTIM_CTRLB for this rate110110- * @rfr_ctrl: Value to program to SDRC_RFR_CTRL for this rate111111- * @mr: Value to program to SDRC_MR for this rate112112- *113113- * This structure holds a pre-computed set of register values for the114114- * SDRC for a given SDRC clock rate and SDRAM chip. These are115115- * intended to be pre-computed and specified in an array in the board-*.c116116- * files. The structure is keyed off the 'rate' field.117117- */118118-struct omap_sdrc_params {119119- unsigned long rate;120120- u32 actim_ctrla;121121- u32 actim_ctrlb;122122- u32 rfr_ctrl;123123- u32 mr;124124-};125125-126126-#ifdef CONFIG_SOC_HAS_OMAP2_SDRC127127-void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,128128- struct omap_sdrc_params *sdrc_cs1);129129-#else130130-static inline void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,131131- struct omap_sdrc_params *sdrc_cs1) {};132132-#endif133133-134134-int omap2_sdrc_get_params(unsigned long r,135135- struct omap_sdrc_params **sdrc_cs0,136136- struct omap_sdrc_params **sdrc_cs1);137137-void omap2_sms_save_context(void);138138-void omap2_sms_restore_context(void);139139-140140-void omap2_sms_write_rot_control(u32 val, unsigned ctx);141141-void omap2_sms_write_rot_size(u32 val, unsigned ctx);142142-void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx);143143-144144-#ifdef CONFIG_ARCH_OMAP2145145-146146-struct memory_timings {147147- u32 m_type; /* ddr = 1, sdr = 0 */148148- u32 dll_mode; /* use lock mode = 1, unlock mode = 0 */149149- u32 slow_dll_ctrl; /* unlock mode, dll value for slow speed */150150- u32 fast_dll_ctrl; /* unlock mode, dll value for fast speed */151151- u32 base_cs; /* base chip select to use for calculations */152152-};153153-154154-extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);155155-struct omap_sdrc_params *rx51_get_sdram_timings(void);156156-157157-u32 omap2xxx_sdrc_dll_is_unlocked(void);158158-u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);159159-160160-#endif /* CONFIG_ARCH_OMAP2 */161161-162162-#endif /* __ASSEMBLER__ */163163-164164-#endif
···8989#include <linux/of.h>9090#include <linux/notifier.h>91919292-#include <plat/omap_device.h>9393-#include <plat/omap_hwmod.h>9494-#include <plat/clock.h>9292+#include "omap_device.h"9393+#include "omap_hwmod.h"95949695/* These parameters are passed to _omap_device_{de,}activate() */9796#define USE_WAKEUP_LAT 0
+28-338
arch/arm/plat-omap/sram.c
···2020#include <linux/init.h>2121#include <linux/io.h>22222323+#include <asm/fncpy.h>2324#include <asm/tlb.h>2425#include <asm/cacheflush.h>25262627#include <asm/mach/map.h>27282828-#include <plat/sram.h>2929-#include <plat/cpu.h>3030-3131-#include "sram.h"3232-3333-/* XXX These "sideways" includes will disappear when sram.c becomes a driver */3434-#include "../mach-omap2/iomap.h"3535-#include "../mach-omap2/prm2xxx_3xxx.h"3636-#include "../mach-omap2/sdrc.h"3737-3838-#define OMAP1_SRAM_PA 0x200000003939-#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)4040-#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000)4141-#ifdef CONFIG_OMAP4_ERRATA_I6884242-#define OMAP4_SRAM_PUB_PA OMAP4_SRAM_PA4343-#else4444-#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)4545-#endif4646-#define OMAP5_SRAM_PA 0x403000004747-4848-#if defined(CONFIG_ARCH_OMAP2PLUS)4949-#define SRAM_BOOTLOADER_SZ 0x005050-#else5151-#define SRAM_BOOTLOADER_SZ 0x805252-#endif5353-5454-#define OMAP24XX_VA_REQINFOPERM0 OMAP2_L3_IO_ADDRESS(0x68005048)5555-#define OMAP24XX_VA_READPERM0 OMAP2_L3_IO_ADDRESS(0x68005050)5656-#define OMAP24XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68005058)5757-5858-#define OMAP34XX_VA_REQINFOPERM0 OMAP2_L3_IO_ADDRESS(0x68012848)5959-#define OMAP34XX_VA_READPERM0 OMAP2_L3_IO_ADDRESS(0x68012850)6060-#define OMAP34XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68012858)6161-#define OMAP34XX_VA_ADDR_MATCH2 OMAP2_L3_IO_ADDRESS(0x68012880)6262-#define OMAP34XX_VA_SMS_RG_ATT0 OMAP2_L3_IO_ADDRESS(0x6C000048)6363-6464-#define GP_DEVICE 0x3006565-6629#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1)))67306868-static unsigned long omap_sram_start;6931static void __iomem *omap_sram_base;7032static unsigned long omap_sram_skip;7133static unsigned long omap_sram_size;7234static void __iomem *omap_sram_ceil;7373-7474-/*7575- * Depending on the target RAMFS firewall setup, the public usable amount of7676- * SRAM varies. The default accessible size for all device types is 2k. A GP7777- * device allows ARM11 but not other initiators for full size. This7878- * functionality seems ok until some nice security API happens.7979- */8080-static int is_sram_locked(void)8181-{8282- if (OMAP2_DEVICE_TYPE_GP == omap_type()) {8383- /* RAMFW: R/W access to all initiators for all qualifier sets */8484- if (cpu_is_omap242x()) {8585- __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */8686- __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0); /* all i-read */8787- __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */8888- }8989- if (cpu_is_omap34xx()) {9090- __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */9191- __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0); /* all i-read */9292- __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */9393- __raw_writel(0x0, OMAP34XX_VA_ADDR_MATCH2);9494- __raw_writel(0xFFFFFFFF, OMAP34XX_VA_SMS_RG_ATT0);9595- }9696- return 0;9797- } else9898- return 1; /* assume locked with no PPA or security driver */9999-}100100-101101-/*102102- * The amount of SRAM depends on the core type.103103- * Note that we cannot try to test for SRAM here because writes104104- * to secure SRAM will hang the system. Also the SRAM is not105105- * yet mapped at this point.106106- */107107-static void __init omap_detect_sram(void)108108-{109109- omap_sram_skip = SRAM_BOOTLOADER_SZ;110110- if (cpu_class_is_omap2()) {111111- if (is_sram_locked()) {112112- if (cpu_is_omap34xx()) {113113- omap_sram_start = OMAP3_SRAM_PUB_PA;114114- if ((omap_type() == OMAP2_DEVICE_TYPE_EMU) ||115115- (omap_type() == OMAP2_DEVICE_TYPE_SEC)) {116116- omap_sram_size = 0x7000; /* 28K */117117- omap_sram_skip += SZ_16K;118118- } else {119119- omap_sram_size = 0x8000; /* 32K */120120- }121121- } else if (cpu_is_omap44xx()) {122122- omap_sram_start = OMAP4_SRAM_PUB_PA;123123- omap_sram_size = 0xa000; /* 40K */124124- } else if (soc_is_omap54xx()) {125125- omap_sram_start = OMAP5_SRAM_PA;126126- omap_sram_size = SZ_128K; /* 128KB */127127- } else {128128- omap_sram_start = OMAP2_SRAM_PUB_PA;129129- omap_sram_size = 0x800; /* 2K */130130- }131131- } else {132132- if (soc_is_am33xx()) {133133- omap_sram_start = AM33XX_SRAM_PA;134134- omap_sram_size = 0x10000; /* 64K */135135- } else if (cpu_is_omap34xx()) {136136- omap_sram_start = OMAP3_SRAM_PA;137137- omap_sram_size = 0x10000; /* 64K */138138- } else if (cpu_is_omap44xx()) {139139- omap_sram_start = OMAP4_SRAM_PA;140140- omap_sram_size = 0xe000; /* 56K */141141- } else if (soc_is_omap54xx()) {142142- omap_sram_start = OMAP5_SRAM_PA;143143- omap_sram_size = SZ_128K; /* 128KB */144144- } else {145145- omap_sram_start = OMAP2_SRAM_PA;146146- if (cpu_is_omap242x())147147- omap_sram_size = 0xa0000; /* 640K */148148- else if (cpu_is_omap243x())149149- omap_sram_size = 0x10000; /* 64K */150150- }151151- }152152- } else {153153- omap_sram_start = OMAP1_SRAM_PA;154154-155155- if (cpu_is_omap7xx())156156- omap_sram_size = 0x32000; /* 200K */157157- else if (cpu_is_omap15xx())158158- omap_sram_size = 0x30000; /* 192K */159159- else if (cpu_is_omap1610() || cpu_is_omap1611() ||160160- cpu_is_omap1621() || cpu_is_omap1710())161161- omap_sram_size = 0x4000; /* 16K */162162- else {163163- pr_err("Could not detect SRAM size\n");164164- omap_sram_size = 0x4000;165165- }166166- }167167-}168168-169169-/*170170- * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.171171- */172172-static void __init omap_map_sram(void)173173-{174174- int cached = 1;175175-176176- if (omap_sram_size == 0)177177- return;178178-179179-#ifdef CONFIG_OMAP4_ERRATA_I688180180- if (cpu_is_omap44xx()) {181181- omap_sram_start += PAGE_SIZE;182182- omap_sram_size -= SZ_16K;183183- }184184-#endif185185- if (cpu_is_omap34xx()) {186186- /*187187- * SRAM must be marked as non-cached on OMAP3 since the188188- * CORE DPLL M2 divider change code (in SRAM) runs with the189189- * SDRAM controller disabled, and if it is marked cached,190190- * the ARM may attempt to write cache lines back to SDRAM191191- * which will cause the system to hang.192192- */193193- cached = 0;194194- }195195-196196- omap_sram_start = ROUND_DOWN(omap_sram_start, PAGE_SIZE);197197- omap_sram_base = __arm_ioremap_exec(omap_sram_start, omap_sram_size,198198- cached);199199- if (!omap_sram_base) {200200- pr_err("SRAM: Could not map\n");201201- return;202202- }203203-204204- omap_sram_ceil = omap_sram_base + omap_sram_size;205205-206206- /*207207- * Looks like we need to preserve some bootloader code at the208208- * beginning of SRAM for jumping to flash for reboot to work...209209- */210210- memset_io(omap_sram_base + omap_sram_skip, 0,211211- omap_sram_size - omap_sram_skip);212212-}2133521436/*21537 * Memory allocator for SRAM: calculates the new ceiling address···58236 return (void *)omap_sram_ceil;59237}602386161-#ifdef CONFIG_ARCH_OMAP16262-6363-static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);6464-6565-void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)6666-{6767- BUG_ON(!_omap_sram_reprogram_clock);6868- /* On 730, bit 13 must always be 1 */6969- if (cpu_is_omap7xx())7070- ckctl |= 0x2000;7171- _omap_sram_reprogram_clock(dpllctl, ckctl);7272-}7373-7474-static int __init omap1_sram_init(void)7575-{7676- _omap_sram_reprogram_clock =7777- omap_sram_push(omap1_sram_reprogram_clock,7878- omap1_sram_reprogram_clock_sz);7979-8080- return 0;8181-}8282-8383-#else8484-#define omap1_sram_init() do {} while (0)8585-#endif8686-8787-#if defined(CONFIG_ARCH_OMAP2)8888-8989-static void (*_omap2_sram_ddr_init)(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,9090- u32 base_cs, u32 force_unlock);9191-9292-void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,9393- u32 base_cs, u32 force_unlock)9494-{9595- BUG_ON(!_omap2_sram_ddr_init);9696- _omap2_sram_ddr_init(slow_dll_ctrl, fast_dll_ctrl,9797- base_cs, force_unlock);9898-}9999-100100-static void (*_omap2_sram_reprogram_sdrc)(u32 perf_level, u32 dll_val,101101- u32 mem_type);102102-103103-void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val, u32 mem_type)104104-{105105- BUG_ON(!_omap2_sram_reprogram_sdrc);106106- _omap2_sram_reprogram_sdrc(perf_level, dll_val, mem_type);107107-}108108-109109-static u32 (*_omap2_set_prcm)(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass);110110-111111-u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass)112112-{113113- BUG_ON(!_omap2_set_prcm);114114- return _omap2_set_prcm(dpll_ctrl_val, sdrc_rfr_val, bypass);115115-}116116-#endif117117-118118-#ifdef CONFIG_SOC_OMAP2420119119-static int __init omap242x_sram_init(void)120120-{121121- _omap2_sram_ddr_init = omap_sram_push(omap242x_sram_ddr_init,122122- omap242x_sram_ddr_init_sz);123123-124124- _omap2_sram_reprogram_sdrc = omap_sram_push(omap242x_sram_reprogram_sdrc,125125- omap242x_sram_reprogram_sdrc_sz);126126-127127- _omap2_set_prcm = omap_sram_push(omap242x_sram_set_prcm,128128- omap242x_sram_set_prcm_sz);129129-130130- return 0;131131-}132132-#else133133-static inline int omap242x_sram_init(void)134134-{135135- return 0;136136-}137137-#endif138138-139139-#ifdef CONFIG_SOC_OMAP2430140140-static int __init omap243x_sram_init(void)141141-{142142- _omap2_sram_ddr_init = omap_sram_push(omap243x_sram_ddr_init,143143- omap243x_sram_ddr_init_sz);144144-145145- _omap2_sram_reprogram_sdrc = omap_sram_push(omap243x_sram_reprogram_sdrc,146146- omap243x_sram_reprogram_sdrc_sz);147147-148148- _omap2_set_prcm = omap_sram_push(omap243x_sram_set_prcm,149149- omap243x_sram_set_prcm_sz);150150-151151- return 0;152152-}153153-#else154154-static inline int omap243x_sram_init(void)155155-{156156- return 0;157157-}158158-#endif159159-160160-#ifdef CONFIG_ARCH_OMAP3161161-162162-static u32 (*_omap3_sram_configure_core_dpll)(163163- u32 m2, u32 unlock_dll, u32 f, u32 inc,164164- u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,165165- u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,166166- u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,167167- u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1);168168-169169-u32 omap3_configure_core_dpll(u32 m2, u32 unlock_dll, u32 f, u32 inc,170170- u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,171171- u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,172172- u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,173173- u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1)174174-{175175- BUG_ON(!_omap3_sram_configure_core_dpll);176176- return _omap3_sram_configure_core_dpll(177177- m2, unlock_dll, f, inc,178178- sdrc_rfr_ctrl_0, sdrc_actim_ctrl_a_0,179179- sdrc_actim_ctrl_b_0, sdrc_mr_0,180180- sdrc_rfr_ctrl_1, sdrc_actim_ctrl_a_1,181181- sdrc_actim_ctrl_b_1, sdrc_mr_1);182182-}183183-184184-void omap3_sram_restore_context(void)239239+/*240240+ * The SRAM context is lost during off-idle and stack241241+ * needs to be reset.242242+ */243243+void omap_sram_reset(void)185244{186245 omap_sram_ceil = omap_sram_base + omap_sram_size;187187-188188- _omap3_sram_configure_core_dpll =189189- omap_sram_push(omap3_sram_configure_core_dpll,190190- omap3_sram_configure_core_dpll_sz);191191- omap_push_sram_idle();192246}193247194194-static inline int omap34xx_sram_init(void)248248+/*249249+ * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.250250+ */251251+void __init omap_map_sram(unsigned long start, unsigned long size,252252+ unsigned long skip, int cached)195253{196196- omap3_sram_restore_context();197197- return 0;198198-}199199-#else200200-static inline int omap34xx_sram_init(void)201201-{202202- return 0;203203-}204204-#endif /* CONFIG_ARCH_OMAP3 */254254+ if (size == 0)255255+ return;205256206206-static inline int am33xx_sram_init(void)207207-{208208- return 0;209209-}257257+ start = ROUND_DOWN(start, PAGE_SIZE);258258+ omap_sram_size = size;259259+ omap_sram_skip = skip;260260+ omap_sram_base = __arm_ioremap_exec(start, size, cached);261261+ if (!omap_sram_base) {262262+ pr_err("SRAM: Could not map\n");263263+ return;264264+ }210265211211-int __init omap_sram_init(void)212212-{213213- omap_detect_sram();214214- omap_map_sram();266266+ omap_sram_reset();215267216216- if (!(cpu_class_is_omap2()))217217- omap1_sram_init();218218- else if (cpu_is_omap242x())219219- omap242x_sram_init();220220- else if (cpu_is_omap2430())221221- omap243x_sram_init();222222- else if (soc_is_am33xx())223223- am33xx_sram_init();224224- else if (cpu_is_omap34xx())225225- omap34xx_sram_init();226226-227227- return 0;268268+ /*269269+ * Looks like we need to preserve some bootloader code at the270270+ * beginning of SRAM for jumping to flash for reboot to work...271271+ */272272+ memset_io(omap_sram_base + omap_sram_skip, 0,273273+ omap_sram_size - omap_sram_skip);228274}
-6
arch/arm/plat-omap/sram.h
···11-#ifndef __PLAT_OMAP_SRAM_H__22-#define __PLAT_OMAP_SRAM_H__33-44-extern int __init omap_sram_init(void);55-66-#endif /* __PLAT_OMAP_SRAM_H__ */
+1-6
drivers/bluetooth/hci_ldisc.c
···270270 */271271static int hci_uart_tty_open(struct tty_struct *tty)272272{273273- struct hci_uart *hu = (void *) tty->disc_data;273273+ struct hci_uart *hu;274274275275 BT_DBG("tty %p", tty);276276-277277- /* FIXME: This btw is bogus, nothing requires the old ldisc to clear278278- the pointer */279279- if (hu)280280- return -EEXIST;281276282277 /* Error if the tty has no write op instead of leaving an exploitable283278 hole */
···2727#include <linux/bch.h>2828#endif29293030-#include <plat/dma.h>3131-#include <plat/gpmc.h>3030+#include <plat-omap/dma-omap.h>3231#include <linux/platform_data/mtd-nand-omap2.h>33323433#define DRIVER_NAME "omap2-nand"···105106#define CS_MASK 0x7106107#define ENABLE_PREFETCH (0x1 << 7)107108#define DMA_MPU_MODE_SHIFT 2109109+#define ECCSIZE0_SHIFT 12108110#define ECCSIZE1_SHIFT 22109111#define ECC1RESULTSIZE 0x1110112#define ECCCLEAR 0x100111113#define ECC1 0x1114114+#define PREFETCH_FIFOTHRESHOLD_MAX 0x40115115+#define PREFETCH_FIFOTHRESHOLD(val) ((val) << 8)116116+#define PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)117117+#define PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)118118+#define STATUS_BUFF_EMPTY 0x00000001119119+120120+#define OMAP24XX_DMA_GPMC 4112121113122/* oob info generated runtime depending on ecc algorithm and layout selected */114123static struct nand_ecclayout omap_oobinfo;···276269 /* wait until buffer is available for write */277270 do {278271 status = readl(info->reg.gpmc_status) &279279- GPMC_STATUS_BUFF_EMPTY;272272+ STATUS_BUFF_EMPTY;280273 } while (!status);281274 }282275}···314307 /* wait until buffer is available for write */315308 do {316309 status = readl(info->reg.gpmc_status) &317317- GPMC_STATUS_BUFF_EMPTY;310310+ STATUS_BUFF_EMPTY;318311 } while (!status);319312 }320313}···355348 } else {356349 do {357350 r_count = readl(info->reg.gpmc_prefetch_status);358358- r_count = GPMC_PREFETCH_STATUS_FIFO_CNT(r_count);351351+ r_count = PREFETCH_STATUS_FIFO_CNT(r_count);359352 r_count = r_count >> 2;360353 ioread32_rep(info->nand.IO_ADDR_R, p, r_count);361354 p += r_count;···402395 } else {403396 while (len) {404397 w_count = readl(info->reg.gpmc_prefetch_status);405405- w_count = GPMC_PREFETCH_STATUS_FIFO_CNT(w_count);398398+ w_count = PREFETCH_STATUS_FIFO_CNT(w_count);406399 w_count = w_count >> 1;407400 for (i = 0; (i < w_count) && len; i++, len -= 2)408401 iowrite16(*p++, info->nand.IO_ADDR_W);···414407 do {415408 cpu_relax();416409 val = readl(info->reg.gpmc_prefetch_status);417417- val = GPMC_PREFETCH_STATUS_COUNT(val);410410+ val = PREFETCH_STATUS_COUNT(val);418411 } while (val && (tim++ < limit));419412420413 /* disable and stop the PFPW engine */···500493 do {501494 cpu_relax();502495 val = readl(info->reg.gpmc_prefetch_status);503503- val = GPMC_PREFETCH_STATUS_COUNT(val);496496+ val = PREFETCH_STATUS_COUNT(val);504497 } while (val && (tim++ < limit));505498506499 /* disable and stop the PFPW engine */···563556 u32 bytes;564557565558 bytes = readl(info->reg.gpmc_prefetch_status);566566- bytes = GPMC_PREFETCH_STATUS_FIFO_CNT(bytes);559559+ bytes = PREFETCH_STATUS_FIFO_CNT(bytes);567560 bytes = bytes & 0xFFFC; /* io in multiple of 4 bytes */568561 if (info->iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */569562 if (this_irq == info->gpmc_irq_count)···689682 limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));690683 do {691684 val = readl(info->reg.gpmc_prefetch_status);692692- val = GPMC_PREFETCH_STATUS_COUNT(val);685685+ val = PREFETCH_STATUS_COUNT(val);693686 cpu_relax();694687 } while (val && (tim++ < limit));695688···1003996 cond_resched();1004997 }100599810061006- status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA);999999+ status = readb(info->reg.gpmc_nand_data);10071000 return status;10081001}10091002···10361029static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode)10371030{10381031 int nerrors;10391039- unsigned int dev_width;10321032+ unsigned int dev_width, nsectors;10401033 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,10411034 mtd);10421035 struct nand_chip *chip = mtd->priv;10361036+ u32 val;1043103710441038 nerrors = (info->nand.ecc.bytes == 13) ? 8 : 4;10451039 dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0;10401040+ nsectors = 1;10461041 /*10471042 * Program GPMC to perform correction on one 512-byte sector at a time.10481043 * Using 4 sectors at a time (i.e. ecc.size = 2048) is also possible and10491044 * gives a slight (5%) performance gain (but requires additional code).10501045 */10511051- (void)gpmc_enable_hwecc_bch(info->gpmc_cs, mode, dev_width, 1, nerrors);10461046+10471047+ writel(ECC1, info->reg.gpmc_ecc_control);10481048+10491049+ /*10501050+ * When using BCH, sector size is hardcoded to 512 bytes.10511051+ * Here we are using wrapping mode 6 both for reading and writing, with:10521052+ * size0 = 0 (no additional protected byte in spare area)10531053+ * size1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area)10541054+ */10551055+ val = (32 << ECCSIZE1_SHIFT) | (0 << ECCSIZE0_SHIFT);10561056+ writel(val, info->reg.gpmc_ecc_size_config);10571057+10581058+ /* BCH configuration */10591059+ val = ((1 << 16) | /* enable BCH */10601060+ (((nerrors == 8) ? 1 : 0) << 12) | /* 8 or 4 bits */10611061+ (0x06 << 8) | /* wrap mode = 6 */10621062+ (dev_width << 7) | /* bus width */10631063+ (((nsectors-1) & 0x7) << 4) | /* number of sectors */10641064+ (info->gpmc_cs << 1) | /* ECC CS */10651065+ (0x1)); /* enable ECC */10661066+10671067+ writel(val, info->reg.gpmc_ecc_config);10681068+10691069+ /* clear ecc and enable bits */10701070+ writel(ECCCLEAR | ECC1, info->reg.gpmc_ecc_control);10521071}1053107210541073/**···10881055{10891056 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,10901057 mtd);10911091- return gpmc_calculate_ecc_bch4(info->gpmc_cs, dat, ecc_code);10581058+ unsigned long nsectors, val1, val2;10591059+ int i;10601060+10611061+ nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1;10621062+10631063+ for (i = 0; i < nsectors; i++) {10641064+10651065+ /* Read hw-computed remainder */10661066+ val1 = readl(info->reg.gpmc_bch_result0[i]);10671067+ val2 = readl(info->reg.gpmc_bch_result1[i]);10681068+10691069+ /*10701070+ * Add constant polynomial to remainder, in order to get an ecc10711071+ * sequence of 0xFFs for a buffer filled with 0xFFs; and10721072+ * left-justify the resulting polynomial.10731073+ */10741074+ *ecc_code++ = 0x28 ^ ((val2 >> 12) & 0xFF);10751075+ *ecc_code++ = 0x13 ^ ((val2 >> 4) & 0xFF);10761076+ *ecc_code++ = 0xcc ^ (((val2 & 0xF) << 4)|((val1 >> 28) & 0xF));10771077+ *ecc_code++ = 0x39 ^ ((val1 >> 20) & 0xFF);10781078+ *ecc_code++ = 0x96 ^ ((val1 >> 12) & 0xFF);10791079+ *ecc_code++ = 0xac ^ ((val1 >> 4) & 0xFF);10801080+ *ecc_code++ = 0x7f ^ ((val1 & 0xF) << 4);10811081+ }10821082+10831083+ return 0;10921084}1093108510941086/**···11271069{11281070 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,11291071 mtd);11301130- return gpmc_calculate_ecc_bch8(info->gpmc_cs, dat, ecc_code);10721072+ unsigned long nsectors, val1, val2, val3, val4;10731073+ int i;10741074+10751075+ nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1;10761076+10771077+ for (i = 0; i < nsectors; i++) {10781078+10791079+ /* Read hw-computed remainder */10801080+ val1 = readl(info->reg.gpmc_bch_result0[i]);10811081+ val2 = readl(info->reg.gpmc_bch_result1[i]);10821082+ val3 = readl(info->reg.gpmc_bch_result2[i]);10831083+ val4 = readl(info->reg.gpmc_bch_result3[i]);10841084+10851085+ /*10861086+ * Add constant polynomial to remainder, in order to get an ecc10871087+ * sequence of 0xFFs for a buffer filled with 0xFFs.10881088+ */10891089+ *ecc_code++ = 0xef ^ (val4 & 0xFF);10901090+ *ecc_code++ = 0x51 ^ ((val3 >> 24) & 0xFF);10911091+ *ecc_code++ = 0x2e ^ ((val3 >> 16) & 0xFF);10921092+ *ecc_code++ = 0x09 ^ ((val3 >> 8) & 0xFF);10931093+ *ecc_code++ = 0xed ^ (val3 & 0xFF);10941094+ *ecc_code++ = 0x93 ^ ((val2 >> 24) & 0xFF);10951095+ *ecc_code++ = 0x9a ^ ((val2 >> 16) & 0xFF);10961096+ *ecc_code++ = 0xc2 ^ ((val2 >> 8) & 0xFF);10971097+ *ecc_code++ = 0x97 ^ (val2 & 0xFF);10981098+ *ecc_code++ = 0x79 ^ ((val1 >> 24) & 0xFF);10991099+ *ecc_code++ = 0xe5 ^ ((val1 >> 16) & 0xFF);11001100+ *ecc_code++ = 0x24 ^ ((val1 >> 8) & 0xFF);11011101+ *ecc_code++ = 0xb5 ^ (val1 & 0xFF);11021102+ }11031103+11041104+ return 0;11311105}1132110611331107/**···12151125 */12161126static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt)12171127{12181218- int ret, max_errors;11281128+ int max_errors;12191129 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,12201130 mtd);12211131#ifdef CONFIG_MTD_NAND_OMAP_BCH8···12311141 max_errors, hw_errors);12321142 goto fail;12331143 }12341234-12351235- /* initialize GPMC BCH engine */12361236- ret = gpmc_init_hwecc_bch(info->gpmc_cs, 1, max_errors);12371237- if (ret)12381238- goto fail;1239114412401145 /* software bch library is only used to detect and locate errors */12411146 info->bch = init_bch(13, max_errors, 0x201b /* hw polynomial */);···15981513 /* Release NAND device, its internal structures and partitions */15991514 nand_release(&info->mtd);16001515 iounmap(info->nand.IO_ADDR_R);16011601- release_mem_region(info->phys_base, NAND_IO_SIZE);15161516+ release_mem_region(info->phys_base, info->mem_size);16021517 kfree(info);16031518 return 0;16041519}
+29-18
drivers/mtd/onenand/omap2.c
···3838#include <linux/regulator/consumer.h>39394040#include <asm/mach/flash.h>4141-#include <plat/gpmc.h>4241#include <linux/platform_data/mtd-onenand-omap2.h>4342#include <asm/gpio.h>44434545-#include <plat/dma.h>4646-#include <plat/cpu.h>4444+#include <plat-omap/dma-omap.h>47454846#define DRIVER_NAME "omap2-onenand"4947···6163 int freq;6264 int (*setup)(void __iomem *base, int *freq_ptr);6365 struct regulator *regulator;6666+ u8 flags;6467};65686669static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)···154155 if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) {155156 syscfg |= ONENAND_SYS_CFG1_IOBE;156157 write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);157157- if (cpu_is_omap34xx())158158+ if (c->flags & ONENAND_IN_OMAP34XX)158159 /* Add a delay to let GPIO settle */159160 syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);160161 }···445446446447#else447448448448-int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,449449- unsigned char *buffer, int offset,450450- size_t count);449449+static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,450450+ unsigned char *buffer, int offset,451451+ size_t count)452452+{453453+ return -ENOSYS;454454+}451455452452-int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,453453- const unsigned char *buffer,454454- int offset, size_t count);456456+static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,457457+ const unsigned char *buffer,458458+ int offset, size_t count)459459+{460460+ return -ENOSYS;461461+}455462456463#endif457464···555550556551#else557552558558-int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,559559- unsigned char *buffer, int offset,560560- size_t count);553553+static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,554554+ unsigned char *buffer, int offset,555555+ size_t count)556556+{557557+ return -ENOSYS;558558+}561559562562-int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,563563- const unsigned char *buffer,564564- int offset, size_t count);560560+static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,561561+ const unsigned char *buffer,562562+ int offset, size_t count)563563+{564564+ return -ENOSYS;565565+}565566566567#endif567568···650639651640 init_completion(&c->irq_done);652641 init_completion(&c->dma_done);642642+ c->flags = pdata->flags;653643 c->gpmc_cs = pdata->cs;654644 c->gpio_irq = pdata->gpio_irq;655645 c->dma_channel = pdata->dma_channel;···741729 this = &c->onenand;742730 if (c->dma_channel >= 0) {743731 this->wait = omap2_onenand_wait;744744- if (cpu_is_omap34xx()) {732732+ if (c->flags & ONENAND_IN_OMAP34XX) {745733 this->read_bufferram = omap3_onenand_read_bufferram;746734 this->write_bufferram = omap3_onenand_write_bufferram;747735 } else {···815803 }816804 iounmap(c->onenand.base);817805 release_mem_region(c->phys_base, c->mem_size);818818- gpmc_cs_free(c->gpmc_cs);819806 kfree(c);820807821808 return 0;
+1-1
drivers/pcmcia/omap_cf.c
···2525#include <asm/sizes.h>26262727#include <mach/mux.h>2828-#include <plat/tc.h>2828+#include <mach/tc.h>292930303131/* NOTE: don't expect this to support many I/O cards. The 16xx chips have
···7373#define ECHO_OP_SET_CANON_COL 0x817474#define ECHO_OP_ERASE_TAB 0x8275757676+struct n_tty_data {7777+ unsigned int column;7878+ unsigned long overrun_time;7979+ int num_overrun;8080+8181+ unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;8282+ unsigned char echo_overrun:1;8383+8484+ DECLARE_BITMAP(process_char_map, 256);8585+ DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);8686+8787+ char *read_buf;8888+ int read_head;8989+ int read_tail;9090+ int read_cnt;9191+9292+ unsigned char *echo_buf;9393+ unsigned int echo_pos;9494+ unsigned int echo_cnt;9595+9696+ int canon_data;9797+ unsigned long canon_head;9898+ unsigned int canon_column;9999+100100+ struct mutex atomic_read_lock;101101+ struct mutex output_lock;102102+ struct mutex echo_lock;103103+ spinlock_t read_lock;104104+};105105+76106static inline int tty_put_user(struct tty_struct *tty, unsigned char x,77107 unsigned char __user *ptr)78108{7979- tty_audit_add_data(tty, &x, 1);109109+ struct n_tty_data *ldata = tty->disc_data;110110+111111+ tty_audit_add_data(tty, &x, 1, ldata->icanon);80112 return put_user(x, ptr);81113}82114···1249212593static void n_tty_set_room(struct tty_struct *tty)12694{9595+ struct n_tty_data *ldata = tty->disc_data;12796 int left;12897 int old_left;12998130130- /* tty->read_cnt is not read locked ? */9999+ /* ldata->read_cnt is not read locked ? */131100 if (I_PARMRK(tty)) {132101 /* Multiply read_cnt by 3, since each byte might take up to133102 * three times as many spaces when PARMRK is set (depending on134103 * its flags, e.g. parity error). */135135- left = N_TTY_BUF_SIZE - tty->read_cnt * 3 - 1;104104+ left = N_TTY_BUF_SIZE - ldata->read_cnt * 3 - 1;136105 } else137137- left = N_TTY_BUF_SIZE - tty->read_cnt - 1;106106+ left = N_TTY_BUF_SIZE - ldata->read_cnt - 1;138107139108 /*140109 * If we are doing input canonicalization, and there are no···144111 * characters will be beeped.145112 */146113 if (left <= 0)147147- left = tty->icanon && !tty->canon_data;114114+ left = ldata->icanon && !ldata->canon_data;148115 old_left = tty->receive_room;149116 tty->receive_room = left;150117151118 /* Did this open up the receive buffer? We may need to flip */152152- if (left && !old_left)153153- schedule_work(&tty->buf.work);119119+ if (left && !old_left) {120120+ WARN_RATELIMIT(tty->port->itty == NULL,121121+ "scheduling with invalid itty");122122+ schedule_work(&tty->port->buf.work);123123+ }154124}155125156156-static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)126126+static void put_tty_queue_nolock(unsigned char c, struct n_tty_data *ldata)157127{158158- if (tty->read_cnt < N_TTY_BUF_SIZE) {159159- tty->read_buf[tty->read_head] = c;160160- tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1);161161- tty->read_cnt++;128128+ if (ldata->read_cnt < N_TTY_BUF_SIZE) {129129+ ldata->read_buf[ldata->read_head] = c;130130+ ldata->read_head = (ldata->read_head + 1) & (N_TTY_BUF_SIZE-1);131131+ ldata->read_cnt++;162132 }163133}164134165135/**166136 * put_tty_queue - add character to tty167137 * @c: character168168- * @tty: tty device138138+ * @ldata: n_tty data169139 *170140 * Add a character to the tty read_buf queue. This is done under the171141 * read_lock to serialize character addition and also to protect us172142 * against parallel reads or flushes173143 */174144175175-static void put_tty_queue(unsigned char c, struct tty_struct *tty)145145+static void put_tty_queue(unsigned char c, struct n_tty_data *ldata)176146{177147 unsigned long flags;178148 /*179149 * The problem of stomping on the buffers ends here.180150 * Why didn't anyone see this one coming? --AJK181151 */182182- spin_lock_irqsave(&tty->read_lock, flags);183183- put_tty_queue_nolock(c, tty);184184- spin_unlock_irqrestore(&tty->read_lock, flags);152152+ spin_lock_irqsave(&ldata->read_lock, flags);153153+ put_tty_queue_nolock(c, ldata);154154+ spin_unlock_irqrestore(&ldata->read_lock, flags);185155}186156187157/**···215179216180static void reset_buffer_flags(struct tty_struct *tty)217181{182182+ struct n_tty_data *ldata = tty->disc_data;218183 unsigned long flags;219184220220- spin_lock_irqsave(&tty->read_lock, flags);221221- tty->read_head = tty->read_tail = tty->read_cnt = 0;222222- spin_unlock_irqrestore(&tty->read_lock, flags);185185+ spin_lock_irqsave(&ldata->read_lock, flags);186186+ ldata->read_head = ldata->read_tail = ldata->read_cnt = 0;187187+ spin_unlock_irqrestore(&ldata->read_lock, flags);223188224224- mutex_lock(&tty->echo_lock);225225- tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0;226226- mutex_unlock(&tty->echo_lock);189189+ mutex_lock(&ldata->echo_lock);190190+ ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0;191191+ mutex_unlock(&ldata->echo_lock);227192228228- tty->canon_head = tty->canon_data = tty->erasing = 0;229229- memset(&tty->read_flags, 0, sizeof tty->read_flags);193193+ ldata->canon_head = ldata->canon_data = ldata->erasing = 0;194194+ bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);230195 n_tty_set_room(tty);231196}232197···272235273236static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)274237{238238+ struct n_tty_data *ldata = tty->disc_data;275239 unsigned long flags;276240 ssize_t n = 0;277241278278- spin_lock_irqsave(&tty->read_lock, flags);279279- if (!tty->icanon) {280280- n = tty->read_cnt;281281- } else if (tty->canon_data) {282282- n = (tty->canon_head > tty->read_tail) ?283283- tty->canon_head - tty->read_tail :284284- tty->canon_head + (N_TTY_BUF_SIZE - tty->read_tail);242242+ spin_lock_irqsave(&ldata->read_lock, flags);243243+ if (!ldata->icanon) {244244+ n = ldata->read_cnt;245245+ } else if (ldata->canon_data) {246246+ n = (ldata->canon_head > ldata->read_tail) ?247247+ ldata->canon_head - ldata->read_tail :248248+ ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail);285249 }286286- spin_unlock_irqrestore(&tty->read_lock, flags);250250+ spin_unlock_irqrestore(&ldata->read_lock, flags);287251 return n;288252}289253···339301340302static int do_output_char(unsigned char c, struct tty_struct *tty, int space)341303{304304+ struct n_tty_data *ldata = tty->disc_data;342305 int spaces;343306344307 if (!space)···348309 switch (c) {349310 case '\n':350311 if (O_ONLRET(tty))351351- tty->column = 0;312312+ ldata->column = 0;352313 if (O_ONLCR(tty)) {353314 if (space < 2)354315 return -1;355355- tty->canon_column = tty->column = 0;316316+ ldata->canon_column = ldata->column = 0;356317 tty->ops->write(tty, "\r\n", 2);357318 return 2;358319 }359359- tty->canon_column = tty->column;320320+ ldata->canon_column = ldata->column;360321 break;361322 case '\r':362362- if (O_ONOCR(tty) && tty->column == 0)323323+ if (O_ONOCR(tty) && ldata->column == 0)363324 return 0;364325 if (O_OCRNL(tty)) {365326 c = '\n';366327 if (O_ONLRET(tty))367367- tty->canon_column = tty->column = 0;328328+ ldata->canon_column = ldata->column = 0;368329 break;369330 }370370- tty->canon_column = tty->column = 0;331331+ ldata->canon_column = ldata->column = 0;371332 break;372333 case '\t':373373- spaces = 8 - (tty->column & 7);334334+ spaces = 8 - (ldata->column & 7);374335 if (O_TABDLY(tty) == XTABS) {375336 if (space < spaces)376337 return -1;377377- tty->column += spaces;338338+ ldata->column += spaces;378339 tty->ops->write(tty, " ", spaces);379340 return spaces;380341 }381381- tty->column += spaces;342342+ ldata->column += spaces;382343 break;383344 case '\b':384384- if (tty->column > 0)385385- tty->column--;345345+ if (ldata->column > 0)346346+ ldata->column--;386347 break;387348 default:388349 if (!iscntrl(c)) {389350 if (O_OLCUC(tty))390351 c = toupper(c);391352 if (!is_continuation(c, tty))392392- tty->column++;353353+ ldata->column++;393354 }394355 break;395356 }···414375415376static int process_output(unsigned char c, struct tty_struct *tty)416377{378378+ struct n_tty_data *ldata = tty->disc_data;417379 int space, retval;418380419419- mutex_lock(&tty->output_lock);381381+ mutex_lock(&ldata->output_lock);420382421383 space = tty_write_room(tty);422384 retval = do_output_char(c, tty, space);423385424424- mutex_unlock(&tty->output_lock);386386+ mutex_unlock(&ldata->output_lock);425387 if (retval < 0)426388 return -1;427389 else···451411static ssize_t process_output_block(struct tty_struct *tty,452412 const unsigned char *buf, unsigned int nr)453413{414414+ struct n_tty_data *ldata = tty->disc_data;454415 int space;455416 int i;456417 const unsigned char *cp;457418458458- mutex_lock(&tty->output_lock);419419+ mutex_lock(&ldata->output_lock);459420460421 space = tty_write_room(tty);461422 if (!space) {462462- mutex_unlock(&tty->output_lock);423423+ mutex_unlock(&ldata->output_lock);463424 return 0;464425 }465426 if (nr > space)···472431 switch (c) {473432 case '\n':474433 if (O_ONLRET(tty))475475- tty->column = 0;434434+ ldata->column = 0;476435 if (O_ONLCR(tty))477436 goto break_out;478478- tty->canon_column = tty->column;437437+ ldata->canon_column = ldata->column;479438 break;480439 case '\r':481481- if (O_ONOCR(tty) && tty->column == 0)440440+ if (O_ONOCR(tty) && ldata->column == 0)482441 goto break_out;483442 if (O_OCRNL(tty))484443 goto break_out;485485- tty->canon_column = tty->column = 0;444444+ ldata->canon_column = ldata->column = 0;486445 break;487446 case '\t':488447 goto break_out;489448 case '\b':490490- if (tty->column > 0)491491- tty->column--;449449+ if (ldata->column > 0)450450+ ldata->column--;492451 break;493452 default:494453 if (!iscntrl(c)) {495454 if (O_OLCUC(tty))496455 goto break_out;497456 if (!is_continuation(c, tty))498498- tty->column++;457457+ ldata->column++;499458 }500459 break;501460 }···503462break_out:504463 i = tty->ops->write(tty, buf, i);505464506506- mutex_unlock(&tty->output_lock);465465+ mutex_unlock(&ldata->output_lock);507466 return i;508467}509468···535494536495static void process_echoes(struct tty_struct *tty)537496{497497+ struct n_tty_data *ldata = tty->disc_data;538498 int space, nr;539499 unsigned char c;540500 unsigned char *cp, *buf_end;541501542542- if (!tty->echo_cnt)502502+ if (!ldata->echo_cnt)543503 return;544504545545- mutex_lock(&tty->output_lock);546546- mutex_lock(&tty->echo_lock);505505+ mutex_lock(&ldata->output_lock);506506+ mutex_lock(&ldata->echo_lock);547507548508 space = tty_write_room(tty);549509550550- buf_end = tty->echo_buf + N_TTY_BUF_SIZE;551551- cp = tty->echo_buf + tty->echo_pos;552552- nr = tty->echo_cnt;510510+ buf_end = ldata->echo_buf + N_TTY_BUF_SIZE;511511+ cp = ldata->echo_buf + ldata->echo_pos;512512+ nr = ldata->echo_cnt;553513 while (nr > 0) {554514 c = *cp;555515 if (c == ECHO_OP_START) {···587545 * Otherwise, tab spacing is normal.588546 */589547 if (!(num_chars & 0x80))590590- num_chars += tty->canon_column;548548+ num_chars += ldata->canon_column;591549 num_bs = 8 - (num_chars & 7);592550593551 if (num_bs > space) {···597555 space -= num_bs;598556 while (num_bs--) {599557 tty_put_char(tty, '\b');600600- if (tty->column > 0)601601- tty->column--;558558+ if (ldata->column > 0)559559+ ldata->column--;602560 }603561 cp += 3;604562 nr -= 3;605563 break;606564607565 case ECHO_OP_SET_CANON_COL:608608- tty->canon_column = tty->column;566566+ ldata->canon_column = ldata->column;609567 cp += 2;610568 nr -= 2;611569 break;612570613571 case ECHO_OP_MOVE_BACK_COL:614614- if (tty->column > 0)615615- tty->column--;572572+ if (ldata->column > 0)573573+ ldata->column--;616574 cp += 2;617575 nr -= 2;618576 break;···624582 break;625583 }626584 tty_put_char(tty, ECHO_OP_START);627627- tty->column++;585585+ ldata->column++;628586 space--;629587 cp += 2;630588 nr -= 2;···646604 }647605 tty_put_char(tty, '^');648606 tty_put_char(tty, op ^ 0100);649649- tty->column += 2;607607+ ldata->column += 2;650608 space -= 2;651609 cp += 2;652610 nr -= 2;···677635 }678636679637 if (nr == 0) {680680- tty->echo_pos = 0;681681- tty->echo_cnt = 0;682682- tty->echo_overrun = 0;638638+ ldata->echo_pos = 0;639639+ ldata->echo_cnt = 0;640640+ ldata->echo_overrun = 0;683641 } else {684684- int num_processed = tty->echo_cnt - nr;685685- tty->echo_pos += num_processed;686686- tty->echo_pos &= N_TTY_BUF_SIZE - 1;687687- tty->echo_cnt = nr;642642+ int num_processed = ldata->echo_cnt - nr;643643+ ldata->echo_pos += num_processed;644644+ ldata->echo_pos &= N_TTY_BUF_SIZE - 1;645645+ ldata->echo_cnt = nr;688646 if (num_processed > 0)689689- tty->echo_overrun = 0;647647+ ldata->echo_overrun = 0;690648 }691649692692- mutex_unlock(&tty->echo_lock);693693- mutex_unlock(&tty->output_lock);650650+ mutex_unlock(&ldata->echo_lock);651651+ mutex_unlock(&ldata->output_lock);694652695653 if (tty->ops->flush_chars)696654 tty->ops->flush_chars(tty);···699657/**700658 * add_echo_byte - add a byte to the echo buffer701659 * @c: unicode byte to echo702702- * @tty: terminal device660660+ * @ldata: n_tty data703661 *704662 * Add a character or operation byte to the echo buffer.705663 *706664 * Should be called under the echo lock to protect the echo buffer.707665 */708666709709-static void add_echo_byte(unsigned char c, struct tty_struct *tty)667667+static void add_echo_byte(unsigned char c, struct n_tty_data *ldata)710668{711669 int new_byte_pos;712670713713- if (tty->echo_cnt == N_TTY_BUF_SIZE) {671671+ if (ldata->echo_cnt == N_TTY_BUF_SIZE) {714672 /* Circular buffer is already at capacity */715715- new_byte_pos = tty->echo_pos;673673+ new_byte_pos = ldata->echo_pos;716674717675 /*718676 * Since the buffer start position needs to be advanced,719677 * be sure to step by a whole operation byte group.720678 */721721- if (tty->echo_buf[tty->echo_pos] == ECHO_OP_START) {722722- if (tty->echo_buf[(tty->echo_pos + 1) &679679+ if (ldata->echo_buf[ldata->echo_pos] == ECHO_OP_START) {680680+ if (ldata->echo_buf[(ldata->echo_pos + 1) &723681 (N_TTY_BUF_SIZE - 1)] ==724682 ECHO_OP_ERASE_TAB) {725725- tty->echo_pos += 3;726726- tty->echo_cnt -= 2;683683+ ldata->echo_pos += 3;684684+ ldata->echo_cnt -= 2;727685 } else {728728- tty->echo_pos += 2;729729- tty->echo_cnt -= 1;686686+ ldata->echo_pos += 2;687687+ ldata->echo_cnt -= 1;730688 }731689 } else {732732- tty->echo_pos++;690690+ ldata->echo_pos++;733691 }734734- tty->echo_pos &= N_TTY_BUF_SIZE - 1;692692+ ldata->echo_pos &= N_TTY_BUF_SIZE - 1;735693736736- tty->echo_overrun = 1;694694+ ldata->echo_overrun = 1;737695 } else {738738- new_byte_pos = tty->echo_pos + tty->echo_cnt;696696+ new_byte_pos = ldata->echo_pos + ldata->echo_cnt;739697 new_byte_pos &= N_TTY_BUF_SIZE - 1;740740- tty->echo_cnt++;698698+ ldata->echo_cnt++;741699 }742700743743- tty->echo_buf[new_byte_pos] = c;701701+ ldata->echo_buf[new_byte_pos] = c;744702}745703746704/**747705 * echo_move_back_col - add operation to move back a column748748- * @tty: terminal device706706+ * @ldata: n_tty data749707 *750708 * Add an operation to the echo buffer to move back one column.751709 *752710 * Locking: echo_lock to protect the echo buffer753711 */754712755755-static void echo_move_back_col(struct tty_struct *tty)713713+static void echo_move_back_col(struct n_tty_data *ldata)756714{757757- mutex_lock(&tty->echo_lock);758758-759759- add_echo_byte(ECHO_OP_START, tty);760760- add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty);761761-762762- mutex_unlock(&tty->echo_lock);715715+ mutex_lock(&ldata->echo_lock);716716+ add_echo_byte(ECHO_OP_START, ldata);717717+ add_echo_byte(ECHO_OP_MOVE_BACK_COL, ldata);718718+ mutex_unlock(&ldata->echo_lock);763719}764720765721/**766722 * echo_set_canon_col - add operation to set the canon column767767- * @tty: terminal device723723+ * @ldata: n_tty data768724 *769725 * Add an operation to the echo buffer to set the canon column770726 * to the current column.···770730 * Locking: echo_lock to protect the echo buffer771731 */772732773773-static void echo_set_canon_col(struct tty_struct *tty)733733+static void echo_set_canon_col(struct n_tty_data *ldata)774734{775775- mutex_lock(&tty->echo_lock);776776-777777- add_echo_byte(ECHO_OP_START, tty);778778- add_echo_byte(ECHO_OP_SET_CANON_COL, tty);779779-780780- mutex_unlock(&tty->echo_lock);735735+ mutex_lock(&ldata->echo_lock);736736+ add_echo_byte(ECHO_OP_START, ldata);737737+ add_echo_byte(ECHO_OP_SET_CANON_COL, ldata);738738+ mutex_unlock(&ldata->echo_lock);781739}782740783741/**784742 * echo_erase_tab - add operation to erase a tab785743 * @num_chars: number of character columns already used786744 * @after_tab: true if num_chars starts after a previous tab787787- * @tty: terminal device745745+ * @ldata: n_tty data788746 *789747 * Add an operation to the echo buffer to erase a tab.790748 *···796758 */797759798760static void echo_erase_tab(unsigned int num_chars, int after_tab,799799- struct tty_struct *tty)761761+ struct n_tty_data *ldata)800762{801801- mutex_lock(&tty->echo_lock);763763+ mutex_lock(&ldata->echo_lock);802764803803- add_echo_byte(ECHO_OP_START, tty);804804- add_echo_byte(ECHO_OP_ERASE_TAB, tty);765765+ add_echo_byte(ECHO_OP_START, ldata);766766+ add_echo_byte(ECHO_OP_ERASE_TAB, ldata);805767806768 /* We only need to know this modulo 8 (tab spacing) */807769 num_chars &= 7;···810772 if (after_tab)811773 num_chars |= 0x80;812774813813- add_echo_byte(num_chars, tty);775775+ add_echo_byte(num_chars, ldata);814776815815- mutex_unlock(&tty->echo_lock);777777+ mutex_unlock(&ldata->echo_lock);816778}817779818780/**···828790 * Locking: echo_lock to protect the echo buffer829791 */830792831831-static void echo_char_raw(unsigned char c, struct tty_struct *tty)793793+static void echo_char_raw(unsigned char c, struct n_tty_data *ldata)832794{833833- mutex_lock(&tty->echo_lock);834834-795795+ mutex_lock(&ldata->echo_lock);835796 if (c == ECHO_OP_START) {836836- add_echo_byte(ECHO_OP_START, tty);837837- add_echo_byte(ECHO_OP_START, tty);797797+ add_echo_byte(ECHO_OP_START, ldata);798798+ add_echo_byte(ECHO_OP_START, ldata);838799 } else {839839- add_echo_byte(c, tty);800800+ add_echo_byte(c, ldata);840801 }841841-842842- mutex_unlock(&tty->echo_lock);802802+ mutex_unlock(&ldata->echo_lock);843803}844804845805/**···856820857821static void echo_char(unsigned char c, struct tty_struct *tty)858822{859859- mutex_lock(&tty->echo_lock);823823+ struct n_tty_data *ldata = tty->disc_data;824824+825825+ mutex_lock(&ldata->echo_lock);860826861827 if (c == ECHO_OP_START) {862862- add_echo_byte(ECHO_OP_START, tty);863863- add_echo_byte(ECHO_OP_START, tty);828828+ add_echo_byte(ECHO_OP_START, ldata);829829+ add_echo_byte(ECHO_OP_START, ldata);864830 } else {865831 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')866866- add_echo_byte(ECHO_OP_START, tty);867867- add_echo_byte(c, tty);832832+ add_echo_byte(ECHO_OP_START, ldata);833833+ add_echo_byte(c, ldata);868834 }869835870870- mutex_unlock(&tty->echo_lock);836836+ mutex_unlock(&ldata->echo_lock);871837}872838873839/**874840 * finish_erasing - complete erase875875- * @tty: tty doing the erase841841+ * @ldata: n_tty data876842 */877843878878-static inline void finish_erasing(struct tty_struct *tty)844844+static inline void finish_erasing(struct n_tty_data *ldata)879845{880880- if (tty->erasing) {881881- echo_char_raw('/', tty);882882- tty->erasing = 0;846846+ if (ldata->erasing) {847847+ echo_char_raw('/', ldata);848848+ ldata->erasing = 0;883849 }884850}885851···899861900862static void eraser(unsigned char c, struct tty_struct *tty)901863{864864+ struct n_tty_data *ldata = tty->disc_data;902865 enum { ERASE, WERASE, KILL } kill_type;903866 int head, seen_alnums, cnt;904867 unsigned long flags;905868906869 /* FIXME: locking needed ? */907907- if (tty->read_head == tty->canon_head) {870870+ if (ldata->read_head == ldata->canon_head) {908871 /* process_output('\a', tty); */ /* what do you think? */909872 return;910873 }···915876 kill_type = WERASE;916877 else {917878 if (!L_ECHO(tty)) {918918- spin_lock_irqsave(&tty->read_lock, flags);919919- tty->read_cnt -= ((tty->read_head - tty->canon_head) &879879+ spin_lock_irqsave(&ldata->read_lock, flags);880880+ ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &920881 (N_TTY_BUF_SIZE - 1));921921- tty->read_head = tty->canon_head;922922- spin_unlock_irqrestore(&tty->read_lock, flags);882882+ ldata->read_head = ldata->canon_head;883883+ spin_unlock_irqrestore(&ldata->read_lock, flags);923884 return;924885 }925886 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {926926- spin_lock_irqsave(&tty->read_lock, flags);927927- tty->read_cnt -= ((tty->read_head - tty->canon_head) &887887+ spin_lock_irqsave(&ldata->read_lock, flags);888888+ ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) &928889 (N_TTY_BUF_SIZE - 1));929929- tty->read_head = tty->canon_head;930930- spin_unlock_irqrestore(&tty->read_lock, flags);931931- finish_erasing(tty);890890+ ldata->read_head = ldata->canon_head;891891+ spin_unlock_irqrestore(&ldata->read_lock, flags);892892+ finish_erasing(ldata);932893 echo_char(KILL_CHAR(tty), tty);933894 /* Add a newline if ECHOK is on and ECHOKE is off. */934895 if (L_ECHOK(tty))935935- echo_char_raw('\n', tty);896896+ echo_char_raw('\n', ldata);936897 return;937898 }938899 kill_type = KILL;···940901941902 seen_alnums = 0;942903 /* FIXME: Locking ?? */943943- while (tty->read_head != tty->canon_head) {944944- head = tty->read_head;904904+ while (ldata->read_head != ldata->canon_head) {905905+ head = ldata->read_head;945906946907 /* erase a single possibly multibyte character */947908 do {948909 head = (head - 1) & (N_TTY_BUF_SIZE-1);949949- c = tty->read_buf[head];950950- } while (is_continuation(c, tty) && head != tty->canon_head);910910+ c = ldata->read_buf[head];911911+ } while (is_continuation(c, tty) && head != ldata->canon_head);951912952913 /* do not partially erase */953914 if (is_continuation(c, tty))···960921 else if (seen_alnums)961922 break;962923 }963963- cnt = (tty->read_head - head) & (N_TTY_BUF_SIZE-1);964964- spin_lock_irqsave(&tty->read_lock, flags);965965- tty->read_head = head;966966- tty->read_cnt -= cnt;967967- spin_unlock_irqrestore(&tty->read_lock, flags);924924+ cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1);925925+ spin_lock_irqsave(&ldata->read_lock, flags);926926+ ldata->read_head = head;927927+ ldata->read_cnt -= cnt;928928+ spin_unlock_irqrestore(&ldata->read_lock, flags);968929 if (L_ECHO(tty)) {969930 if (L_ECHOPRT(tty)) {970970- if (!tty->erasing) {971971- echo_char_raw('\\', tty);972972- tty->erasing = 1;931931+ if (!ldata->erasing) {932932+ echo_char_raw('\\', ldata);933933+ ldata->erasing = 1;973934 }974935 /* if cnt > 1, output a multi-byte character */975936 echo_char(c, tty);976937 while (--cnt > 0) {977938 head = (head+1) & (N_TTY_BUF_SIZE-1);978978- echo_char_raw(tty->read_buf[head], tty);979979- echo_move_back_col(tty);939939+ echo_char_raw(ldata->read_buf[head],940940+ ldata);941941+ echo_move_back_col(ldata);980942 }981943 } else if (kill_type == ERASE && !L_ECHOE(tty)) {982944 echo_char(ERASE_CHAR(tty), tty);983945 } else if (c == '\t') {984946 unsigned int num_chars = 0;985947 int after_tab = 0;986986- unsigned long tail = tty->read_head;948948+ unsigned long tail = ldata->read_head;987949988950 /*989951 * Count the columns used for characters···993953 * This info is used to go back the correct994954 * number of columns.995955 */996996- while (tail != tty->canon_head) {956956+ while (tail != ldata->canon_head) {997957 tail = (tail-1) & (N_TTY_BUF_SIZE-1);998998- c = tty->read_buf[tail];958958+ c = ldata->read_buf[tail];999959 if (c == '\t') {1000960 after_tab = 1;1001961 break;···1006966 num_chars++;1007967 }1008968 }10091009- echo_erase_tab(num_chars, after_tab, tty);969969+ echo_erase_tab(num_chars, after_tab, ldata);1010970 } else {1011971 if (iscntrl(c) && L_ECHOCTL(tty)) {10121012- echo_char_raw('\b', tty);10131013- echo_char_raw(' ', tty);10141014- echo_char_raw('\b', tty);972972+ echo_char_raw('\b', ldata);973973+ echo_char_raw(' ', ldata);974974+ echo_char_raw('\b', ldata);1015975 }1016976 if (!iscntrl(c) || L_ECHOCTL(tty)) {10171017- echo_char_raw('\b', tty);10181018- echo_char_raw(' ', tty);10191019- echo_char_raw('\b', tty);977977+ echo_char_raw('\b', ldata);978978+ echo_char_raw(' ', ldata);979979+ echo_char_raw('\b', ldata);1020980 }1021981 }1022982 }1023983 if (kill_type == ERASE)1024984 break;1025985 }10261026- if (tty->read_head == tty->canon_head && L_ECHO(tty))10271027- finish_erasing(tty);986986+ if (ldata->read_head == ldata->canon_head && L_ECHO(tty))987987+ finish_erasing(ldata);1028988}10299891030990/**···1063102310641024static inline void n_tty_receive_break(struct tty_struct *tty)10651025{10261026+ struct n_tty_data *ldata = tty->disc_data;10271027+10661028 if (I_IGNBRK(tty))10671029 return;10681030 if (I_BRKINT(tty)) {···10721030 return;10731031 }10741032 if (I_PARMRK(tty)) {10751075- put_tty_queue('\377', tty);10761076- put_tty_queue('\0', tty);10331033+ put_tty_queue('\377', ldata);10341034+ put_tty_queue('\0', ldata);10771035 }10781078- put_tty_queue('\0', tty);10361036+ put_tty_queue('\0', ldata);10791037 wake_up_interruptible(&tty->read_wait);10801038}10811039···1094105210951053static inline void n_tty_receive_overrun(struct tty_struct *tty)10961054{10551055+ struct n_tty_data *ldata = tty->disc_data;10971056 char buf[64];1098105710991099- tty->num_overrun++;11001100- if (time_before(tty->overrun_time, jiffies - HZ) ||11011101- time_after(tty->overrun_time, jiffies)) {10581058+ ldata->num_overrun++;10591059+ if (time_after(jiffies, ldata->overrun_time + HZ) ||10601060+ time_after(ldata->overrun_time, jiffies)) {11021061 printk(KERN_WARNING "%s: %d input overrun(s)\n",11031062 tty_name(tty, buf),11041104- tty->num_overrun);11051105- tty->overrun_time = jiffies;11061106- tty->num_overrun = 0;10631063+ ldata->num_overrun);10641064+ ldata->overrun_time = jiffies;10651065+ ldata->num_overrun = 0;11071066 }11081067}11091068···11191076static inline void n_tty_receive_parity_error(struct tty_struct *tty,11201077 unsigned char c)11211078{10791079+ struct n_tty_data *ldata = tty->disc_data;10801080+11221081 if (I_IGNPAR(tty))11231082 return;11241083 if (I_PARMRK(tty)) {11251125- put_tty_queue('\377', tty);11261126- put_tty_queue('\0', tty);11271127- put_tty_queue(c, tty);10841084+ put_tty_queue('\377', ldata);10851085+ put_tty_queue('\0', ldata);10861086+ put_tty_queue(c, ldata);11281087 } else if (I_INPCK(tty))11291129- put_tty_queue('\0', tty);10881088+ put_tty_queue('\0', ldata);11301089 else11311131- put_tty_queue(c, tty);10901090+ put_tty_queue(c, ldata);11321091 wake_up_interruptible(&tty->read_wait);11331092}11341093···1146110111471102static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)11481103{11041104+ struct n_tty_data *ldata = tty->disc_data;11491105 unsigned long flags;11501106 int parmrk;1151110711521152- if (tty->raw) {11531153- put_tty_queue(c, tty);11081108+ if (ldata->raw) {11091109+ put_tty_queue(c, ldata);11541110 return;11551111 }11561112···11611115 c = tolower(c);1162111611631117 if (L_EXTPROC(tty)) {11641164- put_tty_queue(c, tty);11181118+ put_tty_queue(c, ldata);11651119 return;11661120 }11671121···11891143 * handle specially, do shortcut processing to speed things11901144 * up.11911145 */11921192- if (!test_bit(c, tty->process_char_map) || tty->lnext) {11931193- tty->lnext = 0;11461146+ if (!test_bit(c, ldata->process_char_map) || ldata->lnext) {11471147+ ldata->lnext = 0;11941148 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;11951195- if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {11491149+ if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {11961150 /* beep if no space */11971151 if (L_ECHO(tty))11981152 process_output('\a', tty);11991153 return;12001154 }12011155 if (L_ECHO(tty)) {12021202- finish_erasing(tty);11561156+ finish_erasing(ldata);12031157 /* Record the column of first canon char. */12041204- if (tty->canon_head == tty->read_head)12051205- echo_set_canon_col(tty);11581158+ if (ldata->canon_head == ldata->read_head)11591159+ echo_set_canon_col(ldata);12061160 echo_char(c, tty);12071161 process_echoes(tty);12081162 }12091163 if (parmrk)12101210- put_tty_queue(c, tty);12111211- put_tty_queue(c, tty);11641164+ put_tty_queue(c, ldata);11651165+ put_tty_queue(c, ldata);12121166 return;12131167 }12141168···12641218 } else if (c == '\n' && I_INLCR(tty))12651219 c = '\r';1266122012671267- if (tty->icanon) {12211221+ if (ldata->icanon) {12681222 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) ||12691223 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {12701224 eraser(c, tty);···12721226 return;12731227 }12741228 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) {12751275- tty->lnext = 1;12291229+ ldata->lnext = 1;12761230 if (L_ECHO(tty)) {12771277- finish_erasing(tty);12311231+ finish_erasing(ldata);12781232 if (L_ECHOCTL(tty)) {12791279- echo_char_raw('^', tty);12801280- echo_char_raw('\b', tty);12331233+ echo_char_raw('^', ldata);12341234+ echo_char_raw('\b', ldata);12811235 process_echoes(tty);12821236 }12831237 }···12851239 }12861240 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) &&12871241 L_IEXTEN(tty)) {12881288- unsigned long tail = tty->canon_head;12421242+ unsigned long tail = ldata->canon_head;1289124312901290- finish_erasing(tty);12441244+ finish_erasing(ldata);12911245 echo_char(c, tty);12921292- echo_char_raw('\n', tty);12931293- while (tail != tty->read_head) {12941294- echo_char(tty->read_buf[tail], tty);12461246+ echo_char_raw('\n', ldata);12471247+ while (tail != ldata->read_head) {12481248+ echo_char(ldata->read_buf[tail], tty);12951249 tail = (tail+1) & (N_TTY_BUF_SIZE-1);12961250 }12971251 process_echoes(tty);12981252 return;12991253 }13001254 if (c == '\n') {13011301- if (tty->read_cnt >= N_TTY_BUF_SIZE) {12551255+ if (ldata->read_cnt >= N_TTY_BUF_SIZE) {13021256 if (L_ECHO(tty))13031257 process_output('\a', tty);13041258 return;13051259 }13061260 if (L_ECHO(tty) || L_ECHONL(tty)) {13071307- echo_char_raw('\n', tty);12611261+ echo_char_raw('\n', ldata);13081262 process_echoes(tty);13091263 }13101264 goto handle_newline;13111265 }13121266 if (c == EOF_CHAR(tty)) {13131313- if (tty->read_cnt >= N_TTY_BUF_SIZE)12671267+ if (ldata->read_cnt >= N_TTY_BUF_SIZE)13141268 return;13151315- if (tty->canon_head != tty->read_head)12691269+ if (ldata->canon_head != ldata->read_head)13161270 set_bit(TTY_PUSH, &tty->flags);13171271 c = __DISABLED_CHAR;13181272 goto handle_newline;···13211275 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) {13221276 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty))13231277 ? 1 : 0;13241324- if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) {12781278+ if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) {13251279 if (L_ECHO(tty))13261280 process_output('\a', tty);13271281 return;···13311285 */13321286 if (L_ECHO(tty)) {13331287 /* Record the column of first canon char. */13341334- if (tty->canon_head == tty->read_head)13351335- echo_set_canon_col(tty);12881288+ if (ldata->canon_head == ldata->read_head)12891289+ echo_set_canon_col(ldata);13361290 echo_char(c, tty);13371291 process_echoes(tty);13381292 }···13411295 * EOL_CHAR and EOL2_CHAR?13421296 */13431297 if (parmrk)13441344- put_tty_queue(c, tty);12981298+ put_tty_queue(c, ldata);1345129913461300handle_newline:13471347- spin_lock_irqsave(&tty->read_lock, flags);13481348- set_bit(tty->read_head, tty->read_flags);13491349- put_tty_queue_nolock(c, tty);13501350- tty->canon_head = tty->read_head;13511351- tty->canon_data++;13521352- spin_unlock_irqrestore(&tty->read_lock, flags);13011301+ spin_lock_irqsave(&ldata->read_lock, flags);13021302+ set_bit(ldata->read_head, ldata->read_flags);13031303+ put_tty_queue_nolock(c, ldata);13041304+ ldata->canon_head = ldata->read_head;13051305+ ldata->canon_data++;13061306+ spin_unlock_irqrestore(&ldata->read_lock, flags);13531307 kill_fasync(&tty->fasync, SIGIO, POLL_IN);13541308 if (waitqueue_active(&tty->read_wait))13551309 wake_up_interruptible(&tty->read_wait);···13581312 }1359131313601314 parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;13611361- if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {13151315+ if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {13621316 /* beep if no space */13631317 if (L_ECHO(tty))13641318 process_output('\a', tty);13651319 return;13661320 }13671321 if (L_ECHO(tty)) {13681368- finish_erasing(tty);13221322+ finish_erasing(ldata);13691323 if (c == '\n')13701370- echo_char_raw('\n', tty);13241324+ echo_char_raw('\n', ldata);13711325 else {13721326 /* Record the column of first canon char. */13731373- if (tty->canon_head == tty->read_head)13741374- echo_set_canon_col(tty);13271327+ if (ldata->canon_head == ldata->read_head)13281328+ echo_set_canon_col(ldata);13751329 echo_char(c, tty);13761330 }13771331 process_echoes(tty);13781332 }1379133313801334 if (parmrk)13811381- put_tty_queue(c, tty);13351335+ put_tty_queue(c, ldata);1382133613831383- put_tty_queue(c, tty);13371337+ put_tty_queue(c, ldata);13841338}1385133913861340···14151369static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,14161370 char *fp, int count)14171371{13721372+ struct n_tty_data *ldata = tty->disc_data;14181373 const unsigned char *p;14191374 char *f, flags = TTY_NORMAL;14201375 int i;14211376 char buf[64];14221377 unsigned long cpuflags;1423137814241424- if (!tty->read_buf)14251425- return;14261426-14271427- if (tty->real_raw) {14281428- spin_lock_irqsave(&tty->read_lock, cpuflags);14291429- i = min(N_TTY_BUF_SIZE - tty->read_cnt,14301430- N_TTY_BUF_SIZE - tty->read_head);13791379+ if (ldata->real_raw) {13801380+ spin_lock_irqsave(&ldata->read_lock, cpuflags);13811381+ i = min(N_TTY_BUF_SIZE - ldata->read_cnt,13821382+ N_TTY_BUF_SIZE - ldata->read_head);14311383 i = min(count, i);14321432- memcpy(tty->read_buf + tty->read_head, cp, i);14331433- tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);14341434- tty->read_cnt += i;13841384+ memcpy(ldata->read_buf + ldata->read_head, cp, i);13851385+ ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1);13861386+ ldata->read_cnt += i;14351387 cp += i;14361388 count -= i;1437138914381438- i = min(N_TTY_BUF_SIZE - tty->read_cnt,14391439- N_TTY_BUF_SIZE - tty->read_head);13901390+ i = min(N_TTY_BUF_SIZE - ldata->read_cnt,13911391+ N_TTY_BUF_SIZE - ldata->read_head);14401392 i = min(count, i);14411441- memcpy(tty->read_buf + tty->read_head, cp, i);14421442- tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);14431443- tty->read_cnt += i;14441444- spin_unlock_irqrestore(&tty->read_lock, cpuflags);13931393+ memcpy(ldata->read_buf + ldata->read_head, cp, i);13941394+ ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1);13951395+ ldata->read_cnt += i;13961396+ spin_unlock_irqrestore(&ldata->read_lock, cpuflags);14451397 } else {14461398 for (i = count, p = cp, f = fp; i; i--, p++) {14471399 if (f)···1470142614711427 n_tty_set_room(tty);1472142814731473- if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||14291429+ if ((!ldata->icanon && (ldata->read_cnt >= tty->minimum_to_wake)) ||14741430 L_EXTPROC(tty)) {14751431 kill_fasync(&tty->fasync, SIGIO, POLL_IN);14761432 if (waitqueue_active(&tty->read_wait))···1514147015151471static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)15161472{14731473+ struct n_tty_data *ldata = tty->disc_data;15171474 int canon_change = 1;15181518- BUG_ON(!tty);1519147515201476 if (old)15211477 canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;15221478 if (canon_change) {15231523- memset(&tty->read_flags, 0, sizeof tty->read_flags);15241524- tty->canon_head = tty->read_tail;15251525- tty->canon_data = 0;15261526- tty->erasing = 0;14791479+ bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);14801480+ ldata->canon_head = ldata->read_tail;14811481+ ldata->canon_data = 0;14821482+ ldata->erasing = 0;15271483 }1528148415291529- if (canon_change && !L_ICANON(tty) && tty->read_cnt)14851485+ if (canon_change && !L_ICANON(tty) && ldata->read_cnt)15301486 wake_up_interruptible(&tty->read_wait);1531148715321532- tty->icanon = (L_ICANON(tty) != 0);14881488+ ldata->icanon = (L_ICANON(tty) != 0);15331489 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) {15341534- tty->raw = 1;15351535- tty->real_raw = 1;14901490+ ldata->raw = 1;14911491+ ldata->real_raw = 1;15361492 n_tty_set_room(tty);15371493 return;15381494 }···15401496 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||15411497 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||15421498 I_PARMRK(tty)) {15431543- memset(tty->process_char_map, 0, 256/8);14991499+ bitmap_zero(ldata->process_char_map, 256);1544150015451501 if (I_IGNCR(tty) || I_ICRNL(tty))15461546- set_bit('\r', tty->process_char_map);15021502+ set_bit('\r', ldata->process_char_map);15471503 if (I_INLCR(tty))15481548- set_bit('\n', tty->process_char_map);15041504+ set_bit('\n', ldata->process_char_map);1549150515501506 if (L_ICANON(tty)) {15511551- set_bit(ERASE_CHAR(tty), tty->process_char_map);15521552- set_bit(KILL_CHAR(tty), tty->process_char_map);15531553- set_bit(EOF_CHAR(tty), tty->process_char_map);15541554- set_bit('\n', tty->process_char_map);15551555- set_bit(EOL_CHAR(tty), tty->process_char_map);15071507+ set_bit(ERASE_CHAR(tty), ldata->process_char_map);15081508+ set_bit(KILL_CHAR(tty), ldata->process_char_map);15091509+ set_bit(EOF_CHAR(tty), ldata->process_char_map);15101510+ set_bit('\n', ldata->process_char_map);15111511+ set_bit(EOL_CHAR(tty), ldata->process_char_map);15561512 if (L_IEXTEN(tty)) {15571513 set_bit(WERASE_CHAR(tty),15581558- tty->process_char_map);15141514+ ldata->process_char_map);15591515 set_bit(LNEXT_CHAR(tty),15601560- tty->process_char_map);15161516+ ldata->process_char_map);15611517 set_bit(EOL2_CHAR(tty),15621562- tty->process_char_map);15181518+ ldata->process_char_map);15631519 if (L_ECHO(tty))15641520 set_bit(REPRINT_CHAR(tty),15651565- tty->process_char_map);15211521+ ldata->process_char_map);15661522 }15671523 }15681524 if (I_IXON(tty)) {15691569- set_bit(START_CHAR(tty), tty->process_char_map);15701570- set_bit(STOP_CHAR(tty), tty->process_char_map);15251525+ set_bit(START_CHAR(tty), ldata->process_char_map);15261526+ set_bit(STOP_CHAR(tty), ldata->process_char_map);15711527 }15721528 if (L_ISIG(tty)) {15731573- set_bit(INTR_CHAR(tty), tty->process_char_map);15741574- set_bit(QUIT_CHAR(tty), tty->process_char_map);15751575- set_bit(SUSP_CHAR(tty), tty->process_char_map);15291529+ set_bit(INTR_CHAR(tty), ldata->process_char_map);15301530+ set_bit(QUIT_CHAR(tty), ldata->process_char_map);15311531+ set_bit(SUSP_CHAR(tty), ldata->process_char_map);15761532 }15771577- clear_bit(__DISABLED_CHAR, tty->process_char_map);15781578- tty->raw = 0;15791579- tty->real_raw = 0;15331533+ clear_bit(__DISABLED_CHAR, ldata->process_char_map);15341534+ ldata->raw = 0;15351535+ ldata->real_raw = 0;15801536 } else {15811581- tty->raw = 1;15371537+ ldata->raw = 1;15821538 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) &&15831539 (I_IGNPAR(tty) || !I_INPCK(tty)) &&15841540 (tty->driver->flags & TTY_DRIVER_REAL_RAW))15851585- tty->real_raw = 1;15411541+ ldata->real_raw = 1;15861542 else15871587- tty->real_raw = 0;15431543+ ldata->real_raw = 0;15881544 }15891545 n_tty_set_room(tty);15901546 /* The termios change make the tty ready for I/O */···1604156016051561static void n_tty_close(struct tty_struct *tty)16061562{15631563+ struct n_tty_data *ldata = tty->disc_data;15641564+16071565 n_tty_flush_buffer(tty);16081608- if (tty->read_buf) {16091609- kfree(tty->read_buf);16101610- tty->read_buf = NULL;16111611- }16121612- if (tty->echo_buf) {16131613- kfree(tty->echo_buf);16141614- tty->echo_buf = NULL;16151615- }15661566+ kfree(ldata->read_buf);15671567+ kfree(ldata->echo_buf);15681568+ kfree(ldata);15691569+ tty->disc_data = NULL;16161570}1617157116181572/**···1625158316261584static int n_tty_open(struct tty_struct *tty)16271585{16281628- if (!tty)16291629- return -EINVAL;15861586+ struct n_tty_data *ldata;15871587+15881588+ ldata = kzalloc(sizeof(*ldata), GFP_KERNEL);15891589+ if (!ldata)15901590+ goto err;15911591+15921592+ ldata->overrun_time = jiffies;15931593+ mutex_init(&ldata->atomic_read_lock);15941594+ mutex_init(&ldata->output_lock);15951595+ mutex_init(&ldata->echo_lock);15961596+ spin_lock_init(&ldata->read_lock);1630159716311598 /* These are ugly. Currently a malloc failure here can panic */16321632- if (!tty->read_buf) {16331633- tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);16341634- if (!tty->read_buf)16351635- return -ENOMEM;16361636- }16371637- if (!tty->echo_buf) {16381638- tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);15991599+ ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);16001600+ ldata->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);16011601+ if (!ldata->read_buf || !ldata->echo_buf)16021602+ goto err_free_bufs;1639160316401640- if (!tty->echo_buf)16411641- return -ENOMEM;16421642- }16041604+ tty->disc_data = ldata;16431605 reset_buffer_flags(tty);16441606 tty_unthrottle(tty);16451645- tty->column = 0;16071607+ ldata->column = 0;16461608 n_tty_set_termios(tty, NULL);16471609 tty->minimum_to_wake = 1;16481610 tty->closing = 0;16111611+16491612 return 0;16131613+err_free_bufs:16141614+ kfree(ldata->read_buf);16151615+ kfree(ldata->echo_buf);16161616+ kfree(ldata);16171617+err:16181618+ return -ENOMEM;16501619}1651162016521621static inline int input_available_p(struct tty_struct *tty, int amt)16531622{16231623+ struct n_tty_data *ldata = tty->disc_data;16241624+16541625 tty_flush_to_ldisc(tty);16551655- if (tty->icanon && !L_EXTPROC(tty)) {16561656- if (tty->canon_data)16261626+ if (ldata->icanon && !L_EXTPROC(tty)) {16271627+ if (ldata->canon_data)16571628 return 1;16581658- } else if (tty->read_cnt >= (amt ? amt : 1))16291629+ } else if (ldata->read_cnt >= (amt ? amt : 1))16591630 return 1;1660163116611632 return 0;···16871632 * buffer, and once to drain the space from the (physical) beginning of16881633 * the buffer to head pointer.16891634 *16901690- * Called under the tty->atomic_read_lock sem16351635+ * Called under the ldata->atomic_read_lock sem16911636 *16921637 */16931638···16961641 size_t *nr)1697164216981643{16441644+ struct n_tty_data *ldata = tty->disc_data;16991645 int retval;17001646 size_t n;17011647 unsigned long flags;17021648 bool is_eof;1703164917041650 retval = 0;17051705- spin_lock_irqsave(&tty->read_lock, flags);17061706- n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail);16511651+ spin_lock_irqsave(&ldata->read_lock, flags);16521652+ n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail);17071653 n = min(*nr, n);17081708- spin_unlock_irqrestore(&tty->read_lock, flags);16541654+ spin_unlock_irqrestore(&ldata->read_lock, flags);17091655 if (n) {17101710- retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n);16561656+ retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n);17111657 n -= retval;17121658 is_eof = n == 1 &&17131713- tty->read_buf[tty->read_tail] == EOF_CHAR(tty);17141714- tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n);17151715- spin_lock_irqsave(&tty->read_lock, flags);17161716- tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1);17171717- tty->read_cnt -= n;16591659+ ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty);16601660+ tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n,16611661+ ldata->icanon);16621662+ spin_lock_irqsave(&ldata->read_lock, flags);16631663+ ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1);16641664+ ldata->read_cnt -= n;17181665 /* Turn single EOF into zero-length read */17191719- if (L_EXTPROC(tty) && tty->icanon && is_eof && !tty->read_cnt)16661666+ if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt)17201667 n = 0;17211721- spin_unlock_irqrestore(&tty->read_lock, flags);16681668+ spin_unlock_irqrestore(&ldata->read_lock, flags);17221669 *b += n;17231670 *nr -= n;17241671 }···17871730static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,17881731 unsigned char __user *buf, size_t nr)17891732{17331733+ struct n_tty_data *ldata = tty->disc_data;17901734 unsigned char __user *b = buf;17911735 DECLARE_WAITQUEUE(wait, current);17921736 int c;···17991741 int packet;1800174218011743do_it_again:18021802-18031803- if (WARN_ON(!tty->read_buf))18041804- return -EAGAIN;18051805-18061744 c = job_control(tty, file);18071745 if (c < 0)18081746 return c;1809174718101748 minimum = time = 0;18111749 timeout = MAX_SCHEDULE_TIMEOUT;18121812- if (!tty->icanon) {17501750+ if (!ldata->icanon) {18131751 time = (HZ / 10) * TIME_CHAR(tty);18141752 minimum = MIN_CHAR(tty);18151753 if (minimum) {···18281774 * Internal serialization of reads.18291775 */18301776 if (file->f_flags & O_NONBLOCK) {18311831- if (!mutex_trylock(&tty->atomic_read_lock))17771777+ if (!mutex_trylock(&ldata->atomic_read_lock))18321778 return -EAGAIN;18331779 } else {18341834- if (mutex_lock_interruptible(&tty->atomic_read_lock))17801780+ if (mutex_lock_interruptible(&ldata->atomic_read_lock))18351781 return -ERESTARTSYS;18361782 }18371783 packet = tty->packet;···18841830 /* FIXME: does n_tty_set_room need locking ? */18851831 n_tty_set_room(tty);18861832 timeout = schedule_timeout(timeout);18871887- BUG_ON(!tty->read_buf);18881833 continue;18891834 }18901835 __set_current_state(TASK_RUNNING);···18981845 nr--;18991846 }1900184719011901- if (tty->icanon && !L_EXTPROC(tty)) {18481848+ if (ldata->icanon && !L_EXTPROC(tty)) {19021849 /* N.B. avoid overrun if nr == 0 */19031903- spin_lock_irqsave(&tty->read_lock, flags);19041904- while (nr && tty->read_cnt) {18501850+ spin_lock_irqsave(&ldata->read_lock, flags);18511851+ while (nr && ldata->read_cnt) {19051852 int eol;1906185319071907- eol = test_and_clear_bit(tty->read_tail,19081908- tty->read_flags);19091909- c = tty->read_buf[tty->read_tail];19101910- tty->read_tail = ((tty->read_tail+1) &18541854+ eol = test_and_clear_bit(ldata->read_tail,18551855+ ldata->read_flags);18561856+ c = ldata->read_buf[ldata->read_tail];18571857+ ldata->read_tail = ((ldata->read_tail+1) &19111858 (N_TTY_BUF_SIZE-1));19121912- tty->read_cnt--;18591859+ ldata->read_cnt--;19131860 if (eol) {19141861 /* this test should be redundant:19151862 * we shouldn't be reading data if19161863 * canon_data is 019171864 */19181918- if (--tty->canon_data < 0)19191919- tty->canon_data = 0;18651865+ if (--ldata->canon_data < 0)18661866+ ldata->canon_data = 0;19201867 }19211921- spin_unlock_irqrestore(&tty->read_lock, flags);18681868+ spin_unlock_irqrestore(&ldata->read_lock, flags);1922186919231870 if (!eol || (c != __DISABLED_CHAR)) {19241871 if (tty_put_user(tty, c, b++)) {19251872 retval = -EFAULT;19261873 b--;19271927- spin_lock_irqsave(&tty->read_lock, flags);18741874+ spin_lock_irqsave(&ldata->read_lock, flags);19281875 break;19291876 }19301877 nr--;19311878 }19321879 if (eol) {19331880 tty_audit_push(tty);19341934- spin_lock_irqsave(&tty->read_lock, flags);18811881+ spin_lock_irqsave(&ldata->read_lock, flags);19351882 break;19361883 }19371937- spin_lock_irqsave(&tty->read_lock, flags);18841884+ spin_lock_irqsave(&ldata->read_lock, flags);19381885 }19391939- spin_unlock_irqrestore(&tty->read_lock, flags);18861886+ spin_unlock_irqrestore(&ldata->read_lock, flags);19401887 if (retval)19411888 break;19421889 } else {···19681915 if (time)19691916 timeout = time;19701917 }19711971- mutex_unlock(&tty->atomic_read_lock);19181918+ mutex_unlock(&ldata->atomic_read_lock);19721919 remove_wait_queue(&tty->read_wait, &wait);1973192019741921 if (!waitqueue_active(&tty->read_wait))···21292076 return mask;21302077}2131207821322132-static unsigned long inq_canon(struct tty_struct *tty)20792079+static unsigned long inq_canon(struct n_tty_data *ldata)21332080{21342081 int nr, head, tail;2135208221362136- if (!tty->canon_data)20832083+ if (!ldata->canon_data)21372084 return 0;21382138- head = tty->canon_head;21392139- tail = tty->read_tail;20852085+ head = ldata->canon_head;20862086+ tail = ldata->read_tail;21402087 nr = (head - tail) & (N_TTY_BUF_SIZE-1);21412088 /* Skip EOF-chars.. */21422089 while (head != tail) {21432143- if (test_bit(tail, tty->read_flags) &&21442144- tty->read_buf[tail] == __DISABLED_CHAR)20902090+ if (test_bit(tail, ldata->read_flags) &&20912091+ ldata->read_buf[tail] == __DISABLED_CHAR)21452092 nr--;21462093 tail = (tail+1) & (N_TTY_BUF_SIZE-1);21472094 }···21512098static int n_tty_ioctl(struct tty_struct *tty, struct file *file,21522099 unsigned int cmd, unsigned long arg)21532100{21012101+ struct n_tty_data *ldata = tty->disc_data;21542102 int retval;2155210321562104 switch (cmd) {···21592105 return put_user(tty_chars_in_buffer(tty), (int __user *) arg);21602106 case TIOCINQ:21612107 /* FIXME: Locking */21622162- retval = tty->read_cnt;21082108+ retval = ldata->read_cnt;21632109 if (L_ICANON(tty))21642164- retval = inq_canon(tty);21102110+ retval = inq_canon(ldata);21652111 return put_user(retval, (unsigned int __user *) arg);21662112 default:21672113 return n_tty_ioctl_helper(tty, file, cmd, arg);
+22-8
drivers/tty/pty.c
···44 * Added support for a Unix98-style ptmx device.55 * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-199866 *77- * When reading this code see also fs/devpts. In particular note that the88- * driver_data field is used by the devpts side as a binding to the devpts99- * inode.107 */118129#include <linux/module.h>···5659#ifdef CONFIG_UNIX98_PTYS5760 if (tty->driver == ptm_driver) {5861 mutex_lock(&devpts_mutex);5959- devpts_pty_kill(tty->link);6262+ devpts_pty_kill(tty->link->driver_data);6063 mutex_unlock(&devpts_mutex);6164 }6265#endif···93969497static int pty_space(struct tty_struct *to)9598{9696- int n = 8192 - to->buf.memory_used;9999+ int n = 8192 - to->port->buf.memory_used;97100 if (n < 0)98101 return 0;99102 return n;···345348 tty_port_init(ports[1]);346349 o_tty->port = ports[0];347350 tty->port = ports[1];351351+ o_tty->port->itty = o_tty;348352349353 tty_driver_kref_get(driver);350354 tty->count++;···364366 return retval;365367}366368369369+/* this is called once with whichever end is closed last */370370+static void pty_unix98_shutdown(struct tty_struct *tty)371371+{372372+ devpts_kill_index(tty->driver_data, tty->index);373373+}374374+367375static void pty_cleanup(struct tty_struct *tty)368376{377377+ tty->port->itty = NULL;369378 kfree(tty->port);370379}371380···552547 struct tty_struct *tty;553548554549 mutex_lock(&devpts_mutex);555555- tty = devpts_get_tty(pts_inode, idx);550550+ tty = devpts_get_priv(pts_inode);556551 mutex_unlock(&devpts_mutex);557552 /* Master must be open before slave */558553 if (!tty)···586581 .set_termios = pty_set_termios,587582 .ioctl = pty_unix98_ioctl,588583 .resize = pty_resize,584584+ .shutdown = pty_unix98_shutdown,589585 .cleanup = pty_cleanup590586};591587···602596 .chars_in_buffer = pty_chars_in_buffer,603597 .unthrottle = pty_unthrottle,604598 .set_termios = pty_set_termios,599599+ .shutdown = pty_unix98_shutdown,605600 .cleanup = pty_cleanup,606601};607602···621614static int ptmx_open(struct inode *inode, struct file *filp)622615{623616 struct tty_struct *tty;617617+ struct inode *slave_inode;624618 int retval;625619 int index;626620···658650659651 tty_add_file(tty, filp);660652661661- retval = devpts_pty_new(inode, tty->link);662662- if (retval)653653+ slave_inode = devpts_pty_new(inode,654654+ MKDEV(UNIX98_PTY_SLAVE_MAJOR, index), index,655655+ tty->link);656656+ if (IS_ERR(slave_inode)) {657657+ retval = PTR_ERR(slave_inode);663658 goto err_release;659659+ }664660665661 retval = ptm_driver->ops->open(tty, filp);666662 if (retval)667663 goto err_release;668664669665 tty_unlock(tty);666666+ tty->driver_data = inode;667667+ tty->link->driver_data = slave_inode;670668 return 0;671669err_release:672670 tty_unlock(tty);
+3-6
drivers/tty/serial/8250/8250.c
···23492349 serial_port_out(port, UART_EFR, efr);23502350 }2351235123522352-#ifdef CONFIG_ARCH_OMAP123532352 /* Workaround to enable 115200 baud on OMAP1510 internal ports */23542354- if (cpu_is_omap1510() && is_omap_port(up)) {23532353+ if (is_omap1510_8250(up)) {23552354 if (baud == 115200) {23562355 quot = 1;23572356 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1);23582357 } else23592358 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0);23602359 }23612361-#endif2362236023632361 /*23642362 * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2,···24372439{24382440 if (pt->port.iotype == UPIO_AU)24392441 return 0x1000;24402440-#ifdef CONFIG_ARCH_OMAP124412441- if (is_omap_port(pt))24422442+ if (is_omap1_8250(pt))24422443 return 0x16 << pt->port.regshift;24432443-#endif24442444+24442445 return 8 << pt->port.regshift;24452446}24462447
+36
drivers/tty/serial/8250/8250.h
···106106static inline void serial8250_pnp_exit(void) { }107107#endif108108109109+#ifdef CONFIG_ARCH_OMAP1110110+static inline int is_omap1_8250(struct uart_8250_port *pt)111111+{112112+ int res;113113+114114+ switch (pt->port.mapbase) {115115+ case OMAP1_UART1_BASE:116116+ case OMAP1_UART2_BASE:117117+ case OMAP1_UART3_BASE:118118+ res = 1;119119+ break;120120+ default:121121+ res = 0;122122+ break;123123+ }124124+125125+ return res;126126+}127127+128128+static inline int is_omap1510_8250(struct uart_8250_port *pt)129129+{130130+ if (!cpu_is_omap1510())131131+ return 0;132132+133133+ return is_omap1_8250(pt);134134+}135135+#else136136+static inline int is_omap1_8250(struct uart_8250_port *pt)137137+{138138+ return 0;139139+}140140+static inline int is_omap1510_8250(struct uart_8250_port *pt)141141+{142142+ return 0;143143+}144144+#endif
···2323};24242525static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor,2626- int icanon)2626+ unsigned icanon)2727{2828 struct tty_audit_buf *buf;2929···239239 * if TTY auditing is disabled or out of memory. Otherwise, return a new240240 * reference to the buffer.241241 */242242-static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)242242+static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty,243243+ unsigned icanon)243244{244245 struct tty_audit_buf *buf, *buf2;245246···258257259258 buf2 = tty_audit_buf_alloc(tty->driver->major,260259 tty->driver->minor_start + tty->index,261261- tty->icanon);260260+ icanon);262261 if (buf2 == NULL) {263262 audit_log_lost("out of memory in TTY auditing");264263 return NULL;···288287 * Audit @data of @size from @tty, if necessary.289288 */290289void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,291291- size_t size)290290+ size_t size, unsigned icanon)292291{293292 struct tty_audit_buf *buf;294293 int major, minor;···300299 && tty->driver->subtype == PTY_TYPE_MASTER)301300 return;302301303303- buf = tty_audit_buf_get(tty);302302+ buf = tty_audit_buf_get(tty, icanon);304303 if (!buf)305304 return;306305···308307 major = tty->driver->major;309308 minor = tty->driver->minor_start + tty->index;310309 if (buf->major != major || buf->minor != minor311311- || buf->icanon != tty->icanon) {310310+ || buf->icanon != icanon) {312311 tty_audit_buf_push_current(buf);313312 buf->major = major;314313 buf->minor = minor;315315- buf->icanon = tty->icanon;314314+ buf->icanon = icanon;316315 }317316 do {318317 size_t run;
+129-99
drivers/tty/tty_buffer.c
···2727 * Locking: none2828 */29293030-void tty_buffer_free_all(struct tty_struct *tty)3030+void tty_buffer_free_all(struct tty_port *port)3131{3232+ struct tty_bufhead *buf = &port->buf;3233 struct tty_buffer *thead;3333- while ((thead = tty->buf.head) != NULL) {3434- tty->buf.head = thead->next;3434+3535+ while ((thead = buf->head) != NULL) {3636+ buf->head = thead->next;3537 kfree(thead);3638 }3737- while ((thead = tty->buf.free) != NULL) {3838- tty->buf.free = thead->next;3939+ while ((thead = buf->free) != NULL) {4040+ buf->free = thead->next;3941 kfree(thead);4042 }4141- tty->buf.tail = NULL;4242- tty->buf.memory_used = 0;4343+ buf->tail = NULL;4444+ buf->memory_used = 0;4345}44464547/**···5654 * Locking: Caller must hold tty->buf.lock5755 */58565959-static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size)5757+static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size)6058{6159 struct tty_buffer *p;62606363- if (tty->buf.memory_used + size > 65536)6161+ if (port->buf.memory_used + size > 65536)6462 return NULL;6563 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);6664 if (p == NULL)···7270 p->read = 0;7371 p->char_buf_ptr = (char *)(p->data);7472 p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size;7575- tty->buf.memory_used += size;7373+ port->buf.memory_used += size;7674 return p;7775}7876···8785 * Locking: Caller must hold tty->buf.lock8886 */89879090-static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b)8888+static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b)9189{9090+ struct tty_bufhead *buf = &port->buf;9191+9292 /* Dumb strategy for now - should keep some stats */9393- tty->buf.memory_used -= b->size;9494- WARN_ON(tty->buf.memory_used < 0);9393+ buf->memory_used -= b->size;9494+ WARN_ON(buf->memory_used < 0);95959696 if (b->size >= 512)9797 kfree(b);9898 else {9999- b->next = tty->buf.free;100100- tty->buf.free = b;9999+ b->next = buf->free;100100+ buf->free = b;101101 }102102}103103···114110 * Locking: Caller must hold tty->buf.lock115111 */116112117117-static void __tty_buffer_flush(struct tty_struct *tty)113113+static void __tty_buffer_flush(struct tty_port *port)118114{115115+ struct tty_bufhead *buf = &port->buf;119116 struct tty_buffer *thead;120117121121- while ((thead = tty->buf.head) != NULL) {122122- tty->buf.head = thead->next;123123- tty_buffer_free(tty, thead);118118+ while ((thead = buf->head) != NULL) {119119+ buf->head = thead->next;120120+ tty_buffer_free(port, thead);124121 }125125- tty->buf.tail = NULL;122122+ buf->tail = NULL;126123}127124128125/**···139134140135void tty_buffer_flush(struct tty_struct *tty)141136{137137+ struct tty_port *port = tty->port;138138+ struct tty_bufhead *buf = &port->buf;142139 unsigned long flags;143143- spin_lock_irqsave(&tty->buf.lock, flags);140140+141141+ spin_lock_irqsave(&buf->lock, flags);144142145143 /* If the data is being pushed to the tty layer then we can't146144 process it here. Instead set a flag and the flush_to_ldisc147145 path will process the flush request before it exits */148148- if (test_bit(TTY_FLUSHING, &tty->flags)) {149149- set_bit(TTY_FLUSHPENDING, &tty->flags);150150- spin_unlock_irqrestore(&tty->buf.lock, flags);146146+ if (test_bit(TTYP_FLUSHING, &port->iflags)) {147147+ set_bit(TTYP_FLUSHPENDING, &port->iflags);148148+ spin_unlock_irqrestore(&buf->lock, flags);151149 wait_event(tty->read_wait,152152- test_bit(TTY_FLUSHPENDING, &tty->flags) == 0);150150+ test_bit(TTYP_FLUSHPENDING, &port->iflags) == 0);153151 return;154152 } else155155- __tty_buffer_flush(tty);156156- spin_unlock_irqrestore(&tty->buf.lock, flags);153153+ __tty_buffer_flush(port);154154+ spin_unlock_irqrestore(&buf->lock, flags);157155}158156159157/**···171163 * Locking: Caller must hold tty->buf.lock172164 */173165174174-static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size)166166+static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size)175167{176176- struct tty_buffer **tbh = &tty->buf.free;168168+ struct tty_buffer **tbh = &port->buf.free;177169 while ((*tbh) != NULL) {178170 struct tty_buffer *t = *tbh;179171 if (t->size >= size) {···182174 t->used = 0;183175 t->commit = 0;184176 t->read = 0;185185- tty->buf.memory_used += t->size;177177+ port->buf.memory_used += t->size;186178 return t;187179 }188180 tbh = &((*tbh)->next);189181 }190182 /* Round the buffer size out */191183 size = (size + 0xFF) & ~0xFF;192192- return tty_buffer_alloc(tty, size);184184+ return tty_buffer_alloc(port, size);193185 /* Should possibly check if this fails for the largest buffer we194186 have queued and recycle that ? */195187}···200192 *201193 * Make at least size bytes of linear space available for the tty202194 * buffer. If we fail return the size we managed to find.203203- * Locking: Caller must hold tty->buf.lock195195+ * Locking: Caller must hold port->buf.lock204196 */205205-static int __tty_buffer_request_room(struct tty_struct *tty, size_t size)197197+static int __tty_buffer_request_room(struct tty_port *port, size_t size)206198{199199+ struct tty_bufhead *buf = &port->buf;207200 struct tty_buffer *b, *n;208201 int left;209202 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to210203 remove this conditional if its worth it. This would be invisible211204 to the callers */212212- if ((b = tty->buf.tail) != NULL)205205+ b = buf->tail;206206+ if (b != NULL)213207 left = b->size - b->used;214208 else215209 left = 0;216210217211 if (left < size) {218212 /* This is the slow path - looking for new buffers to use */219219- if ((n = tty_buffer_find(tty, size)) != NULL) {213213+ if ((n = tty_buffer_find(port, size)) != NULL) {220214 if (b != NULL) {221215 b->next = n;222216 b->commit = b->used;223217 } else224224- tty->buf.head = n;225225- tty->buf.tail = n;218218+ buf->head = n;219219+ buf->tail = n;226220 } else227221 size = left;228222 }···241231 * Make at least size bytes of linear space available for the tty242232 * buffer. If we fail return the size we managed to find.243233 *244244- * Locking: Takes tty->buf.lock234234+ * Locking: Takes port->buf.lock245235 */246236int tty_buffer_request_room(struct tty_struct *tty, size_t size)247237{238238+ struct tty_port *port = tty->port;248239 unsigned long flags;249240 int length;250241251251- spin_lock_irqsave(&tty->buf.lock, flags);252252- length = __tty_buffer_request_room(tty, size);253253- spin_unlock_irqrestore(&tty->buf.lock, flags);242242+ spin_lock_irqsave(&port->buf.lock, flags);243243+ length = __tty_buffer_request_room(port, size);244244+ spin_unlock_irqrestore(&port->buf.lock, flags);254245 return length;255246}256247EXPORT_SYMBOL_GPL(tty_buffer_request_room);···266255 * Queue a series of bytes to the tty buffering. All the characters267256 * passed are marked with the supplied flag. Returns the number added.268257 *269269- * Locking: Called functions may take tty->buf.lock258258+ * Locking: Called functions may take port->buf.lock270259 */271260272261int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,273262 const unsigned char *chars, char flag, size_t size)274263{264264+ struct tty_bufhead *buf = &tty->port->buf;275265 int copied = 0;276266 do {277267 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);···280268 unsigned long flags;281269 struct tty_buffer *tb;282270283283- spin_lock_irqsave(&tty->buf.lock, flags);284284- space = __tty_buffer_request_room(tty, goal);285285- tb = tty->buf.tail;271271+ spin_lock_irqsave(&buf->lock, flags);272272+ space = __tty_buffer_request_room(tty->port, goal);273273+ tb = buf->tail;286274 /* If there is no space then tb may be NULL */287275 if (unlikely(space == 0)) {288288- spin_unlock_irqrestore(&tty->buf.lock, flags);276276+ spin_unlock_irqrestore(&buf->lock, flags);289277 break;290278 }291279 memcpy(tb->char_buf_ptr + tb->used, chars, space);292280 memset(tb->flag_buf_ptr + tb->used, flag, space);293281 tb->used += space;294294- spin_unlock_irqrestore(&tty->buf.lock, flags);282282+ spin_unlock_irqrestore(&buf->lock, flags);295283 copied += space;296284 chars += space;297285 /* There is a small chance that we need to split the data over···312300 * the flags array indicates the status of the character. Returns the313301 * number added.314302 *315315- * Locking: Called functions may take tty->buf.lock303303+ * Locking: Called functions may take port->buf.lock316304 */317305318306int tty_insert_flip_string_flags(struct tty_struct *tty,319307 const unsigned char *chars, const char *flags, size_t size)320308{309309+ struct tty_bufhead *buf = &tty->port->buf;321310 int copied = 0;322311 do {323312 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);···326313 unsigned long __flags;327314 struct tty_buffer *tb;328315329329- spin_lock_irqsave(&tty->buf.lock, __flags);330330- space = __tty_buffer_request_room(tty, goal);331331- tb = tty->buf.tail;316316+ spin_lock_irqsave(&buf->lock, __flags);317317+ space = __tty_buffer_request_room(tty->port, goal);318318+ tb = buf->tail;332319 /* If there is no space then tb may be NULL */333320 if (unlikely(space == 0)) {334334- spin_unlock_irqrestore(&tty->buf.lock, __flags);321321+ spin_unlock_irqrestore(&buf->lock, __flags);335322 break;336323 }337324 memcpy(tb->char_buf_ptr + tb->used, chars, space);338325 memcpy(tb->flag_buf_ptr + tb->used, flags, space);339326 tb->used += space;340340- spin_unlock_irqrestore(&tty->buf.lock, __flags);327327+ spin_unlock_irqrestore(&buf->lock, __flags);341328 copied += space;342329 chars += space;343330 flags += space;···355342 * Takes any pending buffers and transfers their ownership to the356343 * ldisc side of the queue. It then schedules those characters for357344 * processing by the line discipline.345345+ * Note that this function can only be used when the low_latency flag346346+ * is unset. Otherwise the workqueue won't be flushed.358347 *359359- * Locking: Takes tty->buf.lock348348+ * Locking: Takes port->buf.lock360349 */361350362351void tty_schedule_flip(struct tty_struct *tty)363352{353353+ struct tty_bufhead *buf = &tty->port->buf;364354 unsigned long flags;365365- spin_lock_irqsave(&tty->buf.lock, flags);366366- if (tty->buf.tail != NULL)367367- tty->buf.tail->commit = tty->buf.tail->used;368368- spin_unlock_irqrestore(&tty->buf.lock, flags);369369- schedule_work(&tty->buf.work);355355+ WARN_ON(tty->low_latency);356356+357357+ spin_lock_irqsave(&buf->lock, flags);358358+ if (buf->tail != NULL)359359+ buf->tail->commit = buf->tail->used;360360+ spin_unlock_irqrestore(&buf->lock, flags);361361+ schedule_work(&buf->work);370362}371363EXPORT_SYMBOL(tty_schedule_flip);372364···387369 * that need their own block copy routines into the buffer. There is no388370 * guarantee the buffer is a DMA target!389371 *390390- * Locking: May call functions taking tty->buf.lock372372+ * Locking: May call functions taking port->buf.lock391373 */392374393375int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars,394394- size_t size)376376+ size_t size)395377{378378+ struct tty_bufhead *buf = &tty->port->buf;396379 int space;397380 unsigned long flags;398381 struct tty_buffer *tb;399382400400- spin_lock_irqsave(&tty->buf.lock, flags);401401- space = __tty_buffer_request_room(tty, size);383383+ spin_lock_irqsave(&buf->lock, flags);384384+ space = __tty_buffer_request_room(tty->port, size);402385403403- tb = tty->buf.tail;386386+ tb = buf->tail;404387 if (likely(space)) {405388 *chars = tb->char_buf_ptr + tb->used;406389 memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space);407390 tb->used += space;408391 }409409- spin_unlock_irqrestore(&tty->buf.lock, flags);392392+ spin_unlock_irqrestore(&buf->lock, flags);410393 return space;411394}412395EXPORT_SYMBOL_GPL(tty_prepare_flip_string);···425406 * that need their own block copy routines into the buffer. There is no426407 * guarantee the buffer is a DMA target!427408 *428428- * Locking: May call functions taking tty->buf.lock409409+ * Locking: May call functions taking port->buf.lock429410 */430411431412int tty_prepare_flip_string_flags(struct tty_struct *tty,432413 unsigned char **chars, char **flags, size_t size)433414{415415+ struct tty_bufhead *buf = &tty->port->buf;434416 int space;435417 unsigned long __flags;436418 struct tty_buffer *tb;437419438438- spin_lock_irqsave(&tty->buf.lock, __flags);439439- space = __tty_buffer_request_room(tty, size);420420+ spin_lock_irqsave(&buf->lock, __flags);421421+ space = __tty_buffer_request_room(tty->port, size);440422441441- tb = tty->buf.tail;423423+ tb = buf->tail;442424 if (likely(space)) {443425 *chars = tb->char_buf_ptr + tb->used;444426 *flags = tb->flag_buf_ptr + tb->used;445427 tb->used += space;446428 }447447- spin_unlock_irqrestore(&tty->buf.lock, __flags);429429+ spin_unlock_irqrestore(&buf->lock, __flags);448430 return space;449431}450432EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags);···466446467447static void flush_to_ldisc(struct work_struct *work)468448{469469- struct tty_struct *tty =470470- container_of(work, struct tty_struct, buf.work);449449+ struct tty_port *port = container_of(work, struct tty_port, buf.work);450450+ struct tty_bufhead *buf = &port->buf;451451+ struct tty_struct *tty;471452 unsigned long flags;472453 struct tty_ldisc *disc;454454+455455+ tty = port->itty;456456+ if (WARN_RATELIMIT(tty == NULL, "tty is NULL"))457457+ return;473458474459 disc = tty_ldisc_ref(tty);475460 if (disc == NULL) /* !TTY_LDISC */476461 return;477462478478- spin_lock_irqsave(&tty->buf.lock, flags);463463+ spin_lock_irqsave(&buf->lock, flags);479464480480- if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) {465465+ if (!test_and_set_bit(TTYP_FLUSHING, &port->iflags)) {481466 struct tty_buffer *head;482482- while ((head = tty->buf.head) != NULL) {467467+ while ((head = buf->head) != NULL) {483468 int count;484469 char *char_buf;485470 unsigned char *flag_buf;···493468 if (!count) {494469 if (head->next == NULL)495470 break;496496- tty->buf.head = head->next;497497- tty_buffer_free(tty, head);471471+ buf->head = head->next;472472+ tty_buffer_free(port, head);498473 continue;499474 }500475 /* Ldisc or user is trying to flush the buffers501476 we are feeding to the ldisc, stop feeding the502477 line discipline as we want to empty the queue */503503- if (test_bit(TTY_FLUSHPENDING, &tty->flags))478478+ if (test_bit(TTYP_FLUSHPENDING, &port->iflags))504479 break;505480 if (!tty->receive_room)506481 break;···509484 char_buf = head->char_buf_ptr + head->read;510485 flag_buf = head->flag_buf_ptr + head->read;511486 head->read += count;512512- spin_unlock_irqrestore(&tty->buf.lock, flags);487487+ spin_unlock_irqrestore(&buf->lock, flags);513488 disc->ops->receive_buf(tty, char_buf,514489 flag_buf, count);515515- spin_lock_irqsave(&tty->buf.lock, flags);490490+ spin_lock_irqsave(&buf->lock, flags);516491 }517517- clear_bit(TTY_FLUSHING, &tty->flags);492492+ clear_bit(TTYP_FLUSHING, &port->iflags);518493 }519494520495 /* We may have a deferred request to flush the input buffer,521496 if so pull the chain under the lock and empty the queue */522522- if (test_bit(TTY_FLUSHPENDING, &tty->flags)) {523523- __tty_buffer_flush(tty);524524- clear_bit(TTY_FLUSHPENDING, &tty->flags);497497+ if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) {498498+ __tty_buffer_flush(port);499499+ clear_bit(TTYP_FLUSHPENDING, &port->iflags);525500 wake_up(&tty->read_wait);526501 }527527- spin_unlock_irqrestore(&tty->buf.lock, flags);502502+ spin_unlock_irqrestore(&buf->lock, flags);528503529504 tty_ldisc_deref(disc);530505}···539514 */540515void tty_flush_to_ldisc(struct tty_struct *tty)541516{542542- flush_work(&tty->buf.work);517517+ if (!tty->low_latency)518518+ flush_work(&tty->port->buf.work);543519}544520545521/**···558532559533void tty_flip_buffer_push(struct tty_struct *tty)560534{535535+ struct tty_bufhead *buf = &tty->port->buf;561536 unsigned long flags;562562- spin_lock_irqsave(&tty->buf.lock, flags);563563- if (tty->buf.tail != NULL)564564- tty->buf.tail->commit = tty->buf.tail->used;565565- spin_unlock_irqrestore(&tty->buf.lock, flags);537537+538538+ spin_lock_irqsave(&buf->lock, flags);539539+ if (buf->tail != NULL)540540+ buf->tail->commit = buf->tail->used;541541+ spin_unlock_irqrestore(&buf->lock, flags);566542567543 if (tty->low_latency)568568- flush_to_ldisc(&tty->buf.work);544544+ flush_to_ldisc(&buf->work);569545 else570570- schedule_work(&tty->buf.work);546546+ schedule_work(&buf->work);571547}572548EXPORT_SYMBOL(tty_flip_buffer_push);573549···583555 * Locking: none584556 */585557586586-void tty_buffer_init(struct tty_struct *tty)558558+void tty_buffer_init(struct tty_port *port)587559{588588- spin_lock_init(&tty->buf.lock);589589- tty->buf.head = NULL;590590- tty->buf.tail = NULL;591591- tty->buf.free = NULL;592592- tty->buf.memory_used = 0;593593- INIT_WORK(&tty->buf.work, flush_to_ldisc);560560+ struct tty_bufhead *buf = &port->buf;561561+562562+ spin_lock_init(&buf->lock);563563+ buf->head = NULL;564564+ buf->tail = NULL;565565+ buf->free = NULL;566566+ buf->memory_used = 0;567567+ INIT_WORK(&buf->work, flush_to_ldisc);594568}595569
+3-12
drivers/tty/tty_io.c
···186186 if (tty->dev)187187 put_device(tty->dev);188188 kfree(tty->write_buf);189189- tty_buffer_free_all(tty);190189 tty->magic = 0xDEADDEAD;191190 kfree(tty);192191}···14161417 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n",14171418 __func__, tty->driver->name);1418141914201420+ tty->port->itty = tty;14211421+14191422 /*14201423 * Structures all installed ... call the ldisc open routines.14211424 * If we fail here just call release_tty to clean up. No need···15531552 tty->ops->shutdown(tty);15541553 tty_free_termios(tty);15551554 tty_driver_remove_tty(tty->driver, tty);15551555+ tty->port->itty = NULL;1556155615571557 if (tty->link)15581558 tty_kref_put(tty->link);···16271625 struct tty_struct *tty = file_tty(filp);16281626 struct tty_struct *o_tty;16291627 int pty_master, tty_closing, o_tty_closing, do_sleep;16301630- int devpts;16311628 int idx;16321629 char buf[64];16331630···16411640 idx = tty->index;16421641 pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&16431642 tty->driver->subtype == PTY_TYPE_MASTER);16441644- devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;16451643 /* Review: parallel close */16461644 o_tty = tty->link;16471645···17991799 release_tty(tty, idx);18001800 mutex_unlock(&tty_mutex);1801180118021802- /* Make this pty number available for reallocation */18031803- if (devpts)18041804- devpts_kill_index(inode, idx);18051802 return 0;18061803}18071804···29342937 tty_ldisc_init(tty);29352938 tty->session = NULL;29362939 tty->pgrp = NULL;29372937- tty->overrun_time = jiffies;29382938- tty_buffer_init(tty);29392940 mutex_init(&tty->legacy_mutex);29402941 mutex_init(&tty->termios_mutex);29412942 mutex_init(&tty->ldisc_mutex);29422943 init_waitqueue_head(&tty->write_wait);29432944 init_waitqueue_head(&tty->read_wait);29442945 INIT_WORK(&tty->hangup_work, do_tty_hangup);29452945- mutex_init(&tty->atomic_read_lock);29462946 mutex_init(&tty->atomic_write_lock);29472947- mutex_init(&tty->output_lock);29482948- mutex_init(&tty->echo_lock);29492949- spin_lock_init(&tty->read_lock);29502947 spin_lock_init(&tty->ctrl_lock);29512948 INIT_LIST_HEAD(&tty->tty_files);29522949 INIT_WORK(&tty->SAK_work, do_SAK_work);
+10-5
drivers/tty/tty_ldisc.c
···512512static int tty_ldisc_halt(struct tty_struct *tty)513513{514514 clear_bit(TTY_LDISC, &tty->flags);515515- return cancel_work_sync(&tty->buf.work);515515+ return cancel_work_sync(&tty->port->buf.work);516516}517517518518/**···525525{526526 flush_work(&tty->hangup_work);527527 flush_work(&tty->SAK_work);528528- flush_work(&tty->buf.work);528528+ flush_work(&tty->port->buf.work);529529}530530531531/**···704704 /* Restart the work queue in case no characters kick it off. Safe if705705 already running */706706 if (work)707707- schedule_work(&tty->buf.work);707707+ schedule_work(&tty->port->buf.work);708708 if (o_work)709709- schedule_work(&o_tty->buf.work);709709+ schedule_work(&o_tty->port->buf.work);710710 mutex_unlock(&tty->ldisc_mutex);711711 tty_unlock(tty);712712 return retval;···817817 */818818 clear_bit(TTY_LDISC, &tty->flags);819819 tty_unlock(tty);820820- cancel_work_sync(&tty->buf.work);820820+ cancel_work_sync(&tty->port->buf.work);821821 mutex_unlock(&tty->ldisc_mutex);822822retry:823823 tty_lock(tty);···897897898898static void tty_ldisc_kill(struct tty_struct *tty)899899{900900+ /* There cannot be users from userspace now. But there still might be901901+ * drivers holding a reference via tty_ldisc_ref. Do not steal them the902902+ * ldisc until they are done. */903903+ tty_ldisc_wait_idle(tty, MAX_SCHEDULE_TIMEOUT);904904+900905 mutex_lock(&tty->ldisc_mutex);901906 /*902907 * Now kill off the ldisc
···3131#include <linux/omapfb.h>32323333#include <video/omapdss.h>3434-#include <plat/cpu.h>3534#include <plat/vram.h>3636-#include <plat/vrfb.h>3535+#include <video/omapvrfb.h>37363837#include "omapfb.h"3938···23952396 goto err0;23962397 }2397239823982398- /* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE23992399- * available for OMAP2 and OMAP324002400- */24012401- if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) {23992399+ if (def_vrfb && !omap_vrfb_supported()) {24022400 def_vrfb = 0;24032401 dev_warn(&pdev->dev, "VRFB is not supported on this hardware, "24042402 "ignoring the module parameter vrfb=y\n");
···99 * published by the Free Software Foundation.1010 */11111212+#ifndef __MTD_ONENAND_OMAP2_H1313+#define __MTD_ONENAND_OMAP2_H1414+1215#include <linux/mtd/mtd.h>1316#include <linux/mtd/partitions.h>14171518#define ONENAND_SYNC_READ (1 << 0)1619#define ONENAND_SYNC_READWRITE (1 << 1)1717-1818-struct onenand_freq_info {1919- u16 maf_id;2020- u16 dev_id;2121- u16 ver_id;2222-};2020+#define ONENAND_IN_OMAP34XX (1 << 2)23212422struct omap_onenand_platform_data {2523 int cs;···2527 struct mtd_partition *parts;2628 int nr_parts;2729 int (*onenand_setup)(void __iomem *, int *freq_ptr);2828- int (*get_freq)(const struct onenand_freq_info *freq_info,2929- bool *clk_dep);3030 int dma_channel;3131 u8 flags;3232 u8 regulator_can_sleep;3333 u8 skip_initial_unlocking;3434};3535-3636-#define ONENAND_MAX_PARTITIONS 83737-3838-#if defined(CONFIG_MTD_ONENAND_OMAP2) || \3939- defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)4040-4141-extern void gpmc_onenand_init(struct omap_onenand_platform_data *d);4242-4343-#else4444-4545-#define board_onenand_data NULL4646-4747-static inline void gpmc_onenand_init(struct omap_onenand_platform_data *d)4848-{4949-}5050-5135#endif
+80
include/linux/platform_data/usb-omap.h
···11+/*22+ * usb-omap.h - Platform data for the various OMAP USB IPs33+ *44+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com55+ *66+ * This software is distributed under the terms of the GNU General Public77+ * License ("GPL") version 2, as published by the Free Software Foundation.88+ *99+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"1010+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1111+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE1212+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE1313+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR1414+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF1515+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS1616+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN1717+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)1818+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE1919+ * POSSIBILITY OF SUCH DAMAGE.2020+ */2121+2222+#define OMAP3_HS_USB_PORTS 32323+2424+enum usbhs_omap_port_mode {2525+ OMAP_USBHS_PORT_MODE_UNUSED,2626+ OMAP_EHCI_PORT_MODE_PHY,2727+ OMAP_EHCI_PORT_MODE_TLL,2828+ OMAP_EHCI_PORT_MODE_HSIC,2929+ OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0,3030+ OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM,3131+ OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0,3232+ OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM,3333+ OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0,3434+ OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM,3535+ OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0,3636+ OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM,3737+ OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0,3838+ OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM3939+};4040+4141+struct usbtll_omap_platform_data {4242+ enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];4343+};4444+4545+struct ehci_hcd_omap_platform_data {4646+ enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];4747+ int reset_gpio_port[OMAP3_HS_USB_PORTS];4848+ struct regulator *regulator[OMAP3_HS_USB_PORTS];4949+ unsigned phy_reset:1;5050+};5151+5252+struct ohci_hcd_omap_platform_data {5353+ enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];5454+ unsigned es2_compatibility:1;5555+};5656+5757+struct usbhs_omap_platform_data {5858+ enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];5959+6060+ struct ehci_hcd_omap_platform_data *ehci_data;6161+ struct ohci_hcd_omap_platform_data *ohci_data;6262+};6363+6464+/*-------------------------------------------------------------------------*/6565+6666+struct omap_musb_board_data {6767+ u8 interface_type;6868+ u8 mode;6969+ u16 power;7070+ unsigned extvbus:1;7171+ void (*set_phy_power)(u8 on);7272+ void (*clear_irq)(void);7373+ void (*set_mode)(u8 mode);7474+ void (*reset)(void);7575+};7676+7777+enum musb_interface {7878+ MUSB_INTERFACE_ULPI,7979+ MUSB_INTERFACE_UTMI8080+};
+10-34
include/linux/tty.h
···188188};189189190190struct tty_port {191191+ struct tty_bufhead buf; /* Locked internally */191192 struct tty_struct *tty; /* Back pointer */193193+ struct tty_struct *itty; /* internal back ptr */192194 const struct tty_port_operations *ops; /* Port operations */193195 spinlock_t lock; /* Lock protecting tty field */194196 int blocked_open; /* Waiting to open */···199197 wait_queue_head_t close_wait; /* Close waiters */200198 wait_queue_head_t delta_msr_wait; /* Modem status change */201199 unsigned long flags; /* TTY flags ASY_*/200200+ unsigned long iflags; /* TTYP_ internal flags */201201+#define TTYP_FLUSHING 1 /* Flushing to ldisc in progress */202202+#define TTYP_FLUSHPENDING 2 /* Queued buffer flush pending */202203 unsigned char console:1; /* port is a console */203204 struct mutex mutex; /* Locking */204205 struct mutex buf_mutex; /* Buffer alloc lock */···240235 struct mutex ldisc_mutex;241236 struct tty_ldisc *ldisc;242237238238+ struct mutex atomic_write_lock;243239 struct mutex legacy_mutex;244240 struct mutex termios_mutex;245241 spinlock_t ctrl_lock;···260254261255 struct tty_struct *link;262256 struct fasync_struct *fasync;263263- struct tty_bufhead buf; /* Locked internally */264257 int alt_speed; /* For magic substitution of 38400 bps */265258 wait_queue_head_t write_wait;266259 wait_queue_head_t read_wait;···270265271266#define N_TTY_BUF_SIZE 4096272267273273- /*274274- * The following is data for the N_TTY line discipline. For275275- * historical reasons, this is included in the tty structure.276276- * Mostly locked by the BKL.277277- */278278- unsigned int column;279279- unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;280268 unsigned char closing:1;281281- unsigned char echo_overrun:1;282269 unsigned short minimum_to_wake;283283- unsigned long overrun_time;284284- int num_overrun;285285- unsigned long process_char_map[256/(8*sizeof(unsigned long))];286286- char *read_buf;287287- int read_head;288288- int read_tail;289289- int read_cnt;290290- unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];291291- unsigned char *echo_buf;292292- unsigned int echo_pos;293293- unsigned int echo_cnt;294294- int canon_data;295295- unsigned long canon_head;296296- unsigned int canon_column;297297- struct mutex atomic_read_lock;298298- struct mutex atomic_write_lock;299299- struct mutex output_lock;300300- struct mutex echo_lock;301270 unsigned char *write_buf;302271 int write_cnt;303303- spinlock_t read_lock;304272 /* If the tty has a pending do_SAK, queue it here - akpm */305273 struct work_struct SAK_work;306274 struct tty_port *port;···313335#define TTY_PTY_LOCK 16 /* pty private */314336#define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */315337#define TTY_HUPPED 18 /* Post driver->hangup() */316316-#define TTY_FLUSHING 19 /* Flushing to ldisc in progress */317317-#define TTY_FLUSHPENDING 20 /* Queued buffer flush pending */318338#define TTY_HUPPING 21 /* ->hangup() in progress */319339320340#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))···388412extern void no_tty(void);389413extern void tty_flip_buffer_push(struct tty_struct *tty);390414extern void tty_flush_to_ldisc(struct tty_struct *tty);391391-extern void tty_buffer_free_all(struct tty_struct *tty);415415+extern void tty_buffer_free_all(struct tty_port *port);392416extern void tty_buffer_flush(struct tty_struct *tty);393393-extern void tty_buffer_init(struct tty_struct *tty);417417+extern void tty_buffer_init(struct tty_port *port);394418extern speed_t tty_get_baud_rate(struct tty_struct *tty);395419extern speed_t tty_termios_baud_rate(struct ktermios *termios);396420extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);···511535/* tty_audit.c */512536#ifdef CONFIG_AUDIT513537extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,514514- size_t size);538538+ size_t size, unsigned icanon);515539extern void tty_audit_exit(void);516540extern void tty_audit_fork(struct signal_struct *sig);517541extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);···520544 kuid_t loginuid, u32 sessionid);521545#else522546static inline void tty_audit_add_data(struct tty_struct *tty,523523- unsigned char *data, size_t size)547547+ unsigned char *data, size_t size, unsigned icanon)524548{525549}526550static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch)
···314314int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel);315315void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel);316316317317+enum omapdss_version {318318+ OMAPDSS_VER_UNKNOWN = 0,319319+ OMAPDSS_VER_OMAP24xx,320320+ OMAPDSS_VER_OMAP34xx_ES1, /* OMAP3430 ES1.0, 2.0 */321321+ OMAPDSS_VER_OMAP34xx_ES3, /* OMAP3430 ES3.0+ */322322+ OMAPDSS_VER_OMAP3630,323323+ OMAPDSS_VER_AM35xx,324324+ OMAPDSS_VER_OMAP4430_ES1, /* OMAP4430 ES1.0 */325325+ OMAPDSS_VER_OMAP4430_ES2, /* OMAP4430 ES2.0, 2.1, 2.2 */326326+ OMAPDSS_VER_OMAP4, /* All other OMAP4s */327327+ OMAPDSS_VER_OMAP5,328328+};329329+317330/* Board specific data */318331struct omap_dss_board_info {319332 int (*get_context_loss_count)(struct device *dev);···336323 int (*dsi_enable_pads)(int dsi_id, unsigned lane_mask);337324 void (*dsi_disable_pads)(int dsi_id, unsigned lane_mask);338325 int (*set_min_bus_tput)(struct device *dev, unsigned long r);326326+ enum omapdss_version version;339327};340328341329/* Init with the board info */
+11-1
kernel/printk.c
···8787struct console *console_drivers;8888EXPORT_SYMBOL_GPL(console_drivers);89899090+#ifdef CONFIG_LOCKDEP9191+static struct lockdep_map console_lock_dep_map = {9292+ .name = "console_lock"9393+};9494+#endif9595+9096/*9197 * This is used for debugging the mess that is the VT code by9298 * keeping track if we have the console semaphore held. It's···19141908 */19151909void console_lock(void)19161910{19171917- BUG_ON(in_interrupt());19111911+ might_sleep();19121912+19181913 down(&console_sem);19191914 if (console_suspended)19201915 return;19211916 console_locked = 1;19221917 console_may_schedule = 1;19181918+ mutex_acquire(&console_lock_dep_map, 0, 0, _RET_IP_);19231919}19241920EXPORT_SYMBOL(console_lock);19251921···19431935 }19441936 console_locked = 1;19451937 console_may_schedule = 0;19381938+ mutex_acquire(&console_lock_dep_map, 0, 1, _RET_IP_);19461939 return 1;19471940}19481941EXPORT_SYMBOL(console_trylock);···21042095 local_irq_restore(flags);21052096 }21062097 console_locked = 0;20982098+ mutex_release(&console_lock_dep_map, 1, _RET_IP_);2107209921082100 /* Release the exclusive_console once it is used */21092101 if (unlikely(exclusive_console))