|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: _$ R; i3 a+ q) ~1 I) ?, ?#include <linux/init.h>
% B2 ?( F; q8 U$ `#include <linux/module.h>
7 ]- P( o1 R( O6 N8 g: M#include <linux/kernel.h>: d' n9 ~2 r0 X/ J' I; F5 a
#include <linux/types.h>
$ t8 ]/ B/ q. V; A: S- d3 q$ E. `3 i- B#include <linux/gpio.h>
; F3 @! g0 b$ J' e1 u#include <linux/leds.h>( w+ n8 {! Z% y% }3 U
#include <linux/platform_device.h>& ?/ ?/ u% M$ G
6 e4 y/ Y6 l1 D/ y5 l/ h#include <asm/mach-types.h>8 a8 I+ O! f% G' ~: a: g% F. c m2 X
#include <asm/mach/arch.h>
+ ]8 ]& l1 \. f8 J, v#include <mach/da8xx.h>
; ^: n( X2 h+ Z6 U#include <mach/mux.h>
* m& K7 p8 i* ^$ M
& l- x0 i6 }+ q( [: e" ?# u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): ^5 c) A n' P0 b( v S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ D/ d. c3 h l/ G/ ^9 d% k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) ~! K' v- e& M+ T! D7 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ C+ {0 i+ s1 S+ b
" }& r0 ?6 u+ C7 W. P/* assign the tl som board LED-GPIOs*/. L7 {7 \' K6 }' N
static const short da850_evm_tl_user_led_pins[] = {% l* r4 S$ D' y' E" i9 p1 e, J
/* These pins are definition at <mach/mux.h> file */+ j# @2 P& k3 f) }+ a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) I6 J1 w2 u7 ^. y7 M/ {
-1
5 S: [0 m8 W- p6 w$ y' R};
. w0 K( V! s0 {* E+ j* ~2 E7 K1 V2 H& y% V" d
static struct gpio_led da850_evm_tl_leds[] = {5 S! ?9 j y1 k2 `8 E
{
0 d4 W2 p; u( ~5 a4 c2 F' R: m* [ .active_low = 0,
: W% ~- |4 k$ C. ~6 `6 i5 Q# n0 u .gpio = DA850_USER_LED0,% u) U! \( X$ D! K( m
.name = "user_led0",
9 ?. v9 G) }5 r* G .default_trigger = "default-on",
# _ u5 N, [/ _ },
9 }9 @: U# _7 C3 a {5 {/ L1 z" L( L' X
.active_low = 0,; b0 i6 Z' p% ]( C7 m
.gpio = DA850_USER_LED1,, k5 i# l ~& R/ {
.name = "user_led1",
, ], v1 `) q/ I- G" p4 ]5 j .default_trigger = "default-on",
0 Z$ u2 _4 k: U2 | },3 s/ B- q9 z* D `, r+ i
{- N* A5 D1 S1 U% p4 y
.active_low = 0,
`$ Y9 B; `5 V g .gpio = DA850_USER_LED2,( @- _5 T% R z% x; \0 H9 @9 D
.name = "user_led2",% J% R; w" p0 Q! X9 ~) _8 n; d
.default_trigger = "default-on",8 a4 ~5 Q- `4 E' a ]* a0 _
},$ l4 S/ [# w, V- W6 g
{
" O1 ~4 c, A0 s* O; I, P .active_low = 0,/ [. @% u4 r! [; F) a# U" \
.gpio = DA850_USER_LED3," U2 j, ~) D* d, S, p+ e
.name = "user_led3",6 j: z" t$ u: I$ v
.default_trigger = "default-on",+ R- ?& M/ i s- s- D. U
},9 p# j( ]5 y1 q5 J7 v; ^
};5 o( `0 e/ [# R9 G( m
+ }- X4 K) ^9 ]5 }' Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 T" p3 Q2 \* R7 v .leds = da850_evm_tl_leds,
3 N5 P- ]3 y) \1 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 L; ^& X9 n0 m9 Z7 [' q' z};
" p2 L; D+ O) \+ {9 n$ F
: c9 P8 R( _* e9 _" v+ hstatic void led_dev_release(struct device *dev)& t: v8 j' ~6 B9 f' T3 s( [' \2 B; E
{
& g8 u; N$ j; y3 z) J) m! q};7 @7 y" S# N& O$ ]* t3 M+ P
. n$ Q5 u9 K2 e v x6 m! {
static struct platform_device da850_evm_tl_leds_device = {
$ Y4 P3 i- Y0 g7 t. M' v .name = "leds-gpio",; j. j5 m. c2 I2 R) y
.id = 1,* Y5 Z! E: J' E, \. |- h+ T9 M
.dev = {
' e8 v9 |+ E' e9 @2 q; R .platform_data = &da850_evm_tl_leds_pdata,, z; [# q' V% R
.release = led_dev_release, ^2 C( p4 N& ^+ Z% ]
}6 H, w' L! j$ ?" s5 b6 O
};
4 y& F/ ^1 {7 a/ Q7 w+ N- Q% U& l: _& T
static int __init led_platform_init(void)
4 n( e4 C/ a& E( p) ?8 P; f* t4 ^{
. U$ L9 N/ [# B) n' F int ret;3 {6 O; [1 W: L7 d A
#if 0
1 U% d# }6 m5 Y; X/ c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ j' A5 B: f: ~+ m- T) ~ if (ret)
* j1 q" o: @- \4 x b0 X2 L, |4 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 H; e* n- Z- x. F "%d\n", ret);' \ Y- V7 r0 U& K- |- b* |
#endif g. j# K. s# i% {# r6 ~
ret = platform_device_register(&da850_evm_tl_leds_device);" u4 T- z6 g! U1 Y
if (ret) m ^. A6 I' r/ ~
pr_warning("Could not register som GPIO expander LEDS");
- t5 ^3 S: \! J# B& t, \+ H# a" b else
" q9 _$ ~$ k& @! H printk(KERN_INFO "LED register sucessful!\n");
1 ^7 E" _% h! \4 C8 d3 K
8 V. F, q2 c: o$ ]% _3 f return ret;
. S3 W; w' W: O Q}0 |8 S& Z9 {" K4 E
8 k. b1 c w. _
static void __exit led_platform_exit(void)3 |4 W8 W* ?5 X z
{
7 N/ X$ V* w# a/ e* ]7 M- Y platform_device_unregister(&da850_evm_tl_leds_device);
$ K+ U" E# Z% T# Q0 [& Y- g- |$ o
printk(KERN_INFO "LED unregister!\n");
6 l' r; W, l# Z3 i! |}8 ^, ^. f* P3 u
& A+ X- [) g2 Q; A1 }module_init(led_platform_init);
( v, ~$ f' v0 i3 \6 q8 x! ^ e) mmodule_exit(led_platform_exit);3 Z1 A' J7 {4 g: }- r4 O
- X8 W$ n/ X# \ D2 b6 |MODULE_DESCRIPTION("Led platform driver");
9 K# c D) I! }7 P$ K" E# j5 nMODULE_AUTHOR("Tronlong");
4 t# Q* B; o3 D' x4 pMODULE_LICENSE("GPL");) y9 X; [/ @' ^# N# P% r i
+ u& W. t8 C: \' N! w5 Y2 D% n
|
|