|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: s0 c. M$ x+ V4 S: ]; ?#include <linux/init.h>2 w7 l" {6 ]+ h+ c
#include <linux/module.h>5 Z- V% D1 f$ t
#include <linux/kernel.h>3 y2 k- x# j' u, t0 |3 U5 I, f: G
#include <linux/types.h>1 Z0 W+ l- H2 o
#include <linux/gpio.h>0 N1 {5 a5 h! c6 m& N% C
#include <linux/leds.h>: K, s; ~4 u& {0 F
#include <linux/platform_device.h>1 x1 o) g1 r2 @
! \& g) X; G7 D2 X#include <asm/mach-types.h>1 V9 M: B/ m d/ z
#include <asm/mach/arch.h>. W; r k( Y7 ?: R% Q
#include <mach/da8xx.h>4 |5 s' k& x- h4 g5 [1 s
#include <mach/mux.h>
& y8 R& X5 M% A$ X( ^9 Z
9 p7 r/ l8 P3 ]+ I3 T2 o# I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* t& M5 z H0 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' y6 f7 X& Q( R* m4 G/ O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( c- r4 U- Q' @; Q+ }3 Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ \& n3 k* Y& b& K H) {+ P1 x8 _
6 u) ?/ O7 J: f' g! I" N/* assign the tl som board LED-GPIOs*/
$ C. }, ?6 g5 Ystatic const short da850_evm_tl_user_led_pins[] = { s8 P2 T0 v% b2 Q3 D% ~: T" f
/* These pins are definition at <mach/mux.h> file */: y* x% }, _% E+ x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* H T' ~: Q) k5 w s) ?
-1
7 R2 [/ j7 f6 l% E4 f4 N0 ^* V};' _0 m) C- l8 j
5 n% Q2 `2 R8 N. ^8 rstatic struct gpio_led da850_evm_tl_leds[] = {
1 W4 A6 p6 X0 ~9 F) f {0 ]9 ^- ]( F' x7 R* p
.active_low = 0,
7 ] ?' @8 A5 x, h .gpio = DA850_USER_LED0,
0 v( E- g4 Z- S1 Q( D .name = "user_led0",
H0 n( Z. N' _4 [7 b6 K# w0 z9 V' w .default_trigger = "default-on",+ \; L* ]% W) T9 p4 G
},! O D0 y, x+ H; m
{# O6 C0 u8 G1 M( N! G4 J! {% j1 j
.active_low = 0,
( X6 C5 Z# [9 f+ A( o' T .gpio = DA850_USER_LED1,
3 V7 s1 ^7 S' i' e2 p8 A6 {* k .name = "user_led1",
( h) }- f" G) Q2 r .default_trigger = "default-on",
% g2 X a. K# X) K, I. y6 A },
- C* K2 @4 t0 F, ?5 F) Z. c% w {4 ~0 {8 b( @ ~2 I+ }
.active_low = 0,
1 _5 {& G. K- z" h% e .gpio = DA850_USER_LED2,
. s6 X9 i S6 H .name = "user_led2",7 D* d5 o" Y3 I
.default_trigger = "default-on",- d, L4 H' c8 D3 u
},2 U( [/ o2 P+ g" S0 |4 \' A
{/ e4 d8 `& T4 U. ~ Z7 n
.active_low = 0,7 D3 @6 L2 N* J2 o/ ]
.gpio = DA850_USER_LED3,8 `+ K& `% o/ s9 l
.name = "user_led3",
) W/ H2 V8 l8 u4 f8 G& ]1 o9 }" K .default_trigger = "default-on",
: o, a% D$ x0 G/ H },6 M. v2 b! ]! Q4 _& ^! [
};# B6 E" E4 m2 _) k" _
% L5 t& v: F+ f1 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( {/ o0 R8 Q& U. |4 Z
.leds = da850_evm_tl_leds,
2 B, C% f9 u7 u9 @! y. q) O6 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 S/ h ]- A& u$ ~# ^* T
};
9 A$ f/ ]7 O1 H4 U5 \% o* G6 k/ m. I
8 w! v. x3 y! ]. Z0 u4 pstatic void led_dev_release(struct device *dev)5 `) _1 x& h+ X0 J* f
{
5 i8 ~3 l. `+ V; S$ B2 J+ L. R$ U};4 _/ y6 ~2 x' T% x0 j
e, k$ T* U, |. V9 N
static struct platform_device da850_evm_tl_leds_device = {
! h5 v" ?' D) P! e4 {/ O .name = "leds-gpio",
! `1 d) }$ P( x" I k* K5 T' n .id = 1,. V' |7 u8 H) g* h5 P- t
.dev = {8 v+ _- h" h) c
.platform_data = &da850_evm_tl_leds_pdata,
0 @5 M" r0 U) v .release = led_dev_release,
2 N$ `) P4 q9 U* E }) E9 Z, B# v. _& o( q
};0 T% }' g& r% G/ t" {
! l/ G' s. J% L; Z
static int __init led_platform_init(void)1 E) @; X+ d- f( F9 q& T, l" _
{+ q" o( K5 z4 {4 q- }
int ret;9 n( ~: f+ |* |6 Z6 t5 S8 _3 w6 ?
#if 0
% m4 ^! i( z o5 O; T$ s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! T+ B. b. T3 ^6 V1 w
if (ret)1 o+ q! [$ a& {, C k9 c& e Y& ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 v! k' I1 N# d" n "%d\n", ret);6 s9 d( i2 L0 a
#endif
9 Q! x- z8 O) L% j' q- ~* }. M1 u ret = platform_device_register(&da850_evm_tl_leds_device);
) v9 w- b+ R' V3 @# Y if (ret)
( i" o D+ N% q pr_warning("Could not register som GPIO expander LEDS");% d1 g# s; K6 B' _+ y1 k8 y1 c
else; L' Z x+ X2 L5 b! Y) j. W
printk(KERN_INFO "LED register sucessful!\n");6 d8 V+ a3 i- g; B( p
/ {% a) P- d3 A/ e return ret;
% c% a" E% w* w6 y" ^}1 ^9 o7 D4 g- i1 s( D8 B
U" e2 f, p# T, H
static void __exit led_platform_exit(void)
3 O; e+ x) }! b& z1 h, s{8 O& [% J$ ?" M% j$ F& r" @# e
platform_device_unregister(&da850_evm_tl_leds_device);
- Y( e0 U O O8 P I/ J9 H
% R0 o' k/ _. K: v printk(KERN_INFO "LED unregister!\n");
- v$ i# f$ v& @) X: f}8 [7 R/ |+ S$ D& a
; @! p' A. W9 ?+ p0 \module_init(led_platform_init);
/ r4 r0 h' i4 c8 C0 [1 J+ T# h; C6 W# Bmodule_exit(led_platform_exit);* M6 O4 l( @* d, P0 Z$ S e
, W& T a$ X2 xMODULE_DESCRIPTION("Led platform driver");
p8 O: N g9 bMODULE_AUTHOR("Tronlong");
* c3 S, \/ B- D' a3 c6 TMODULE_LICENSE("GPL");
$ W3 o4 G: T3 q' D; C' ~" v8 y4 E2 y3 [- e$ D* c
|
|