|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ L' ]& U* _3 C. {#include <linux/init.h>
" Z) ~% h( O# l4 O#include <linux/module.h>- ?, m% c3 e+ Y( W" t$ ?
#include <linux/kernel.h>' A( m- b, J Q/ ?+ N
#include <linux/types.h>7 C* _9 b' z9 i9 x5 L( r
#include <linux/gpio.h>% x9 f+ @$ F* \' _5 L% L
#include <linux/leds.h>" }; z1 L% w' s7 Q. d* I; Y9 \8 r
#include <linux/platform_device.h>
6 G; T `- U( M( W$ n6 j- ]& R' R) _) N
#include <asm/mach-types.h>9 _0 L% ~) j; f! u' }- k% W
#include <asm/mach/arch.h>' `& C$ W$ h5 X4 n
#include <mach/da8xx.h>
+ k. @4 M, l! ~* T9 h#include <mach/mux.h># K$ m( g6 P4 R0 L t
- T+ \, H) _0 m5 D% b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* h- w% p: p# T, ^: b+ z: p- B7 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* T- l& B5 `' ~, w- e% ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" g, ~7 h/ B b3 D+ {+ i9 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% p9 M" @/ K6 g6 Y4 a- ^
0 ^4 ~% m- V7 W' j. C; }# q
/* assign the tl som board LED-GPIOs*/ k+ d# X3 p# {# X* i3 D) ]
static const short da850_evm_tl_user_led_pins[] = {
+ K4 ^1 b7 w, C6 a) c8 L9 _ /* These pins are definition at <mach/mux.h> file */& s. `3 B) i; b* o- Z% o: {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' V& ]- a6 f6 S" s$ k Y
-19 b8 p% n/ n9 l8 g& h3 R# _
};% D. k9 |- y$ q$ a2 M
5 P( R. |/ f' \static struct gpio_led da850_evm_tl_leds[] = {" K4 C2 W" o# `& t- w' l
{7 \8 H% W% ` p( a+ S7 D/ F+ n
.active_low = 0,
) R5 j1 N. @1 ]) O2 K .gpio = DA850_USER_LED0,7 k& `0 [; c9 E' g# O
.name = "user_led0",2 v" p( F" s+ C; P9 h# `
.default_trigger = "default-on",
4 O: C7 f! o+ P" ^6 F, E$ e },. L; P/ m; k i+ S9 r
{
, ^3 h% |6 O0 p6 q; i9 u .active_low = 0,: x' m! e x4 z* j# p
.gpio = DA850_USER_LED1,
0 W" L7 X/ n B- ?0 ~5 t F# K7 h .name = "user_led1",
2 O5 v! O6 L, j% ^& Y3 z9 {- C1 \# G .default_trigger = "default-on",
/ n( b2 ^9 O9 }% r/ f, Q1 ~ },$ t; y! E u0 Q( T O" e% ]
{
& l9 B8 c# @8 V" W( p .active_low = 0,
3 X0 p: R" ^) X- Z7 \ .gpio = DA850_USER_LED2,
: N' b5 p2 {4 `' L [2 i .name = "user_led2",
" {8 i- t$ G6 p( o2 {% Z .default_trigger = "default-on",* }, M0 V2 }2 z! S0 \ x
},
) E2 I% G' J# T6 j8 o {
, v" s& R3 a" [. o& |3 ~3 F! }, v .active_low = 0,# ^, W4 P8 ?/ J" Q1 E' f; a' o+ } G
.gpio = DA850_USER_LED3,/ z5 { G7 W, ^/ c( y% s4 X
.name = "user_led3", M5 |5 V+ P4 u; ]& E8 l& ]7 @
.default_trigger = "default-on",
8 J3 |, w$ G4 o8 Y; ? },
( V b7 F/ z& m8 [9 {( @: J};9 U9 i/ R* o' K+ R: {% V
3 g$ ?* t% M: ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 C' K' O/ l" X' F# F .leds = da850_evm_tl_leds,
! G! ~( p6 i4 @" i! {% S7 k1 q( P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% l' I7 @0 p9 m+ Y# w};
% h! g2 }0 w0 q) }5 J* M! D6 _; x& I4 i: y
static void led_dev_release(struct device *dev)
* j3 \& ]7 O. h; l, Z8 H! ^5 Z{
, z! |2 r5 W: m% n) v& N};
: P, x* n v( _
$ j( P& {! V7 t. B3 M) C/ @0 m }static struct platform_device da850_evm_tl_leds_device = {4 U8 o- s3 q& X* b! d
.name = "leds-gpio",
7 \& h( I3 N/ t; Y7 ^) F8 v7 _ .id = 1,
0 b7 \7 L6 d3 Z .dev = {
- u# Y9 P2 ~9 s K" r: [5 ] .platform_data = &da850_evm_tl_leds_pdata,6 o1 m% z1 v8 {8 n! X
.release = led_dev_release,
8 I+ R2 W2 G5 L8 C }
0 o. f2 x0 p! X5 [ ~8 H* S" I};
8 n, Z# I% U" a6 j1 U2 Y. J! @3 z0 H, I- W4 F5 f
static int __init led_platform_init(void)
" K6 J2 A, v, k) e& M' N{1 m0 \4 s6 l! R+ C" e
int ret;
( D& R1 G# y0 p3 X0 U! i#if 0
- ]+ e* p7 e; l/ ^3 `+ G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 l6 U$ i& a T if (ret)" J2 t: f% d4 Q# i! S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- ^) T1 b: X3 [/ H7 k. e7 O
"%d\n", ret);2 V' b$ e+ v7 b- b- m4 g, F1 p* a
#endif
5 n1 @, w0 V, l ret = platform_device_register(&da850_evm_tl_leds_device);
7 c, ?* U- u+ T+ ~3 \2 v: C/ a if (ret)
% q9 L- U m7 D/ ^ pr_warning("Could not register som GPIO expander LEDS");& C/ l. D( ?8 N' s) X4 I* G
else
/ @3 i) e: T$ {% q% S, Y7 V+ r printk(KERN_INFO "LED register sucessful!\n");, @1 @2 t1 X1 z' w3 A
) A5 s! [* q: a( K! l return ret;
: I1 U2 Z# c) {* W. \- `}& A" r, z" _1 I: F: a1 K5 \# @( J
, p4 m& q" ^7 a3 o; pstatic void __exit led_platform_exit(void)
/ O" c3 ]" L: z# P" m' Z E{
4 y- b* E; T7 n/ ~$ `- s platform_device_unregister(&da850_evm_tl_leds_device);
3 T* h9 D5 U! G1 L/ y& K8 N# W" {" `+ V8 Z% B
printk(KERN_INFO "LED unregister!\n");
1 M/ t8 B( u2 d/ n$ U b. N/ c}
" d" O! m# C: G- R# @1 X/ n' t$ R
' Z" s4 _! N/ t, U7 V/ Omodule_init(led_platform_init);$ k! A* e9 r5 _/ ]; g. [" q3 [" @
module_exit(led_platform_exit);" S$ E; ?7 A% S/ o- e( s
8 W0 [5 f1 }+ W2 |
MODULE_DESCRIPTION("Led platform driver");+ {5 K6 }- L0 Q! V# E' t
MODULE_AUTHOR("Tronlong");
9 ^( w4 c7 I* `; B0 Q8 iMODULE_LICENSE("GPL");% q9 H! J5 [( q
m+ n# a, i, q7 S! s% q9 [* V |
|