|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& e* r+ b5 H, N$ I#include <linux/init.h>
5 A) i4 P9 r {& w: u& S$ ~#include <linux/module.h>" C. t+ _1 @( O; z
#include <linux/kernel.h>- W, W5 {) E' p/ Z: N, `/ t
#include <linux/types.h>" O: m) W5 l/ M" b M" E& x/ Q+ _1 b
#include <linux/gpio.h>; F2 B* K; A- Z4 z. _
#include <linux/leds.h>
2 v8 E) L1 m4 k8 X+ N" H#include <linux/platform_device.h>7 u! A8 J' M% j7 A9 t. o% ~
E! @* Q+ X @& S$ _#include <asm/mach-types.h>
7 I$ a: t; N) j#include <asm/mach/arch.h>0 t9 X& g' l, [' m
#include <mach/da8xx.h>
4 m& l" S0 L" Y. y# M#include <mach/mux.h>. W9 S7 |) {& v% G6 L, @
. q- D4 m+ R/ U5 h# M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- {* K& v8 U \7 c* g: A0 {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" R' J* x: `5 w( b' E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 }) I4 q8 H* i) n+ L$ @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! p! t+ v( |: q! Q0 s+ r% Z& M# r! R3 \+ d
/* assign the tl som board LED-GPIOs*// `( ~) E7 @. _8 f
static const short da850_evm_tl_user_led_pins[] = {0 B0 e& F4 N+ P6 l7 [- e
/* These pins are definition at <mach/mux.h> file */
7 O/ U* H4 I% _8 o- f" a4 [( U* w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- C6 J N$ Q4 w% ` -1
, r2 p8 Q F6 v: G& z. D* _};
& W9 m: V! |* X% s7 T. T9 o! N0 V/ @ U$ R% N
static struct gpio_led da850_evm_tl_leds[] = {
7 ]( ~8 y S+ `1 @5 {6 k- Y' ]4 d& [ {, B5 r6 j; |+ B
.active_low = 0,
T" u9 k4 f" F! F. S6 W .gpio = DA850_USER_LED0,
! c5 ~* c4 @5 N- b .name = "user_led0",' \1 X- d) {. }$ F3 e; m
.default_trigger = "default-on",
- N( s1 E' o9 v+ F },/ S A7 E+ z4 I% H7 v
{- w( ]1 K6 H' K- u' \7 n! K
.active_low = 0,
' T- Y' O; c" _+ e .gpio = DA850_USER_LED1,1 r+ l8 Z1 y u. G q
.name = "user_led1",
& `% n f3 D8 ]) d2 e# h3 T .default_trigger = "default-on",
( D4 ~7 B9 f2 F& O },
& \& |9 d! r8 z. \ {: r" v Q+ O) i, q6 J# n
.active_low = 0,+ Q! U. F& v0 s% a
.gpio = DA850_USER_LED2, S; p- J1 {- P9 D& w
.name = "user_led2",
( Q, [1 I& T, f. T( t! j6 H5 ? .default_trigger = "default-on",/ P G" a' S/ |
},
( X' L- j; y( M/ @ {; K4 f9 f8 q4 K6 _4 D
.active_low = 0,' U# h. J" }7 m4 E# P
.gpio = DA850_USER_LED3,
: U: y! V7 n! O& k .name = "user_led3",
; E. [" u3 t$ O% y h6 ?$ b .default_trigger = "default-on",. l: Z! ~; {8 a- I: N
},9 Q$ O5 X+ ^4 h* I4 {, P& b2 q
};
e+ e+ F9 }* x1 w: W- g9 x, S: @) Q) t M1 h" O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ `( i* w1 B( c# P .leds = da850_evm_tl_leds,' x8 F& U Y2 R) ]% ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 o& m$ x. p4 l5 e4 I: A( f* V};
) H6 G: c: N" M% V6 B! I, r0 O
static void led_dev_release(struct device *dev): g; G; v( n3 e6 m; z
{
/ Y$ b2 S( n, p c};
6 R2 D; J N+ A2 p0 S6 ]" B
6 A$ q: o+ f* x! v; estatic struct platform_device da850_evm_tl_leds_device = {
* `+ |- `) ~; H3 S2 ? .name = "leds-gpio",. B' J L3 k! s S7 `0 S$ Y( B
.id = 1,
" K4 K* p* b6 D* P& r+ ~ .dev = {
8 `9 K3 W$ s3 | .platform_data = &da850_evm_tl_leds_pdata," g5 ^4 U$ b. o/ A
.release = led_dev_release,) A8 i7 q' V5 R( t
}
. u; Q2 c# K, u3 V$ f};
/ ^4 [1 I$ ^1 G- ]5 m) d; j# g
- L- u7 c- ?6 X6 x* rstatic int __init led_platform_init(void)
' E( _/ o( R2 \9 `$ m{
( X5 [; ^& U: Q8 J3 n int ret;2 F; `( A6 ^/ `" L, g4 C7 [* L5 C4 x
#if 0
+ ]! W7 R8 w& L% P3 I2 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 r5 C% ?* v2 j" B# M8 p' d- U if (ret)
9 o& b" C+ a# e& l* }$ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( P i- O0 l0 t# e) P8 Z, @4 m "%d\n", ret);
# G7 W+ Z+ u+ N& i#endif
' a* }& w% A% S' z+ W+ Z" Y2 X ret = platform_device_register(&da850_evm_tl_leds_device);* f! L4 @8 h4 f$ p# v
if (ret)
: s- l2 ?) W8 q/ s% S pr_warning("Could not register som GPIO expander LEDS");
0 D, Q* b- \2 j. \7 B# ]4 i% Y else
^% X4 H% ~4 T% s printk(KERN_INFO "LED register sucessful!\n");0 {- E7 p" e: |6 r, N% x; z9 T
: L& s! o' y9 o" n/ J. [7 r
return ret;( H: S) l: t- I+ Z* s
}3 @7 i3 O# [6 b0 l: p5 A& B
6 g* j6 z# k/ zstatic void __exit led_platform_exit(void)
* d9 G" ~6 v! ?% H- b{
7 Z0 z* c0 l. [ platform_device_unregister(&da850_evm_tl_leds_device);2 \9 @& m1 C: x0 R' e% y' K
: }2 J' d$ A& k' s7 o, ? printk(KERN_INFO "LED unregister!\n"); l) a9 W5 w" A6 |* ?" W
}* w1 f) |$ d: a0 O; V
" ]$ k( b5 i$ m" t) P- s
module_init(led_platform_init);% d( W" K: r2 m8 T
module_exit(led_platform_exit);
- G5 r* G1 E2 T! W4 m5 R ?; U, H4 a1 D
MODULE_DESCRIPTION("Led platform driver");
/ x% g/ s7 v$ [' |; y4 P# O) KMODULE_AUTHOR("Tronlong");
6 B5 B3 j5 ]0 W t3 ]' PMODULE_LICENSE("GPL");+ j/ r9 L" I( M1 z0 H- z
7 w& f' N" s- ]
|
|