|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; B4 T- W6 W& R" P( }' H% d
#include <linux/init.h>
! t3 S$ T- ?+ Q+ ^2 s" L1 d& w5 x5 l#include <linux/module.h>
0 I3 C7 J$ e8 i#include <linux/kernel.h>
+ X$ d5 P- h# O2 y/ N#include <linux/types.h>4 ]) l: g' a3 r/ D$ l( Q" A. S- m* A
#include <linux/gpio.h>; t/ W/ C- ^& t6 b
#include <linux/leds.h>$ J/ n# {; \5 K% `: J
#include <linux/platform_device.h>( t$ W) u4 V8 [8 ~# u! n' ]
9 ]# C6 P. V& |; V* ^+ L( n" x#include <asm/mach-types.h>' _! Z! ]5 S+ d
#include <asm/mach/arch.h>
! a" K7 [8 S- x; ~1 v#include <mach/da8xx.h>
. B2 k% q9 v7 e#include <mach/mux.h>/ ~2 Y) f+ P& O. q5 C1 J0 R
% b' l s8 } x$ t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 M+ X v6 t( x2 m7 f/ c. {: Y' K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ s. [2 J' X0 Q( S1 ? X6 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- o5 G" v) h' l" B$ A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ c/ I' q! s H
; }1 W9 T2 v) E9 F/* assign the tl som board LED-GPIOs*/% x2 i/ {' D$ H! F
static const short da850_evm_tl_user_led_pins[] = {
' S( L" f; u7 p7 I; c4 V- f7 ^ /* These pins are definition at <mach/mux.h> file */
) O- O- A8 T! I6 P) X3 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 D+ q/ Y+ Q# e- V, R6 }6 O& e! B -1- X3 i' {2 _( G U0 _
};, n3 v3 Y/ A0 q, g, V; T
. r9 w6 p+ ?+ O% U" U
static struct gpio_led da850_evm_tl_leds[] = {0 e6 B4 F: O, F. B' `9 o! u
{2 Q: h( C' T% W. T& ]; w
.active_low = 0,
% f: \4 |, L. B3 u3 W1 C9 H- x .gpio = DA850_USER_LED0,# q9 X( `& e$ ~# W! n$ d) T/ h
.name = "user_led0",
' ]4 ~- X4 x: R. N .default_trigger = "default-on",/ f5 [7 ]- p: i! ?) [
},: W7 N! {7 r# V& ?5 b7 P4 s
{
, s& G/ M% D3 i0 \/ m' w" c .active_low = 0,: h1 a+ g- n4 O3 h7 M6 K1 C/ y
.gpio = DA850_USER_LED1,
, x) B+ t+ j8 r$ R2 l- o( D .name = "user_led1",' Z1 a$ u+ I0 ]; G
.default_trigger = "default-on",
, V' e' d7 l! @5 }- n6 G" h },
- }. f! o( C8 n% N n# a/ W {
! W+ J( ?- R& r R( o4 v) Y: v' U .active_low = 0,0 k4 K5 i/ n. Y0 U
.gpio = DA850_USER_LED2,
4 H8 V4 l. t0 z7 L .name = "user_led2",9 t" F) c7 U, M) l
.default_trigger = "default-on",
" x' B: H$ I8 z4 M },
6 ?) w: p( k8 X" u6 L {
5 S- E! t# ? w0 U/ \$ o& @ .active_low = 0,: P% {* ?6 y5 G0 u% B
.gpio = DA850_USER_LED3,
7 U" Z: {3 k) ?1 |( W( i .name = "user_led3",
% O2 s7 ]9 u) W$ w" d E3 _* h- t .default_trigger = "default-on",+ S# `% o6 p4 a- o4 R# @( I. I
},
! j5 F4 G& R3 M& ~) N# L8 }};
/ U( \/ c) Y7 M0 b6 i2 ~7 g' n' Z/ w. B% r6 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' l7 B- X- ~, H* ^4 u: A) r2 w .leds = da850_evm_tl_leds,0 C! ?2 p- r3 Z- S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 C( Y$ @2 F& J: k3 R, q6 `};- }" _/ l \& l6 A/ b
/ A$ d' ]3 @! S) ]static void led_dev_release(struct device *dev)9 A, x) @; X! }
{) B( [/ q4 h6 q# E7 k( C7 z
};
( y5 c, N( N$ @; h/ v3 J& B+ U
# }9 \$ k5 y. o" @9 w% i) astatic struct platform_device da850_evm_tl_leds_device = {
7 t% z& | S. [$ I: i, |+ A .name = "leds-gpio",
( @% o0 n7 F( p) G+ O7 H .id = 1,! D: o2 w: U3 b5 L5 d7 {( z
.dev = {9 Z7 x/ f" ^4 e* f4 W
.platform_data = &da850_evm_tl_leds_pdata,
; K: w7 a6 e' Y$ s; f7 _ .release = led_dev_release,* `2 e' h5 S/ l6 k. Y4 w
}
5 u0 N$ X$ n- Y};6 S+ R9 d3 D* l9 s1 k
- D% e; L( O$ Y9 i3 o2 |, k( Z C+ wstatic int __init led_platform_init(void)
$ W: ^. p9 I. t; L8 Q+ \7 V{
, A. U1 Q d: o int ret;* J# T1 h+ L1 i J
#if 0
) _& }% h; V- v/ D0 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 A! j( y, y% i' o. M if (ret)
# K2 [! p- u M8 P% ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ }3 g+ s5 f' c5 u# n& D
"%d\n", ret);+ o) |8 c' C$ C5 i
#endif
D! }8 a6 M5 m ret = platform_device_register(&da850_evm_tl_leds_device);7 [/ ~9 S# m- q& ^
if (ret)% c$ |# e8 F& ]6 M# \
pr_warning("Could not register som GPIO expander LEDS");
0 P$ x& F+ l! \* o8 } else
$ E9 q6 ~- Z9 `$ ]0 U printk(KERN_INFO "LED register sucessful!\n");1 N" c& M! x: V1 a. \/ N) ?
4 P( e' W2 q1 G- z: ?6 `7 \
return ret;
+ a9 E% R% Z0 d! }+ w/ `0 W}9 C: A9 I2 k+ A; m, q0 ^
# B/ F, ^9 B1 l0 ?static void __exit led_platform_exit(void)3 k+ |" m5 b1 j8 m* n9 N+ n
{
) E2 A, }- t( A9 Z3 u8 U platform_device_unregister(&da850_evm_tl_leds_device);
& g; }5 _/ l/ T1 b1 v1 q
+ o, m s/ ` |% P1 L' j printk(KERN_INFO "LED unregister!\n");
( n; E* | ~ x1 e}
& w6 G+ ~5 A$ U' }; ~( h6 R8 T; ?8 K, n* C- Z6 h" }) {8 i3 o( l& V
module_init(led_platform_init);6 h8 i9 L. Z! [) E( u) J5 F& g$ U
module_exit(led_platform_exit);
k' ~, z# p/ P8 |5 M( `% g. n8 V3 _! I Y& R
MODULE_DESCRIPTION("Led platform driver");! W+ L* B& r* a+ Q4 {) A
MODULE_AUTHOR("Tronlong");
6 l7 Q/ F. g3 _6 g5 F( ~MODULE_LICENSE("GPL");
4 E+ j0 d! i7 I; O! D3 l0 u3 ^; G- w7 i3 E3 @3 c
|
|