|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( ?- G; A/ ?$ c1 x
#include <linux/init.h>
+ K: o3 B- E9 j9 m#include <linux/module.h>
8 a' [0 i% d( `3 I) F3 ]2 _#include <linux/kernel.h>
# e0 }9 u% m4 l# A#include <linux/types.h>/ P8 H# }- z0 S4 o6 _: @
#include <linux/gpio.h>4 n# w" H2 R7 ~3 _. n& Y
#include <linux/leds.h>
; [, I q4 U) J1 B6 x0 w' j#include <linux/platform_device.h>
4 B! Y& s. @* I- M* r c' {5 H- T- Z' V4 u
#include <asm/mach-types.h>
8 }! h4 g" R! y#include <asm/mach/arch.h>
5 p, z) D% a7 P8 |! c% M#include <mach/da8xx.h>" w% u% z9 R: s5 @ o+ T
#include <mach/mux.h> ]4 d2 ~9 g9 y
1 h0 ~3 ^4 `( B: A7 x% J6 C# E/ m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" Y- l0 S9 R+ H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- _. c. V0 \( ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 R/ _" B( g2 j7 U% N/ g) ?4 z: a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 h' P- p) l- V$ {7 }- Z0 _+ O$ i
& L# V1 B' S9 h/* assign the tl som board LED-GPIOs*/; }( n' [4 J6 j0 c
static const short da850_evm_tl_user_led_pins[] = {
( ^0 A/ j F+ v4 r) [/ h* m /* These pins are definition at <mach/mux.h> file */
4 Z* w" Q. r8 q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ s, Y `1 }$ Y0 e
-15 ]9 J# b) C. V. \- B) E( b
};
# V: d0 A; a$ A* \, v4 G% q7 A) J8 y* c
static struct gpio_led da850_evm_tl_leds[] = {" N: S5 E% u' ?- q; G
{( g- Q. [7 E# d0 G0 K% m* G
.active_low = 0,
" H# S C* |/ [# X# ^4 | .gpio = DA850_USER_LED0,
' ?8 U3 e3 J) {+ c8 z .name = "user_led0",
) J8 k3 j( g/ D& e1 m6 a+ r .default_trigger = "default-on",
" l2 [: b" C! k# a' M },& @7 L j e8 ^' u
{" z5 x: O: K8 N+ y; `
.active_low = 0,
8 T" o+ y: U2 z0 d8 ~ n t .gpio = DA850_USER_LED1,
+ q& B( ^! u( h" I( M: b9 f .name = "user_led1", K) |+ [2 Y5 C/ q4 x
.default_trigger = "default-on",
! @& s8 M+ T2 u7 U/ O) l },
! g" o2 s4 q8 {0 H% R {
( f1 t$ ~7 d0 X- M .active_low = 0,
0 |' b9 @& m- u+ L, A .gpio = DA850_USER_LED2,
4 ~4 W g4 h, B3 K .name = "user_led2",
" F2 M1 J; J" {" ` .default_trigger = "default-on",
: P' U7 j2 ]1 r" W7 H4 n/ c1 k },0 W9 h5 |- t7 B$ `1 p5 F
{
/ ~9 W# L: o n# E" Z: \ .active_low = 0,
" ]$ ~ c0 L) v c e$ q .gpio = DA850_USER_LED3,. e2 o& o4 B0 E+ q! k" ^4 z' p
.name = "user_led3",
* e1 P. T$ D/ {: E .default_trigger = "default-on",
% Z" s6 d( _: V: X2 b },! R- o8 m* e8 s8 n+ h4 p6 ~8 z( |
};
+ j1 L1 j4 R" b# R- z* f0 m: u9 A5 j6 N# @" U( r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- W2 M, w6 p# {; n
.leds = da850_evm_tl_leds,. Q+ k- y/ k4 D! g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 B' c+ X1 q3 V8 d- @. V q};
- Y5 L" \% W4 N
* @; E$ w$ s3 hstatic void led_dev_release(struct device *dev); i" ~; O! R/ y. L4 S+ D
{
; f& a+ K! T% n' |. @' ~ `};
) n) k6 R) U/ Z+ W: g& a2 B& }+ }8 v3 X3 X4 F
static struct platform_device da850_evm_tl_leds_device = {
1 O3 q2 e2 O# ^- h& o .name = "leds-gpio",
9 g/ D, E6 v& \% c .id = 1,
( }: D6 s/ h5 x, l .dev = {
7 R0 h4 y, B- n9 P* E x .platform_data = &da850_evm_tl_leds_pdata,
8 [) P a5 r+ g" Q .release = led_dev_release,
6 G& I2 D1 f0 p4 t8 W( t/ \$ k: Q }) j1 x1 `. Q/ c; S2 R/ L! }/ w
};/ X* C+ V2 Y, W4 L# t9 I
: k6 p8 j( X5 U) f+ y) [7 d. b3 n9 f
static int __init led_platform_init(void)
5 d: W% O2 v+ S" H$ X{
( `8 `2 L, g& \: y int ret;+ O0 n: T' M8 v+ H5 Y
#if 0: Q7 f: X# L6 @$ Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ j' ~! H/ K% `+ d; ?5 A
if (ret)1 e; r8 R {6 q9 u; d+ n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ Y0 ~& l, d" x2 C# a' }
"%d\n", ret);
1 ~. j4 a+ L5 E0 w. Z0 R5 i#endif
5 f: c8 w3 [' E6 t6 E4 O ret = platform_device_register(&da850_evm_tl_leds_device);
5 {7 L# _, |* E9 r, s if (ret)- R! \) T1 U+ _
pr_warning("Could not register som GPIO expander LEDS");
/ ?- I, ^7 ~4 I3 {) s! ] else( r2 O: Y4 S5 O. o) K" D
printk(KERN_INFO "LED register sucessful!\n");
3 l! y5 n' m% x3 @1 F: W3 P
6 h8 B0 z9 n/ J; @2 [& Y$ o9 a return ret;; `% ~1 L* O6 ]0 `& f% s
}8 T$ j" A$ Q8 X' {: H0 k
) E/ b% r. O fstatic void __exit led_platform_exit(void)7 b; i4 y0 C4 ^9 r
{* B( i) X W1 g* i4 t x
platform_device_unregister(&da850_evm_tl_leds_device);
' L+ u" f$ r; V3 |) y& R" o0 ^; u" K7 K7 G% S
printk(KERN_INFO "LED unregister!\n");
, r U# z/ e8 k4 Z; D}
$ F2 i+ z% H+ I' z
! N% v8 F; [, s& `1 Rmodule_init(led_platform_init);
' ~6 v6 w: B6 H! b3 T2 |module_exit(led_platform_exit);
/ `' c5 Z# l/ {9 N: f
2 Q" x; a! D' aMODULE_DESCRIPTION("Led platform driver");
9 {% b$ ]: _. C; {: e, BMODULE_AUTHOR("Tronlong");
& R6 h- w# _) c9 C) |4 ZMODULE_LICENSE("GPL");/ s( t( m' Q7 M. Y" S. I4 l2 D( h
- x* N( o* K+ l% Z. T1 v$ ]% B |
|