|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ x" c$ I1 ?2 k% X2 a#include <linux/init.h>
& \$ A' ]( I: ^#include <linux/module.h>
4 ?! U# B X* \: ?; G#include <linux/kernel.h>" s* }! n! n- @- ]
#include <linux/types.h># I. q8 K6 _+ a8 d% H, o3 }
#include <linux/gpio.h>
: {$ ^% _* C6 o% O#include <linux/leds.h>
" `+ d- p! R2 y1 n4 B#include <linux/platform_device.h>
/ F9 T5 {$ n! H1 R1 S
* {" t, \ T* U# V( [% T5 t4 H6 n7 b#include <asm/mach-types.h>8 s, H* }' U7 z; J o
#include <asm/mach/arch.h>* D' |$ j# c/ z$ t% w. V
#include <mach/da8xx.h>
" G1 K) g3 W* e! }2 K* k#include <mach/mux.h>- u e s) ^( M1 N
. ^' m* c- M( b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) a1 P; [. k! Z5 Q8 x" ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 I) H$ X9 f0 m) }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# M+ g2 S: z( ?& B+ j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' f" C! z; o6 k, {
( _" z9 ?8 c- a2 P# X' S/* assign the tl som board LED-GPIOs*/
, k- E4 F9 i# K- `: n0 r3 ] V1 \static const short da850_evm_tl_user_led_pins[] = {
6 n6 ]* I: R5 M. v /* These pins are definition at <mach/mux.h> file */
7 H; f( }7 A! s2 u1 H1 J: E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* p: u1 x% ]! I7 |1 h/ |9 q
-1* O* x( C6 I# ?
};
" }; S# }& W/ l5 l5 t- L5 Q' f1 F3 ?9 |8 x/ y) {: S' {. u# _7 @
static struct gpio_led da850_evm_tl_leds[] = {
5 [9 X4 i7 z* m {4 J3 [* U2 @; Z J# P4 H: n4 v8 m
.active_low = 0," _% q" v( C4 y/ i( ~3 n* Y
.gpio = DA850_USER_LED0,
9 X2 j- W6 L6 v .name = "user_led0",
2 c# r) }( A+ d# C* ^0 h2 W/ E .default_trigger = "default-on",
( T( g2 m, X k; H# H8 ]8 q$ k },
B6 _) |* V1 I! ]$ X {, e" }0 m( @' L( Y C
.active_low = 0,
" p2 M1 c9 J% P .gpio = DA850_USER_LED1,3 V, R2 v. R7 Y
.name = "user_led1",
. [4 Z3 x) S- D9 r .default_trigger = "default-on",5 v9 C% \ n" Y6 [
},
, i, P8 D% l, K# v+ p. w' B% @ {/ Y! k1 _' g" I Q5 o6 @, G
.active_low = 0,' h/ j. ^8 J1 l) }
.gpio = DA850_USER_LED2,
+ R2 d, \% X2 a/ q .name = "user_led2",/ C, w# N) m' w4 O
.default_trigger = "default-on",
( y! E9 G" k# }4 d$ Q' w4 E% j4 C },
& D; X4 r4 F, [7 O, ^- M8 o {
* ~# ~% o: g, W. H& H .active_low = 0,
! o0 w3 d3 y( F* r4 V9 q0 A .gpio = DA850_USER_LED3,) U3 G1 k6 }2 w; M" s9 M5 [
.name = "user_led3",) A0 E* e7 J) |+ T
.default_trigger = "default-on",
( O! N0 H& b( Z },
: K4 w1 m6 v& R* _( {}; O9 S) G7 U T5 Z
" m9 ?8 l- H/ W& C9 P* b5 i) P0 Z) i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ @* e+ ` ? h/ o' Y .leds = da850_evm_tl_leds,
& A3 L' b) m* X$ W- l6 \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ |! l: s9 e' F# `8 g
};: x2 {( f l9 v a
7 P$ \: }. o. c" A/ M1 g
static void led_dev_release(struct device *dev). X3 w) i- J. h* x* F& ~. f7 c
{
) h! V8 i2 o {};' J# j$ B; d: ^+ H2 [) b, m
) ~, n: P8 F8 fstatic struct platform_device da850_evm_tl_leds_device = {7 \# |1 n6 Q/ g9 g% k/ G
.name = "leds-gpio",
) ~. F$ j4 c& i1 V9 _ .id = 1,
7 g C1 A1 H" }: s% R; w2 x& c .dev = {/ H% J9 {9 B- x
.platform_data = &da850_evm_tl_leds_pdata,; L, Z5 g/ ]" l
.release = led_dev_release,
; Z k# @4 Y% W8 a }" ~5 e0 ]+ \/ P; W
};5 c3 U% K7 e. U7 J- x0 e; G
; W3 _3 }/ Z+ r9 mstatic int __init led_platform_init(void)( m- H4 @% |* L: C5 y
{
* c7 z0 Z, A2 a+ e% @ int ret;1 K0 [6 D W# d! z) s3 U k# q; l
#if 0
5 G1 U# p# f7 B+ T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 ]" W( j- x3 n) t8 ]- Q
if (ret)% k8 M. {0 x5 N1 y. J! k( P0 @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 C8 W4 i! a+ d& P, u5 q
"%d\n", ret);
; e' d0 F4 z$ _6 J q$ W$ `#endif
5 H9 V- A) V1 p; s5 X ret = platform_device_register(&da850_evm_tl_leds_device); u8 u9 k( B* y; T- Y) f- ~
if (ret)
$ K5 ]0 u- O" H; A2 A1 S7 [6 v pr_warning("Could not register som GPIO expander LEDS");
2 x* i% w+ d2 h7 d else
. {# g9 [, p. D( {4 q printk(KERN_INFO "LED register sucessful!\n");' A! Y( ?. |) M7 A( Q- E
6 l$ Q- b6 @2 n return ret;1 A7 G7 n+ L6 G T: ~
}
: y! O! |' u# @* ?; ]+ u: n
; u) j% M0 P4 j4 x7 `static void __exit led_platform_exit(void)
$ v; h' g5 J8 M; K{# ?' U' K# i/ T0 j' U
platform_device_unregister(&da850_evm_tl_leds_device);: n6 P+ {3 y7 ~9 a. E, }' V
! j/ @6 t6 V: v$ L2 H+ s
printk(KERN_INFO "LED unregister!\n");9 |0 b" s1 T) u- Q( H' B
}2 k5 h# M# z: r- p) }$ V
- z, _- \# A0 C* q" M
module_init(led_platform_init);
% y! a3 z! }# E2 V. u# gmodule_exit(led_platform_exit);
, y2 r- J& v2 f- ?5 \0 R. D. ~- S$ i K' s9 U
MODULE_DESCRIPTION("Led platform driver");
J9 m& o" E, @/ YMODULE_AUTHOR("Tronlong");
6 i9 x: q- @6 OMODULE_LICENSE("GPL");
8 C% f. p/ w/ _6 g0 A: h: c3 V L7 @- K3 h
|
|